Posted By

christianjunk on 02/05/11


Tagged

ArcObjects


Versions (?)

Zoom to point


 / Published in: C#
 

URL: http://blog.davidrenz.com/?p=109

This function will zoom to a specific point on the map control. If the addToMap switch is set, the point will be added to the map.

  1. public static void zoomMapToPoint(ESRI.ArcGIS.ADF.Web.UI.WebControls.Map map, ESRI.ArcGIS.ADF.Web.Geometry.Point pPoint, string zoomfactor, string graphicsLayerName, bool addToMap)
  2. {
  3. ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceManager mapman = (ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceManager)map.MapResourceManagerInstance;
  4.  
  5. // convert the point to an adf point
  6. ESRI.ArcGIS.ADF.Web.Geometry.Point adf_point = new ESRI.ArcGIS.ADF.Web.Geometry.Point(pPoint.X, pPoint.Y);
  7.  
  8. //// Get graphics layer from Map
  9. ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer glayer = MapSubs.GetGraphicsLayer(graphicsLayerName, mapman);
  10. //glayer.Clear();
  11.  
  12. // add the point
  13. if (addToMap)
  14. {
  15. AddPointToMap(adf_point, glayer);
  16. }
  17.  
  18. double mapZoomFactor = map.Scale / double.Parse(zoomfactor);
  19. map.Zoom(mapZoomFactor);
  20.  
  21. map.CenterAt(pPoint);
  22. map.Refresh();
  23. }

Report this snippet  

You need to login to post a comment.