Show
Ignore:
Timestamp:
12/05/07 15:55:38 (13 months ago)
Author:
gyuque
Message:

lang/actionscript/swfgmap

Location:
lang/actionscript/swfgmap/trunk/gyuque/gmap
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lang/actionscript/swfgmap/trunk/gyuque/gmap/IMeshMap.as

    r2456 r2477  
    11package gyuque.gmap 
    22{ 
     3        import flash.geom.Point; 
     4         
    35        public interface IMeshMap 
    46        { 
    5                 function resetPanning(tx:int, ty:int)                :void; 
     7                function getCurrentPanning(out:Point) :void; 
     8                function resetPanning(tx:int, ty:int)  :void; 
    69                function setTileOffset(ox:int, oy:int) :void; 
    710                function loadTile(tx:int, ty:int)      :void; 
  • lang/actionscript/swfgmap/trunk/gyuque/gmap/ViewportUpdater.as

    r2456 r2477  
    11package gyuque.gmap 
    22{ 
     3        import flash.events.*; 
     4        import flash.utils.Timer; 
     5        import flash.geom.Point; 
     6         
    37        public class ViewportUpdater 
    48        { 
     
    812                 
    913                private var mReqQueue:XYQueue; 
     14                private var mUpdateTimer:Timer; 
    1015                 
    1116                public function ViewportUpdater(listener:IMeshMap) 
     
    1318                        mListener = listener; 
    1419                        mGHash = new GridHash(); 
     20                        mReqQueue = new XYQueue(); 
     21                         
     22                        mUpdateTimer = new Timer(100);  
     23                        mUpdateTimer.addEventListener(TimerEvent.TIMER, onTimer); 
     24                        mUpdateTimer.start(); 
    1525                } 
    1626                 
     
    1929                        var prev:GMapViewport = mCurViewport; 
    2030                        mCurViewport = v; 
    21                          
    2231                        if (mCurViewport) 
    2332                        { 
    2433                                if (prev == null) 
    2534                                        refresh(); 
     35                        } 
     36                } 
     37                 
     38                private function onTimer(e:Event):void 
     39                { 
     40                        if (mReqQueue.empty) 
     41                                return; 
     42                                 
     43                        var j:Object = {}; 
     44                        mReqQueue.consume(j); 
     45                        switch(j.v) 
     46                        { 
     47                        case 1: // load 
     48                                checkAndLoad(j.x, j.y); 
     49                                break; 
    2650                        } 
    2751                } 
     
    3458                private function spread(tx:int, ty:int):void 
    3559                { 
    36                         checkAndLoad(tx    , ty - 1); 
    37                         checkAndLoad(tx + 1, ty    ); 
    38                         checkAndLoad(tx    , ty + 1); 
    39                         checkAndLoad(tx - 1, ty    ); 
     60                        addLoadJob(tx    , ty - 1); 
     61                        addLoadJob(tx + 1, ty    ); 
     62                        addLoadJob(tx    , ty + 1); 
     63                        addLoadJob(tx - 1, ty    ); 
    4064                } 
    4165                 
     
    4771                                mListener.loadTile(tx, ty); 
    4872                        } 
     73                } 
     74                 
     75                private function addLoadJob(tx:int, ty:int):void 
     76                { 
     77                        mReqQueue.push(tx, ty, 1); 
    4978                } 
    5079                 
     
    6594class XYQueue 
    6695{ 
    67         private var Xs:Array; 
    68         private var Ys:Array; 
     96        private var Xs:Array = new Array(); 
     97        private var Ys:Array = new Array(); 
     98        private var Vs:Array = new Array(); 
    6999         
    70100        public function consume(out:Object):Boolean 
     
    74104                out.x = Xs.shift(); 
    75105                out.y = Ys.shift(); 
     106                out.v = Vs.shift(); 
    76107                return true; 
    77108        } 
     
    82113        } 
    83114         
    84         public function push(x:int, y:int):void 
     115        public function push(x:int, y:int, v:int):void 
    85116        { 
    86117                Xs.push(x); 
    87118                Ys.push(y); 
     119                Vs.push(v); 
    88120        } 
    89121} 
  • lang/actionscript/swfgmap/trunk/gyuque/gmap/googlemaps/GMapMapLayer.as

    r2456 r2477  
    6666                        mCenterTY = ty; 
    6767                } 
     68                 
     69                public function getCurrentPanning(out:Point):void 
     70                { 
     71                        out.x = x; 
     72                        out.x = y; 
     73                } 
    6874        } 
    6975}