Min and Max Zoom LevelsIf you want to only allow a user to see a certain zoom level (without using a "fixed" map) or only between a range of zoom levels, you can do so by attaching an "onendzoom" event when you load the map.
Usage:
map = new VEMap('myMap');
map.LoadMap();
map.AttachEvent('onendzoom', function(obj) { zoomControl(obj); });
Code:
zoomMax = 19;
zoomMin = 0;
function zoomControl( obj ) {
var currentZoom = obj.view.zoomLevel;
if(currentZoom > zoomMax) {
map.SetZoomLevel(zoomMax);
} else if(currentZoom < zoomMin) {
map.SetZoomLevel(zoomMin);
}
}
Enhancements: Is there a way to know if the user clicked ZOOM IN as opposed to ZOOM OUT?
JonnyAJAX
--> Jonny, you could get5 the current zoom level before the zoom, and then get the zoom level after the zoom. Calculate whether the zoom has increased or decrease, and there is your answer.
This doesnt work - you get this error:
"obj.view has no properties"
line referenced:
var currentZoom = obj.view.zoomLevel;
get rid of the ".view" and it seems to work.