IsMouseOverMarker
property detects clicking on marker just fine, but when trying to use IsMouseOverPolygon
property of GMap
Control to detect if user clicked on polygon line - it doesn't seem to be working.
Note: PolygonEnabled
property of GMap
control is set to True.
The OnPolygonClick
event doesn't even fire:
private void gMap_OnPolygonClick(GMapPolygon item, MouseEventArgs e) {
double pLat = item.From.Value.Lat;
}
Map Click
event does fire, but the 'IsMouseOverPolygon` never gets True value:
private void gMap_Click(object sender, EventArgs e) {
if (gMap.IsMouseOverMarker) {
MessageBox.Show("Clicked on marker and it works!");
}
if (gMap.IsMouseOverPolygon) {
MessageBox.Show("clicked on line - never works");
}
}
I wonder if there is something wrong in a way I'm adding polygons or is it because in my case it's just lines:
GMapOverlay polyOverlay = new GMapOverlay("polygons");
gMap.Overlays.Add(polyOverlay);
List<PointLatLng> points = new List<PointLatLng>();
points.Add(start);
points.Add(end);
polygon = new GMapPolygon(points, "mypolygon");
polygon.Stroke = new Pen(Color.Blue, 5);
polyOverlay.Polygons.Add(polygon);
So, the question is: how should I go about detecting mouse click on those lines?