ThinkGeo.com    |     Documentation    |     Premium Support

Auto Zoom to marker/point

Is it possible to automatically zoom to an existing marker or group of markers?



Ivan, 
  
 There is a way to do this with a little looping.  I will write a sample tomorrow and post it.  You gave us a good idea because the way I will show you could be wrapped into an API that we can expose to make it easier for you. 
  
 David

Ivan, 
  
   Below is a private method that allows you to pass in markers and it will zoom to them.  We are also adding this method to our map control in the next public beta but for the interim you can use this code. 
  
         private void ZoomToMarkers(Collection<Marker> markers) 
         { 
             RectangleShape extent = null; 
  
             foreach (Marker marker in markers) 
             { 
                 if (extent == null) 
                 { 
                     extent = new RectangleShape(marker.Position.X - 0.00001, marker.Position.Y + 0.00001, marker.Position.X + 0.00001, marker.Position.Y - 0.00001); 
                 } 
                 else 
                 { 
                     extent.ExpandToInclude(marker.Position); 
                 } 
             } 
  
             if (extent != null) 
             { 
                 Map1.CurrentExtent = extent; 
             } 
         } 
  
 David