开发者

Reverse geocoding on 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.

开发者_如何学GoHow 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.


You can use de event dragend.

GEvent.addListener(marker, "dragend", function() {        
    // perform your geocoding here
});

It just works :D

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜