JonnyAJAX


Is there a way to set the max zoom-put or zoom in MAP parameters




Re: Max zoom out or zoom in parameters?

Mo Majad


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);

}






Re: Max zoom out or zoom in parameters?

JonnyAJAX

I think attaching a onzoom event can catch it ... great idea. I'll give it a try and post the code.




Re: Max zoom out or zoom in parameters?

JonnyAJAX

Is there a way to know if the user clicked ZOOM IN as opposed to ZOOM OUT



Re: Max zoom out or zoom in parameters?

JonnyAJAX

Well here's the code: http://viavirtualearth.com/Wiki/min_max_zoom.ashx



Re: Max zoom out or zoom in parameters?

SoulSolutions

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:

  1. mouse wheel
  2. keyboard
  3. dashboard
  4. double click
  5. triggered from another bit of code
  6. Draw the zoom box

John.






Re: Max zoom out or zoom in parameters?

JonnyAJAX

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





Re: Max zoom out or zoom in parameters?

SoulSolutions

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>






Re: Max zoom out or zoom in parameters?

JonnyAJAX

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.