OpenLayers OpenLayers

Changeset 1585

Show
Ignore:
Timestamp:
10/05/06 02:20:47 (2 years ago)
Author:
euzuro
Message:

fix for #191 - graceful dealing with setCenter() on lonlat out of maxexteng (on first setcenter() call). added test

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Map.js

    r1581 r1585  
    577577    */ 
    578578    setCenter: function (lonlat, zoom, dragging) { 
     579         
     580        if (!this.center && !this.isValidLonLat(lonlat)) { 
     581            lonlat = this.maxExtent.getCenterLonLat(); 
     582        } 
     583         
    579584        var zoomChanged = (this.isValidZoomLevel(zoom)) &&  
    580585                          (zoom != this.getZoom()); 
  • trunk/openlayers/tests/test_Map.html

    r1424 r1585  
    248248    } 
    249249     
     250    function test_088_Map_setCenter(t) { 
     251        t.plan(1); 
     252        map = new OpenLayers.Map($('map')); 
     253        var baseLayer = new OpenLayers.Layer.WMS("Test Layer",  
     254            "http://octo.metacarta.com/cgi-bin/mapserv?", 
     255            {map: "/mapdata/vmap_wms.map", layers: "basic"}, 
     256            {maxResolution: 'auto', maxExtent: new OpenLayers.Bounds(-10,-10,10,10)}); 
     257        map.addLayer(baseLayer); 
     258        var ll = new OpenLayers.LonLat(-100,-150); 
     259        map.setCenter(ll, 0); 
     260        t.ok(map.getCenter().equals(new OpenLayers.LonLat(0,0)), "safely sets out-of-bounds lonlat"); 
     261    } 
     262 
    250263     
    251264    function test_99_Map_destroy (t) {