arcgis for silverlight 鼠标点击地图获取当前经纬度
silverlight代码:
地图的name值是myMap。后台在页面初始化的时候,添加地图的点击事件
myMap.MouseClick+=new EventHandler<Map.MouseEventArgs>(myMap_MouseClick);
#region /////////////////////////////////////////////////地图事件 和 坐标 private void myMap_MouseClick(object sender, Map.MouseEventArgs e) { //MapPoint p = e.MapPoint;//当前获取到的点,坐标系是墨卡托的 ESRI.ArcGIS.Client.Projection.WebMercator _mercator = new ESRI.ArcGIS.Client.Projection.WebMercator();//墨卡托类 MapPoint mapPoint = _mercator.ToGeographic(e.MapPoint) as MapPoint; txtCoord.Text = mapPoint.X + "," + mapPoint.Y; //MessageBox.Show("经度:"+mapPoint.X+"纬度:"+mapPoint.Y); } //复制坐标按钮事件 private void btnCopy_Click(object sender, RoutedEventArgs e) { string coord = txtCoord.Text.Trim(); //HtmlPage.Window.Invoke("Copy", coord); Clipboard.SetText(coord); MessageBox.Show("复制成功"); } #endregion