Unfortunately, e.view.zoomLevel only returns the current zoom level.
So if you use an onstartzoom it gives you the current zoom prior to clicking... onendzoom gives you zoom after the click. So it's doesn't tell you which way your going. :(
If we knew the ID of the button zoom element or something maybe we could at something to it...
If you use a cuztom zoom in and zoomout button this isn't a problem and you can get seemless zoom control. That may be what I have to do in my own project.
Max zoom out or zoom in parameters?
h1
N B
Yeah, the zoom control works but only after it's zoomed past a max or min, then zooms back in or out.
Not perfect. If we knew if the user wants to zoom in OR out we could catch it onstartzoom instead of onendzoom.
Thoughts
ski123
If you stored the current zoom as a global varible outside the function then you could compare the new current zoom to work it out.
But I don't think this would make you code any better. Remember there is about 6 ways to zoom in/out:
John.
Th3MachIn3
Kjelle
I don't think you can, but on map change zoom you can try something like:
var currentZoom = map.GetZoomLevel();
if(currentZoom >= 13) {
map.SetZoomLevel(12);
}
if(currentZoom <= 3) {
map.SetZoomLevel(4);
}
Wally9633
Unfortunately, e.view.zoomLevel only returns the current zoom level.
So if you use an onstartzoom it gives you the current zoom prior to clicking... onendzoom gives you zoom after the click. So it's doesn't tell you which way your going. :(
If we knew the ID of the button zoom element or something maybe we could at something to it...
If you use a cuztom zoom in and zoomout button this isn't a problem and you can get seemless zoom control. That may be what I have to do in my own project.
Lewis Yeung
Yeah I think that:
e.view.zoomLevel
In the
onstartzoom event
should return the zoomlevel requested, no the current zoom level. It would make it much more useful.
Maybe something to ask for from the VE team
John.
eg.
<
html xmlns="http://www.w3.org/1999/xhtml"><head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://dev.virtualearth.net/mapcontrol/v4/mapcontrol.js"></script>
<script type="text/javascript">
var map;
function MyOnload()
{
map = new VEMap('mymap');
map.LoadMap();
map.AttachEvent('onclick', myEventTester); //change to your event
map.AttachEvent('onstartzoom', myEventTester); //change to your event
}
function myEventTester(e)
{
var events = "mapstyle: " + e.view.mapStyle;
events +="<br/>latlong: " + e.view.latlong.latitude + ", " + e.view.latlong.longitude;
events +="<br/>LatLong: " + e.view.LatLong;
events +="<br/>zoomLevel: " + e.view.zoomLevel;
events +="<br/>sceneID: " + e.view.sceneId;
events +="<br/>sceneOrientation: " + e.view.sceneOrientation;
document.getElementById('events').innerHTML = events;
}
</script>
</head>
<body onload="MyOnload()">
<div id='mymap' style="position:relative; width:600px; height:400px;"></div>
<div id='events' style="position:relative; width:600px; height:400px;"></div>
</body>
</html>
M_Over