private void wpfMap1_MouseMove(object sender, MouseEventArgs e)
        {
            //Gets the PointShape in world coordinates from screen coordinates.
            Point point = e.MouseDevice.GetPosition(null);

            ScreenPointF screenPointF = new ScreenPointF((float)point.X, (float)point.Y);
            PointShape   pointShape   = ExtentHelper.ToWorldCoordinate(wpfMap1.CurrentExtent, screenPointF, (float)wpfMap1.ActualWidth, (float)wpfMap1.ActualHeight);

            //Uses the WrapDatelineProjection to get the proper decimal degree value on the virtual maps to the right and left of the central map.
            WrapDatelineProjection wrapDatelineProjection = new WrapDatelineProjection();

            //Sets the HalfExtentWidth of the wrapdateline overlay we want to apply the projection on.
            //Here it is 180 because, the full extent width is 360.
            wrapDatelineProjection.HalfExtentWidth = wpfMap1.Overlays["WMK"].GetBoundingBox().Width / 2;//180;

            wrapDatelineProjection.Open();
            Vertex projVertex = wrapDatelineProjection.ConvertToExternalProjection(pointShape.X, pointShape.Y);

            wrapDatelineProjection.Close();

            try
            {
                //Shows the real coordinates.
                textBox1.Text = "real X: " + string.Format("{0}", System.Math.Round(pointShape.X)) +
                                "  real Y: " + string.Format("{0}", System.Math.Round(pointShape.Y));
                //Shows the Long Lat after the WrapDatelineProjection
                textBox3.Text = "Long.: " + System.Math.Round(projVertex.X) +
                                "  Lat.: " + System.Math.Round(projVertex.Y);
            }
            catch { }
        }
        private void wpfMap1_MapClick(object sender, MapClickWpfMapEventArgs e)
        {
            try
            {
                //Uses the WrapDatelineProjection to create the target pointshape for GetFeatureNearestTo spatial query function.
                WrapDatelineProjection wrapDatelineProjection = new WrapDatelineProjection();
                //Sets the HalfExtentWidth of the wrapdateline overlay we want to apply the projection on.
                //Here it is 180 because, the full extent width is 360.
                wrapDatelineProjection.HalfExtentWidth = wpfMap1.Overlays["WMK"].GetBoundingBox().Width / 2;//180;

                //Gets the valid world coordinate regardless to where the user click on the map
                wrapDatelineProjection.Open();
                Vertex projVertex = wrapDatelineProjection.ConvertToExternalProjection(e.WorldX, e.WorldY);
                wrapDatelineProjection.Close();

                //Here we just use the feature source of the shapefile because we don't display it, we just use it for doing the spatial query.
                ShapeFileFeatureSource shapeFileFeatureSource = new ShapeFileFeatureSource(@"../../data/countries02.shp");
                shapeFileFeatureSource.Open();
                //Uses the projected X and Y values for the Spatial Query.
                Collection <Feature> features = shapeFileFeatureSource.GetFeaturesNearestTo(new PointShape(projVertex), wpfMap1.MapUnit, 1, ReturningColumnsType.NoColumns);
                shapeFileFeatureSource.Close();

                LayerOverlay         dynamicOverlay       = (LayerOverlay)wpfMap1.Overlays["DynamicOverlay"];
                InMemoryFeatureLayer inMemoryFeatureLayer = (InMemoryFeatureLayer)dynamicOverlay.Layers["SelectLayer"];

                //Clears the InMemoryFeatureLayer and add the feature as the result of the spatial query.
                inMemoryFeatureLayer.Open();
                inMemoryFeatureLayer.InternalFeatures.Clear();
                inMemoryFeatureLayer.InternalFeatures.Add(features[0]);
                inMemoryFeatureLayer.Close();

                //Refreshes only the overlay with the updated InMemoryFeatureLayer.
                wpfMap1.Refresh(dynamicOverlay);
            }
            catch { }
        }