Changeset 2496 for lang/actionscript/swfgmap
- Timestamp:
- 12/05/07 20:32:14 (13 months ago)
- Location:
- lang/actionscript/swfgmap/trunk
- Files:
-
- 1 added
- 8 modified
-
TestApp.as (modified) (1 diff)
-
gyuque/gmap/GMapView.as (modified) (1 diff)
-
gyuque/gmap/GridHash.as (modified) (3 diffs)
-
gyuque/gmap/IMeshMap.as (modified) (1 diff)
-
gyuque/gmap/IPanningLayer.as (added)
-
gyuque/gmap/Layer.as (modified) (1 diff)
-
gyuque/gmap/LayerManager.as (modified) (2 diffs)
-
gyuque/gmap/ViewportUpdater.as (modified) (10 diffs)
-
gyuque/gmap/googlemaps/GMapMapLayer.as (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/actionscript/swfgmap/trunk/TestApp.as
r2485 r2496 21 21 22 22 var T:Matrix = new Matrix(); 23 T.rotate(0. 2);23 T.rotate(0.9); 24 24 vp.setTransform(T); 25 25 setViewport(vp); -
lang/actionscript/swfgmap/trunk/gyuque/gmap/GMapView.as
r2485 r2496 74 74 protected function addGoogleMapLayer():Boolean 75 75 { 76 var lyr:GMapMapLayer = new GMapMapLayer(this );76 var lyr:GMapMapLayer = new GMapMapLayer(this, mSuperLayer); 77 77 lyr.debug_out = this; 78 78 mSuperLayer.push(lyr); -
lang/actionscript/swfgmap/trunk/gyuque/gmap/GridHash.as
r2454 r2496 4 4 { 5 5 private var mHash:Object; 6 private var mItCursor:int; 7 6 8 public function GridHash() 7 9 { … … 14 16 } 15 17 16 public function poke(x:int, y:int, dat: int):void18 public function poke(x:int, y:int, dat:*):void 17 19 { 18 20 mHash[makeKey(x, y)] = dat; 19 21 } 20 22 21 public function peek(x:int, y:int): int23 public function peek(x:int, y:int):Object 22 24 { 23 25 return mHash[makeKey(x, y)] || 0; … … 28 30 mHash = {}; 29 31 } 32 33 public function map(proc:Function, _this:Object):void 34 { 35 for each(var v:int in mHash) 36 proc.apply(_this, [v]); 37 } 30 38 } 31 39 } -
lang/actionscript/swfgmap/trunk/gyuque/gmap/IMeshMap.as
r2485 r2496 3 3 import flash.geom.Point; 4 4 5 public interface IMeshMap 5 public interface IMeshMap extends IPanningLayer 6 6 { 7 function getCurrentPanning(out:Point) :void;8 7 function get centerTileX() :int; 9 8 function get centerTileY() :int; 10 function reset Panning(tx:int, ty:int) :void;9 function resetOffset(tx:int, ty:int) :void; 11 10 function setTileOffset(ox:int, oy:int) :void; 12 11 function loadTile(tx:int, ty:int) :void; -
lang/actionscript/swfgmap/trunk/gyuque/gmap/Layer.as
r2413 r2496 12 12 protected var mLastDX:Number; 13 13 protected var mLastDY:Number; 14 protected var mParent:Layer; 14 15 15 public function Layer(eventSrc:EventDispatcher )16 public function Layer(eventSrc:EventDispatcher, parent:Layer) 16 17 { 17 18 eventSrc.addEventListener(GMapViewEvent.VIEWPORT_CHANGED, onViewportChanged); 19 mParent = parent; 18 20 } 19 21 -
lang/actionscript/swfgmap/trunk/gyuque/gmap/LayerManager.as
r2485 r2496 1 1 package gyuque.gmap 2 2 { 3 public class LayerManager extends Layer 3 public class LayerManager extends Layer implements IPanningLayer 4 4 { 5 5 import flash.display.*; 6 import flash.geom. Matrix;6 import flash.geom.*; 7 7 8 8 private var mLayers:Array = new Array(); 9 private var mPanPos:Point = new Point(); 9 10 10 11 public function LayerManager(c:DisplayObjectContainer) 11 12 { 12 super(c );13 super(c, null); 13 14 } 14 15 … … 27 28 M.ty = transform.matrix.ty; 28 29 30 M.tx = v.width * 0.5; 31 M.ty = v.height * 0.5; 29 32 if (refreshAll) 30 33 { 31 M.tx = v.width * 0.5; 32 M.ty = v.height * 0.5; 34 35 mPanPos.x = 0; 36 mPanPos.y = 0; 33 37 } 34 38 else 35 39 { 36 M.tx += mLastDX;37 M.ty += mLastDY;40 mPanPos.x += mLastDX; 41 mPanPos.y += mLastDY; 38 42 } 43 M.tx += mPanPos.x; 44 M.ty += mPanPos.y; 45 39 46 transform.matrix = M; 47 } 48 49 public function getCurrentPanning(out:Point):void 50 { 51 mViewport.transformVectorScreenToView(mPanPos.x, mPanPos.y, out); 40 52 } 41 53 } -
lang/actionscript/swfgmap/trunk/gyuque/gmap/ViewportUpdater.as
r2485 r2496 15 15 private var mReqQueue:XYQueue; 16 16 private var mUpdateTimer:Timer; 17 18 private var mLoadedTiles:XYQueue; 17 19 18 20 public function ViewportUpdater(listener:IMeshMap) … … 21 23 mGHash = new GridHash(); 22 24 mReqQueue = new XYQueue(); 23 24 mUpdateTimer = new Timer(100); 25 mLoadedTiles = new XYQueue(); 26 27 mUpdateTimer = new Timer(80); 25 28 mUpdateTimer.addEventListener(TimerEvent.TIMER, onTimer); 26 29 mUpdateTimer.start(); … … 35 38 if (prev == null) 36 39 refresh(); 40 else 41 update(); 37 42 } 38 43 } … … 40 45 private function onTimer(e:Event):void 41 46 { 42 if (mReqQueue.empty) 43 return; 44 45 var j:Object = {}; 46 mReqQueue.consume(j); 47 switch(j.v) 48 { 49 case 1: // load 50 checkAndLoad(j.x, j.y); 51 break; 47 update(); 48 49 for (var i:int = 0;i < 2;i++) 50 { 51 if (mReqQueue.empty) 52 return; 53 dout.puts("tiles:"+ mLoadedTiles.length +" queue:"+mReqQueue.length); 54 55 var j:Object = {}; 56 mReqQueue.consume(j); 57 switch(j.v) 58 { 59 case 1: // load 60 checkAndLoad(j.x, j.y); 61 break; 62 case 2: // load 63 checkAndUnload(j.x, j.y); 64 break; 65 } 52 66 } 53 67 } … … 79 93 if (nest == 0) 80 94 { 81 if (isTileVisible(x, y) != T_INVISIBLE)95 if (isTileVisible(x, y) == T_VISIBLE) 82 96 { 83 97 retval = true; … … 89 103 } 90 104 91 92 93 105 return retval; 94 106 } 95 107 108 private function isGoneOut(tx:int, ty:int):Boolean 109 { 110 return (isTileVisible(tx, ty) == T_INVISIBLE); 111 } 112 96 113 private function checkAndLoad(tx:int, ty:int):void 97 114 { 98 115 if (mGHash.peek(tx, ty)) 116 { 99 117 mListener.loadTile(tx, ty); 100 } 101 118 mLoadedTiles.push(tx, ty, 1); 119 } 120 } 121 122 private function checkAndUnload(tx:int, ty:int):void 123 { 124 if (!mGHash.peek(tx, ty)) 125 mListener.unloadTile(tx, ty); 126 } 127 102 128 private function addLoadJob(tx:int, ty:int):void 103 129 { … … 106 132 mGHash.poke(tx, ty, 1); 107 133 mReqQueue.push(tx, ty, 1); 108 109 dout.puts((tx-29095)+", "+(ty-12855)); 110 } 134 } 135 } 136 137 private function addUnloadJob(tx:int, ty:int):void 138 { 139 if (mGHash.peek(tx, ty)) 140 { 141 mGHash.poke(tx, ty, 0); 142 mReqQueue.push(tx, ty, 2); 143 } 144 } 145 146 private function update():void 147 { 148 149 var j:Object = {}; 150 var nextArr:XYQueue = new XYQueue(); 151 var len:int = mLoadedTiles.length; 152 153 for (;!mLoadedTiles.empty;) 154 { 155 mLoadedTiles.consume(j); 156 if (isGoneOut(j.x, j.y)) 157 addUnloadJob(j.x, j.y); 158 else 159 { 160 nextArr.push(j.x, j.y, j.v); 161 spread(j.x, j.y, 0); 162 } 163 } 164 165 mLoadedTiles = nextArr; 111 166 } 112 167 … … 116 171 var tiledata:Object = GMapCalc.calcTileData(v.centerNX, v.centerNY, v.zoom, 0); 117 172 118 mListener.reset Panning(tiledata.tile_index.x, tiledata.tile_index.y);173 mListener.resetOffset(tiledata.tile_index.x, tiledata.tile_index.y); 119 174 mListener.setTileOffset(tiledata.offset.x, tiledata.offset.y); 120 175 … … 142 197 mCurViewport.transformVectorViewToScreen(bx, by, p); 143 198 144 var padding:Number = GMapCalc.TILE_SIZE* 0.7;199 var padding:Number = GMapCalc.TILE_SIZE*1.2; 145 200 for (var i:int = 0;i < 2;i++) { 146 201 if (p.x >= (-mCurViewport.width*0.5 - padding) && p.y >= (-mCurViewport.height*0.5 - padding) && p.x < (mCurViewport.width*0.5 + padding) && p.y < (mCurViewport.height*0.5 + padding)) … … 171 226 } 172 227 228 public function get length():int 229 { 230 return Xs.length; 231 } 232 233 public function at(out:Object, i:int):void 234 { 235 out.x = Xs[i]; 236 out.y = Ys[i]; 237 out.v = Vs[i]; 238 } 239 173 240 public function get empty():Boolean 174 241 { -
lang/actionscript/swfgmap/trunk/gyuque/gmap/googlemaps/GMapMapLayer.as
r2485 r2496 12 12 protected var mCenterTX:int; 13 13 protected var mCenterTY:int; 14 protected var mLoadedTiles:GridHash = new GridHash(); 14 15 15 16 public function set debug_out(d:IDebugOut):void … … 18 19 } 19 20 20 public function GMapMapLayer(eventSrc:EventDispatcher )21 public function GMapMapLayer(eventSrc:EventDispatcher, parent:Layer) 21 22 { 22 super(eventSrc );23 super(eventSrc, parent); 23 24 mVPobs = new ViewportUpdater(this); 24 25 … … 60 61 tile.x = -c + otx*GMapCalc.TILE_SIZE; 61 62 tile.y = -c + oty*GMapCalc.TILE_SIZE; 63 64 mLoadedTiles.poke(tx, ty, tile); 62 65 } 63 66 64 67 public function unloadTile(tx:int, ty:int):void 65 68 { 69 var o:Object = mLoadedTiles.peek(tx, ty); 70 if (o) 71 { 72 removeChild( DisplayObject(o) ); 73 } 66 74 } 67 75 68 public function reset Panning(tx:int, ty:int):void76 public function resetOffset(tx:int, ty:int):void 69 77 { 70 78 mCenterTX = tx; … … 74 82 public function getCurrentPanning(out:Point):void 75 83 { 76 out.x = x; 77 out.y = y; 84 if (parent && parent is IPanningLayer) 85 { 86 IPanningLayer(parent).getCurrentPanning(out); 87 } 88 else 89 { 90 out.x = 0; 91 out.y = 0; 92 } 93 94 out.x += x; 95 out.y += y; 96 78 97 } 79 98
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)