do not cast to LonLat if center is null in Map moveTo

This commit is contained in:
Bart van den Eijnden
2012-03-15 16:53:22 +01:00
parent bb6cf0c2d1
commit a3874b8f97
2 changed files with 22 additions and 1 deletions

View File

@@ -1797,7 +1797,7 @@ OpenLayers.Map = OpenLayers.Class({
* options - {Object}
*/
moveTo: function(lonlat, zoom, options) {
if (!(lonlat instanceof OpenLayers.LonLat)) {
if (lonlat != null && !(lonlat instanceof OpenLayers.LonLat)) {
lonlat = new OpenLayers.LonLat(lonlat);
}
if (!options) {

View File

@@ -2037,6 +2037,27 @@
map.moveTo([16, 48], 0);
t.eq(map.getCenter().toShortString(), "0, 0", "no panning when moveTo is called with invalid zoom");
}
function test_correctCenterAtZoomLevel0(t) {
t.plan(1);
var map = new OpenLayers.Map({
div: 'map',
maxExtent: new OpenLayers.Bounds(-30, 48.00, 3.50, 64.00),
restrictedExtent: new OpenLayers.Bounds(-30, 48.00, 3.50, 64.00),
projection: "EPSG:4258",
units: "degrees",
layers: [
new OpenLayers.Layer('name', {
isBaseLayer: true
})
]
});
map.setCenter(new OpenLayers.LonLat(-1.3, 50.8), 4);
map.moveTo(null, 0);
var center = map.getCenter();
t.ok(center.equals(new OpenLayers.LonLat(-13.25, 56)), "Center is correct and not equal to maxExtent's center");
}
</script>
</head>
<body>