<esri:Map x:Name="myMap" ExtentChanged="myMap_ExtentChanged" WrapAround="True" IsLogoVisible="False" Extent="117.112306799734,29.3397854999517,118.981519200236,30.5753385000024" MouseMove="myMap_MouseMove"> <esri:Map.Layers> <esri:ArcGISDynamicMapServiceLayer ID="MyLayer" Url="http://192.168.0.89/arcgis/rest/services/HSDynamic/MapServer/"/> </esri:Map.Layers> </esri:Map> #region 处理鼠标在地图上移动时,显示地理坐标 private void myMap_MouseMove(object sender, System.Windows.Input.MouseEventArgs args) { if (myMap.Extent != null) { System.Windows.Point screenPoint = args.GetPosition(myMap); ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint = myMap.ScreenToMap(screenPoint); if (myMap.WrapAroundIsActive) mapPoint = ESRI.ArcGIS.Client.Geometry.Geometry.NormalizeCentralMeridian(mapPoint) as ESRI.ArcGIS.Client.Geometry.MapPoint; MapCoordsTextBlock.Text = string.Format("X = {0} , Y = {1}", Math.Round(mapPoint.X, 4), Math.Round(mapPoint.Y, 4)); } } #endregion
效果如下图: