I created a custom Google map with my own tiles, and I am trying to find the latitude and longitude of points to place markers. I am us开发者_StackOverflow中文版ing Google Maps API v3.
Following the "Event Context V3", I can get the lat/long of the centered position using this script:
google.maps.event.addListener(map, 'dragend', function() {
var center = map.getCenter();
alert(center.toString());
});
How can I do this by just clicking on a part of the map, rather than dragging the map and changing the center?
Doesn't this work:
google.maps.event.addListener(map, 'click', function(event) {
alert(event.latLng);
});
?
精彩评论