Allow use of array for bounds.

This commit is contained in:
tschaub
2011-10-26 15:40:40 -06:00
parent 75a1a8e119
commit 98ee7167c4
4 changed files with 52 additions and 3 deletions

View File

@@ -38,8 +38,10 @@
}
function test_Map_constructor_convenience(t) {
t.plan(3);
t.plan(13);
var map = new OpenLayers.Map({
maxExtent: [-170, -80, 170, 80],
restrictedExtent: [-120, -65, 120, 65],
layers: [
new OpenLayers.Layer(null, {isBaseLayer: true})
],
@@ -47,6 +49,20 @@
zoom: 3
});
// maxExtent from array
t.ok(map.maxExtent instanceof OpenLayers.Bounds, "maxExtent bounds");
t.eq(map.maxExtent.left, -170, "maxExtent left");
t.eq(map.maxExtent.bottom, -80, "maxExtent bottom");
t.eq(map.maxExtent.right, 170, "maxExtent right");
t.eq(map.maxExtent.top, 80, "maxExtent top");
// restrictedExtent from array
t.ok(map.restrictedExtent instanceof OpenLayers.Bounds, "restrictedExtent bounds");
t.eq(map.restrictedExtent.left, -120, "restrictedExtent left");
t.eq(map.restrictedExtent.bottom, -65, "restrictedExtent bottom");
t.eq(map.restrictedExtent.right, 120, "restrictedExtent right");
t.eq(map.restrictedExtent.top, 65, "restrictedExtent top");
var center = map.getCenter();
t.eq(center.lon, -111, "center lon");
t.eq(center.lat, 45, "center lat");
@@ -1412,7 +1428,7 @@
}
function test_Map_zoomToExtent(t) {
t.plan(9);
t.plan(12);
var map = new OpenLayers.Map("map");
var layer = new OpenLayers.Layer(null, {isBaseLayer: true});
@@ -1441,6 +1457,13 @@
t.eq(center.lon, -105, "c) correct x");
t.eq(center.lat, 42, "c) correct y");
t.eq(map.getZoom(), 3, "c) correct zoom");
// accept array
map.zoomToExtent([-160, 15, -50, 69]);
center = map.getCenter();
t.eq(center.lon, -105, "(array) correct x");
t.eq(center.lat, 42, "(array) correct y");
t.eq(map.getZoom(), 2, "(array) correct zoom");
map.destroy();
}