dnennis
dnennis

Reputation: 140

Where To Insert New Polygon Points?

I'm using a polygon in a GMap.NET project. Creating the polygon was easy but I cannot figure out where to insert a new set of points (a marker used to drag and reshape the polygon).

The new marker has to go between two other existing markers where the user clicked the mouse.

How do I find the two markers between the clicked location please?

[EDIT] code as requested:

private void gMapControl1OnPolygonClick(GMapPolygon item, MouseEventArgs e)
{
    if (item is GMapPolygon && e.Button == System.Windows.Forms.MouseButtons.Right)
    {
        GMapPolygon gpl = item as GMapPolygon;

        Bitmap bmp = Resources.ResourceManager.GetObject("gold_tristar", Resources.Culture) as Bitmap;

        PointLatLng T = gMapControl1.FromLocalToLatLng(e.X, e.Y);
        polyOverlay1.Markers.Add(new MyMarkerGoogle(new PointLatLng(T.Lat, T.Lng), bmp));
        polyOverlay1.Markers[polyOverlay1.Markers.Count - 1].Tag = polyOverlay1.Markers.Count - 1;

        gpl.Points.Add(T);

        gMapControl1.UpdatePolygonLocalPosition(polygon);
    }
}

Upvotes: 0

Views: 751

Answers (1)

Teyam
Teyam

Reputation: 8082

Going through this tutorial - GMAP.NET TUTORIAL – MAPS, MARKERS AND POLYGONS will be very beneficial. It explains how to place a map control on a form, how to initialize it to show the coordinates you want, how to add markers to it, and how to add polygons.

You may also find additional information and more sample codes on how to implement the polygons's editable property and set the draggable property in Add a polygon.

Upvotes: 1

Related Questions