fix for #191 - graceful dealing with setCenter() on lonlat out of maxexteng (on first setcenter() call). added test
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1585 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -576,6 +576,11 @@ OpenLayers.Map.prototype = {
|
||||
* trigger movestart/end events
|
||||
*/
|
||||
setCenter: function (lonlat, zoom, dragging) {
|
||||
|
||||
if (!this.center && !this.isValidLonLat(lonlat)) {
|
||||
lonlat = this.maxExtent.getCenterLonLat();
|
||||
}
|
||||
|
||||
var zoomChanged = (this.isValidZoomLevel(zoom)) &&
|
||||
(zoom != this.getZoom());
|
||||
|
||||
|
||||
@@ -247,6 +247,19 @@
|
||||
|
||||
}
|
||||
|
||||
function test_088_Map_setCenter(t) {
|
||||
t.plan(1);
|
||||
map = new OpenLayers.Map($('map'));
|
||||
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
|
||||
"http://octo.metacarta.com/cgi-bin/mapserv?",
|
||||
{map: "/mapdata/vmap_wms.map", layers: "basic"},
|
||||
{maxResolution: 'auto', maxExtent: new OpenLayers.Bounds(-10,-10,10,10)});
|
||||
map.addLayer(baseLayer);
|
||||
var ll = new OpenLayers.LonLat(-100,-150);
|
||||
map.setCenter(ll, 0);
|
||||
t.ok(map.getCenter().equals(new OpenLayers.LonLat(0,0)), "safely sets out-of-bounds lonlat");
|
||||
}
|
||||
|
||||
|
||||
function test_99_Map_destroy (t) {
|
||||
t.plan( 2 );
|
||||
|
||||
Reference in New Issue
Block a user