I have an embedded Google map with my web application in ASP.NET 3.5.
I have implemented reverse geocoding (getting address from latitude and longitude) on Map click.
Now, I need the same but on marker click.
How should I code marker click?
I have an embedded Google map with my web application in ASP.NET 3.5.
I have implemented reverse geocoding (getting address from latitude and longitude) on Map click.
Now, I need the same but on marker click.
How should I code marker click?
For each of your markers, add the following event handler for the click event. This assumes you're using the version 2 API.
// pass in a reference to your marker object and
// bind the function to the click event
GEvent.addListener(marker, "click", function() {
// perform your geocoding here
});
You can grab the coordinates of the marker with its getLatLng()
method, which returns a GLatLng
object.
More info can be found here.
You can add a call to your reverse-geocode function within the event listener for the marker's OnClick event.
google.maps.event.addListener(marker, 'click', function() { infowindow.open(map,marker); });
Is a normal thing you might do to have the infowindow open when you click a marker. Add another function() to it.