Changeset 75

Show
Ignore:
Timestamp:
01/23/07 23:42:24 (2 years ago)
Author:
migurski
Message:

Delayed tile grid tile placement until a single frame has elapsed, and moved scroll/zoom limits over to map provider where they belog

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/as2/lib/com/modestmaps/core/TileGrid.as

    r69 r75  
    6666        buildWell(); 
    6767        buildMask(); 
    68          
     68        redraw();    
     69         
     70                Reactor.callNextFrame(Delegate.create(this, this.initializeTiles)); 
     71    } 
     72     
     73   /** 
     74    * Create the first tiles. 
     75    */ 
     76    private function initializeTiles():Void 
     77    { 
    6978        // impose some limits 
    7079        zoomLevel = 11; 
    71         topLeftOutLimit = new Coordinate(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY, 0)
    72         bottomRightInLimit = new Coordinate(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, Coordinate.MAX_ZOOM)
     80        topLeftOutLimit = mapProvider.outerLimits()[0]
     81        bottomRightInLimit = mapProvider.outerLimits()[1]
    7382         
    7483        // initial tile centers the map on the SF Bay Area 
     
    9099        tileBuffer = Math.max(0, tileBuffer); 
    91100         
     101        centerWell(false); 
    92102        allocateTiles(); 
    93         redraw();    
     103        positionTiles(); 
    94104         
    95105        labelContainer.swapDepths( getNextHighestDepth() );     
     
    352362    public function zoomIn(amount:Number):Void 
    353363    { 
     364        if(!tiles) 
     365            return; 
     366         
    354367        if(zoomLevel >= bottomRightInLimit.zoom && Math.round(well._xscale) >= 100) 
    355368            return; 
     
    367380    public function zoomOut(amount:Number):Void 
    368381    { 
     382        if(!tiles) 
     383            return; 
     384         
    369385        if(zoomLevel <= topLeftOutLimit.zoom && Math.round(well._xscale) <= 100) 
    370386            return; 
     
    382398    public function resizeTo(bottomLeft:Point):Void 
    383399    { 
     400        if(!tiles) 
     401            return; 
     402         
    384403        width = bottomLeft.x; 
    385404        height = bottomLeft.y; 
     
    393412    public function panRight(pixels:Number):Void 
    394413    { 
     414        if(!tiles) 
     415            return; 
     416         
    395417        well._x -= pixels; 
    396418        positionTiles(); 
     
    400422    public function panLeft(pixels:Number):Void 
    401423    { 
     424        if(!tiles) 
     425            return; 
     426         
    402427        well._x += pixels; 
    403428        positionTiles(); 
     
    407432    public function panUp(pixels:Number):Void 
    408433    { 
     434        if(!tiles) 
     435            return; 
     436         
    409437        well._y += pixels; 
    410438        positionTiles(); 
     
    414442    public function panDown(pixels:Number):Void 
    415443    { 
     444        if(!tiles) 
     445            return; 
     446         
    416447        well._y -= pixels; 
    417448        positionTiles(); 
     
    433464    private function allocateTiles():Void 
    434465    { 
     466        if(!tiles) 
     467            return; 
     468         
    435469        // internal pixel dimensions of well, compensating for scale 
    436470        var wellWidth:Number  = (100 / well._xscale) * width; 
     
    474508    private function centerWell(adjustTiles:Boolean):Void 
    475509    { 
     510        if(!tiles) 
     511            return; 
     512         
    476513        var center:Point = new Point((width/2), (height/2)); 
    477514         
     
    497534    private function normalizeWell():Void 
    498535    { 
     536        if(!tiles) 
     537            return; 
     538         
    499539        var zoomAdjust:Number, scaleAdjust:Number; 
    500540         
     
    662702    private function positionTiles():Void 
    663703    { 
     704        if(!tiles) 
     705            return; 
     706         
    664707        var tile:Tile; 
    665708        var point:Point; 
  • trunk/as2/lib/com/modestmaps/geo/Map.as

    r69 r75  
    8181    public function zoomIn():Void 
    8282    { 
    83         grid.zoomIn(0.25); 
     83        grid.zoomIn(1); 
    8484    } 
    8585     
    8686    public function zoomOut():Void 
    8787    { 
    88         grid.zoomOut(0.25); 
     88        grid.zoomOut(1); 
    8989    } 
    9090} 
  • trunk/as2/lib/com/modestmaps/mapproviders/AbstractMapProvider.as

    r74 r75  
    2121        private var __requestThrottler : RequestThrottler; 
    2222        private var __projection:IProjection; 
     23         
     24        // boundaries for the current provider 
     25        private var __topLeftOutLimit:Coordinate; 
     26        private var __bottomRightInLimit:Coordinate; 
    2327 
    2428        // tracks if we're set up to broadcast events 
     
    4145            var t:Transformation = new Transformation(1, 0, 0, 0, 1, 0); 
    4246        __projection = new LinearProjection(Coordinate.MAX_ZOOM, t); 
     47 
     48        __topLeftOutLimit = new Coordinate(0, 0, 0); 
     49        __bottomRightInLimit = (new Coordinate(1, 1, 0)).zoomTo(Coordinate.MAX_ZOOM); 
    4350        } 
    4451 
     
    5562        return __projection.toString(); 
    5663        } 
     64 
     65   /* 
     66    * Get top left outer-zoom limit and bottom right inner-zoom limits, 
     67    * as Coordinates in a two element array. 
     68    */ 
     69    public function outerLimits():/*Coordinate*/Array 
     70    { 
     71        var limits:/*Coordinate*/Array = []; 
     72 
     73        limits[0] = __topLeftOutLimit.copy(); 
     74        limits[1] = __bottomRightInLimit.copy(); 
     75 
     76        return limits; 
     77    } 
    5778 
    5879        public function createLabel( clip : MovieClip, label : String ) : Void 
  • trunk/as2/lib/com/modestmaps/mapproviders/IMapProvider.as

    r69 r75  
    1818    */ 
    1919    public function coordinateLocation(coordinate:Coordinate):Location; 
     20 
     21   /* 
     22    * Get top left outer-zoom limit and bottom right inner-zoom limits, 
     23    * as Coordinates in a two element array. 
     24    */ 
     25    public function outerLimits():/*Coordinate*/Array; 
    2026} 
  • trunk/as2/lib/com/modestmaps/mapproviders/microsoft/AbstractMicrosoftMapProvider.as

    r70 r75  
    2525                                                           
    2626        __projection = new MercatorProjection(26, t); 
     27 
     28        __topLeftOutLimit = new Coordinate(0, Number.NEGATIVE_INFINITY, 0); 
     29        __bottomRightInLimit = (new Coordinate(1, Number.POSITIVE_INFINITY, 0)).zoomTo(Coordinate.MAX_ZOOM); 
    2730        } 
    2831