fixing getOLZoomFromMapObjectZoom so it also works when the layer is not the baseLayer. r=bartvde,tschaub (see #3342)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@12105 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -82,6 +82,34 @@
|
||||
t.eq( layer.resolutions[i], resolutions[i + minZoomLevel], "resolutions array at index " + i + " ok");
|
||||
}
|
||||
}
|
||||
|
||||
function test_getMapObjectZoomFromOLZoom(t) {
|
||||
t.plan(4);
|
||||
|
||||
var map = new OpenLayers.Map("map", {allOverlays: true});
|
||||
var xyz = new OpenLayers.Layer.XYZ("xyz", "${x}${y}${z}", {
|
||||
sphericalMercator: true,
|
||||
resolutions: [39135.7584765625, 19567.87923828125, 9783.939619140625]
|
||||
});
|
||||
var fixed = new (OpenLayers.Class(OpenLayers.Layer, OpenLayers.Layer.FixedZoomLevels, {
|
||||
initialize: function() {
|
||||
OpenLayers.Layer.prototype.initialize.apply(this, arguments);
|
||||
}
|
||||
}))("fixed", {
|
||||
resolutions: [156543.03390625, 78271.516953125, 39135.7584765625, 19567.87923828125, 9783.939619140625],
|
||||
minZoomLevel: 1
|
||||
});
|
||||
map.addLayers([xyz, fixed]);
|
||||
map.setCenter(new OpenLayers.LonLat(0, 0), 2);
|
||||
// map.getZoom() returns 2
|
||||
t.eq(fixed.getMapObjectZoomFromOLZoom(map.getZoom()), 4, "correct return value from getMapObjectZoomFromOLZoom");
|
||||
t.eq(fixed.getOLZoomFromMapObjectZoom(4), map.getZoom() - fixed.minZoomLevel, "correct return value from getOLZoomFromMapObjectZoom");
|
||||
|
||||
map.setBaseLayer(fixed);
|
||||
// map.getZoom() returns 4 now
|
||||
t.eq(fixed.getMapObjectZoomFromOLZoom(map.getZoom()), 5, "correct return value from getMapObjectZoomFromOLZoom");
|
||||
t.eq(fixed.getOLZoomFromMapObjectZoom(5), map.getZoom(), "correct return value from getOLZoomFromMapObjectZoom");
|
||||
}
|
||||
|
||||
function p_createLayer(layer, mapOptions, layerOptions) {
|
||||
|
||||
@@ -104,6 +132,6 @@
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map"></div>
|
||||
<div id="map" style="width:256px;height:256px"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user