I'm trying to get address info when I click somewhere on my gmap.NET like country, city, address... etc. I have searched enough but the only solution that I have found is here Location information where mouse click on the map GMap.net. The code that I'm using is:
private void Form1_Load(object sender, EventArgs e)
{
// Initialize map:
gmap.MapProvider = GMap.NET.MapProviders.GoogleMapProvider.Instance;
GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
gmap.Position = new PointLatLng(37.9667, 23.7167);
gmap.MouseClick += new MouseEventHandler(map_MouseClick);
}
private void map_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e)
{
double lat = 0.0;
double lng= 0.0;
if (e.Button == MouseButtons.Left)
{
lat = gmap.FromLocalToLatLng(e.X, e.Y).Lat;
lng = gmap.FromLocalToLatLng(e.X, e.Y).Lng;
//ajout des overlay
overlayOne = new GMapOverlay(gmap, "OverlayOne");
//ajout de Markers
overlayOne.Markers.Add(new GMap.NET.WindowsForms.Markers.GMapMarkerGoogleGreen(new PointLatLng(lat, lng)));
//ajout de overlay à la map
gmap.Overlays.Add(overlayOne);
List<Placemark> plc = null;
var st = GMapProviders.GoogleMap.GetPlacemarks(new PointLatLng(54.6961334816182, 25.2985095977782), out plc);
if (st == GeoCoderStatusCode.G_GEO_SUCCESS && plc != null)
{
foreach (var pl in plc)
{
if (!string.IsNullOrEmpty(pl.PostalCodeNumber))
{
Debug.WriteLine("Accuracy: " + pl.Accuracy + ", " + pl.Address + ", PostalCodeNumber: " + pl.PostalCodeNumber);
}
}
}
}
}
The error that appeared is The name 'GMapProviders' does not exist in the current context
I'm trying to understand the code but I can't. I'm beginner programmer with c# and when I try to copy/paste the code into my code there is an error in GMapProviders that is in the map_MouseClick method. There is any one can help me or can enplane the code to me. Thanx.