locked
How to calculate the zoom level if i have arrays of lattitude and longitude? RRS feed

  • Question

  • Hi,

    I need to calculate the zoom level dynamically so that all pushpins appear in the visibility of the map. I have arrays of latitude and longitude which can be treated as inputs to caluculate the zoom level dynamically.

    If anyone has already written a method to achive this, please do share the same with me so that it can be helpful to me.

    Thanks in advance,

     

    Monday, January 15, 2007 5:40 AM

Answers

  • Its strangly named but it is called SetMapView() and takes an array of VELatLong so I think you are set.

    John.

          <script>
             var map = null;
            
             function GetMap()
             {
                map = new VEMap('myMap');
                map.LoadMap();
               
                var pinid=0;
                var locs = new Array;
                   var loc = new VELatLong(40, -123);
                   locs.push(loc);
                   var loc = new VELatLong(42, -122);
                   locs.push(loc);
                   var loc = new VELatLong(44, -118);
                   locs.push(loc);
                   var loc = new VELatLong(46, -118);
                   locs.push(loc);
                  
                for (i=0; i < locs.length; i++)
                {
                   var pin = new VEPushpin(pinid, locsIdea, null, 'A point', 'location number '+i);
                   map.AddPushpin(pin);
                   pinid++;
                }
               
                DoBestMap(locs);
             }  
             function DoBestMap(locs)
             {
                map.SetMapView(locs);
             }
          </script>

    Monday, January 15, 2007 5:54 AM
    Moderator

All replies

  • Its strangly named but it is called SetMapView() and takes an array of VELatLong so I think you are set.

    John.

          <script>
             var map = null;
            
             function GetMap()
             {
                map = new VEMap('myMap');
                map.LoadMap();
               
                var pinid=0;
                var locs = new Array;
                   var loc = new VELatLong(40, -123);
                   locs.push(loc);
                   var loc = new VELatLong(42, -122);
                   locs.push(loc);
                   var loc = new VELatLong(44, -118);
                   locs.push(loc);
                   var loc = new VELatLong(46, -118);
                   locs.push(loc);
                  
                for (i=0; i < locs.length; i++)
                {
                   var pin = new VEPushpin(pinid, locsIdea, null, 'A point', 'location number '+i);
                   map.AddPushpin(pin);
                   pinid++;
                }
               
                DoBestMap(locs);
             }  
             function DoBestMap(locs)
             {
                map.SetMapView(locs);
             }
          </script>

    Monday, January 15, 2007 5:54 AM
    Moderator
  • Hi John,

    It was a great answer!!

    It really helped me and its working in my site now-:)

    thanks a lot again!!

    Monday, January 15, 2007 7:09 AM