Point clickPoint = e.GetPosition(mapControl);
            PointLatLng point = mapControl.FromLocalToLatLng((int)clickPoint.X, (int)clickPoint.Y);

            foreach(GMapMarker marker in mapControl.Markers)
            {
                GPoint markerPoint = mapControl.FromLatLngToLocal(marker.Position);

                double deltaX = 0, deltaY = 0;

                if(marker.Shape != null)
                {
                    if(marker.Shape is Ellipse)
                    {
                        Ellipse ee = (Ellipse)marker.Shape;
                        deltaX = ee.Width;
                        deltaY = ee.Height;
                    } else  if (marker.Shape is Image)
                    {
                        Image ee = (Image)marker.Shape;
                        deltaX = ee.Width;
                        deltaY = ee.Height;
                    }
                }
                if(clickPoint.X - markerPoint.X > 0 && clickPoint.X - markerPoint.X < deltaX)
                {
                    if (clickPoint.Y - markerPoint.Y > 0 && clickPoint.Y - markerPoint.Y < deltaY)
                    {
                        MessageBoxResult result = MessageBox.Show("确认删除,请选确认\n\r取消删除,请选取消", "是否删除标记吗?", MessageBoxButton.YesNo, MessageBoxImage.Question);
                        if(result == MessageBoxResult.Yes)
                        {
                            marker.Shape = null;
                        }

                        break;
                    }
                }
            }

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注