Have NavigationHistory control deal with reprojection, r=ahocevar (closes #1997)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@10261 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
bartvde
2010-04-30 14:52:38 +00:00
parent 0bb5ab8191
commit dc4d5036e4
2 changed files with 61 additions and 3 deletions

View File

@@ -195,6 +195,48 @@
control.destroy();
}
function test_reprojection(t) {
t.plan(2);
var map = new OpenLayers.Map("map");
var layer = new OpenLayers.Layer(
"test", {isBaseLayer: true}
);
map.addLayer(layer);
map.zoomToMaxExtent();
var control = new OpenLayers.Control.NavigationHistory();
map.addControl(control);
map.zoomTo(4);
var bounds = map.getExtent().clone();
var expected = bounds.transform(new OpenLayers.Projection('EPSG:4326'),
new OpenLayers.Projection('EPSG:900913'));
// change the projection to EPSG:900913
var projSettings = {
units: "m",
maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508),
maxResolution: 156543.0339
};
map.setOptions(projSettings);
map.projection = 'EPSG:900913';
delete projSettings.maxResolution;
projSettings.projection = new OpenLayers.Projection('EPSG:900913');
layer.addOptions(projSettings);
layer.initResolutions();
map.zoomTo(7);
// go back one in the history
control.previous.trigger();
t.eq(map.getExtent().left.toFixed(3), expected.left.toFixed(3), "The extent [left] is reprojected correctly");
t.eq(map.getExtent().right.toFixed(3), expected.right.toFixed(3), "The extent [right] is reprojected correctly");
// top and bottom cannot be checked here since in EPSG:900913 the extent is not a rectangle so they are adjusted.
control.destroy();
}
</script>
</head>
<body>