MetalGod01


After I map an address, how can I find out what the maximum zoom level is available (that is, the maximum I can zoom into without the "missing tiles")

Thanks!




Re: How to find the maximum zoom available?

SoulSolutions


That's a tough one, ideally we need the VE API to tell us but currently it doesn't.

I have played with trying to detect the tile image itself with mixed results, i wouldn't use it in a commercial site but if you're interested:

<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 = null;
         var VEnoimagesize = -1;
         var VETilePath = "tiles.virtualearth";
        
         function GetMap()
         {
            map = new VEMap('myMap');
            map.LoadMap(new VELatLong(-27.5, 137), 4 ,'h' ,false);
            map.AttachEvent("onchangeview", CheckZoomLevel);
         } 
         function CheckZoomLevel()
         {
            setTimeout("DelayedCheckZoomLevel()",1000);
         }
         function DelayedCheckZoomLevel()
         {
            if (map.GetMapStyle() != VEMapStyle.Road)
            {
              var y = document.images;
             var imglength = 0;
             for (i=0;i<y.length;i++)
             {
              if (y[ i].fileSize==VEnoimagesize && y[ i].src.indexOf(VETilePath) > 0)
              {
                  //Change to Road view
                  map.SetMapStyle(VEMapStyle.Road);
                 
                  //Or you could zoom out
                  //map.SetZoomLevel(13);
                  break;
              }
             }
         }
         }
      </script>
   </head>
   <body onload="GetMap();">
      <div id='myMap' style="position:relative; width:400px; height:400px;"></div>
   </body>
</html>  

John.







Re: How to find the maximum zoom available?

Derek Chan

As a reference, the maximum zoom level is 19, at the moment I'm trying to figure out the function that determines what the max zoom level is depending on where you are

Msn.VE.MapControl=function(p_elSource,p_htParams,p_parentAPIControl){var offsetMeters=20971520,baseMetersPerPixel=163840,buffer=0,animatedMovementEnabled=true,zoomTotalSteps=6,keyboardPanSpeed=15,panToLatLongSpeed=15,earthRadius=6378137,earthCircumference=earthRadius*2*Math.PI,projectionOffset=earthCircumference*0.5,minZoom=1,maxZoom=19,,emptyTile="http://virtualearth.msn.com/i/spacer.gif"...





Re: How to find the maximum zoom available?

MetalGod01

Derek,

But level 19 is not available in all areas. After I map an address, I need to zoom to the highest level available for _that area_, which may not be level 19.

Dave





Re: How to find the maximum zoom available?

Derek Chan

Okay, I've looked into the API and figured out how to get the current max zoom level.

map.vemapcontrol.GetCurrentViewMaxZoomLevel();

I've posted this on the wiki for further reference.




Re: How to find the maximum zoom available?

SoulSolutions

Yeah that works for road view but what people are really looking for is for aerial and hybrid mode. You should get zoomlevel 13 for most of the world, better in cities.

John.






Re: How to find the maximum zoom available?

Derek Chan

Thanks for the update John.  I've looked through the API and found that there are only two methods in relation to determining max zoom level:

 map.vemapcontrol.GetCurrentViewMaxZoomLevel();
 map.vemapcontrol.GetMaxTileZoom();

Both of these are not in relation to the "no image" photo that you get in aerial/hybrid which leads me to believe that the tile server is managing what images are getting displayed and not the API control