double last_lat;
double last_lng;
int indicator = 0;
private void map_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
double lat = map.FromLocalToLatLng(e.X, e.Y).Lat;
double lng = map.FromLocalToLatLng(e.X, e.Y).Lng;
if (last_lat != lat || last_lng != lng)
{
if (indicator == 0)
{
GMapOverlay markersOverlay = new GMapOverlay(map, "marker");
GMapMarkerGoogleRed marker = new GMapMarkerGoogleRed(new PointLatLng(lat, lng));
markersOverlay.Markers.Add(marker);
map.Overlays.Add(markersOverlay);
last_lat = lat;
last_lng = lng;
indicator = 1;
//MessageBox.Show("kina unhan!");
}
else
{
//MessageBox.Show(Convert.ToString(last_lat),"Last Lat");
//MessageBox.Show(Convert.ToString(last_lng), "Last Lng");
GMapOverlay markersOverlay = new GMapOverlay(map, "marker");
GMapMarkerGoogleRed marker = new GMapMarkerGoogleRed(new PointLatLng(last_lat, last_lng));
markersOverlay.Markers.Remove(marker);
map.Overlays.Remove(markersOverlay);
map.Refresh();
//GMapOverlay markersOverlay2 = new GMapOverlay(map, "marker");
//GMapMarkerGoogleRed marker2 = new GMapMarkerGoogleRed(new PointLatLng(lat, lng));
//markersOverlay.Markers.Add(marker2);
//map.Overlays.Add(markersOverlay2);
//MessageBox.Show("sunod");
}
}
}
}
问问题
2208 次