Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add custom marker(square) to Gmap

Tags:

c#

gmap.net

Basically I want to draw a filled square and add it (and use it) as a marker to Gmap. I tried drawing a square and use it as a bitmap but it asks me for the x y coordinates and I don't know what values to put for that because the marker already uses lat/long. I am trying this but the position of the square is not right.I want to square to appear on the specified lat/long.

Bitmap flag = new Bitmap(50, 50);
gmap.MapProvider = GMap.NET.MapProviders.BingHybridMapProvider.Instance;
GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
Graphics fg = Graphics.FromImage(flag);
fg.FillRectangle(Brushes.Red, 100, 100, 50, 50);
GMapOverlay markerOverlay = new GMapOverlay(NametextBox.Text);
GMarkerGoogle marker = new GMarkerGoogle(new PointLatLng(-25.966688, 32.580528),flag);
markerOverlay.Markers.Add(marker);
gmap.Overlays.Add(markerOverlay);
like image 560
Vaibhav Pandya Avatar asked Sep 16 '25 00:09

Vaibhav Pandya


1 Answers

To draw a filled square you follow following steps:

  1. Right click on project settings.
  2. Go to resources > add resource > new image.
  3. Double click on new created image.
  4. A blank page opens. Draw whatever you like and save it.

For plotting I used the following example:

GMapMarker marker = new GMarkerGoogle(new PointLatLng(-25.966688, 32.580528), new Bitmap(Properties.Resources.image8));
gmap.Overlays.Add(markers);   // overlay added
markers.Markers.Add(marker);

Hope this works for you.

like image 130
pranjal khanduri Avatar answered Sep 17 '25 15:09

pranjal khanduri