locked
Show only tiles from a certain region/country. RRS feed

  • Question

  • Hi all,

    Can anyone tell me if it's possible to show tiles from a certain country/region only? I'm looking at Ireland in particular.

    Thanks
    Denis
    Thursday, November 27, 2008 4:25 PM

Answers

  • This has been asked for a few times, unfortunately I can't find the posts. Using the standard control it's not possible to only show the tiles for a specific area, however it is possible to restrict the map view to a particular area. The following code restricts the view over Illinois. To use it else where you just need to modify the bounding coordinates:

    <html> 
      <head> 
        <title>My Virtual Earth</title> 
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
    <script src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6"></script> 
    <script> 
     var map = null
        var mapView; 
     function OnPageLoad() 
     { 
      map = new VEMap('myMap'); 
      map.LoadMap(new VELatLong(39.82411792224589,-89.6759033203125),7); 
       
      map.AttachEvent("onstartpan", onstartpan); 
      map.AttachEvent("onendzoom", OnEndZoom); 
      map.AttachEvent("onendpan", onendpan); 
     } 
     
     function onstartpan(e) 
     { 
      mapView = map.GetMapView();   
     } 
      
     function onendpan(e) 
     { 
       var v = map.GetMapView();   
          var tl = v.TopLeftLatLong; 
          var br = v.BottomRightLatLong; 
          var topLat = tl.Latitude; 
          var leftLong =  tl.Longitude; 
       var bottomLat = br.Latitude; 
          var rightLong =  br.Longitude; 
     
       if(topLat>=42.551879696629214||leftLong<=-91.58203125||bottomLat<=37.00128704482802||rightLong>=-86.934814453125) 
        map.SetMapView(mapView); 
     } 
      
     function OnEndZoom(e) 
     { 
      var zoom = map.GetZoomLevel(); 
       
      if(zoom<=7) 
       map.SetZoomLevel(7); 
     } 
    </script> 
      </head> 
      <body onload="OnPageLoad();"
        <div id="myMap" style="position:relative;width:400px;height:650px;"></div> 
      </body> 
    </html> 

    • Marked as answer by Denis_dh Friday, November 28, 2008 9:12 AM
    Friday, November 28, 2008 2:59 AM
    Moderator

All replies

  • This has been asked for a few times, unfortunately I can't find the posts. Using the standard control it's not possible to only show the tiles for a specific area, however it is possible to restrict the map view to a particular area. The following code restricts the view over Illinois. To use it else where you just need to modify the bounding coordinates:

    <html> 
      <head> 
        <title>My Virtual Earth</title> 
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
    <script src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6"></script> 
    <script> 
     var map = null
        var mapView; 
     function OnPageLoad() 
     { 
      map = new VEMap('myMap'); 
      map.LoadMap(new VELatLong(39.82411792224589,-89.6759033203125),7); 
       
      map.AttachEvent("onstartpan", onstartpan); 
      map.AttachEvent("onendzoom", OnEndZoom); 
      map.AttachEvent("onendpan", onendpan); 
     } 
     
     function onstartpan(e) 
     { 
      mapView = map.GetMapView();   
     } 
      
     function onendpan(e) 
     { 
       var v = map.GetMapView();   
          var tl = v.TopLeftLatLong; 
          var br = v.BottomRightLatLong; 
          var topLat = tl.Latitude; 
          var leftLong =  tl.Longitude; 
       var bottomLat = br.Latitude; 
          var rightLong =  br.Longitude; 
     
       if(topLat>=42.551879696629214||leftLong<=-91.58203125||bottomLat<=37.00128704482802||rightLong>=-86.934814453125) 
        map.SetMapView(mapView); 
     } 
      
     function OnEndZoom(e) 
     { 
      var zoom = map.GetZoomLevel(); 
       
      if(zoom<=7) 
       map.SetZoomLevel(7); 
     } 
    </script> 
      </head> 
      <body onload="OnPageLoad();"
        <div id="myMap" style="position:relative;width:400px;height:650px;"></div> 
      </body> 
    </html> 

    • Marked as answer by Denis_dh Friday, November 28, 2008 9:12 AM
    Friday, November 28, 2008 2:59 AM
    Moderator
  • Thanks for that. You mention using the standard controls. Is there something outside of the standard controls?

    Regards,
    Denis
    Friday, November 28, 2008 9:13 AM