I'm tying to migrate from v2 to v3 and having a little problem
detecting mouse clicks the way I used to.
v2 code (which DID work):
GEvent.addListener(map, "click", function(overlay, point) {
if(!overlay) {
MkAdd("", point.lat(), point.lng()); // xml, lat=X, lng=Y
}
});
v3 code (which DID NOT work):
google.maps.event.addListener(map, "click", function(overlay, event) {
if(!overlay) {
MkAdd("", event.lat(), event.lng()); // xml, lat=X, lng=Y
}
});
While attempting to debug this problem I did this which returned some
crazy wrong latlng's:
google.maps.event.addListener(map, "click", function(event) {
MkAdd("", event.pixel.x, event.pixel.y); // xml, lat=X, lng=Y
});
Eventually here's what DID worked for me.
google.maps.event.addListener(map, "click", function(event) {
MkAdd("", event.latLng.lat().toFixed(11),
event.latLng.lng().toFixed(11));
});
Ultimately what I want to do is be able to click on a map that may
already have marker points on it and add a new marker where no markers
are currently present. If they are then I want either the info window
or to zoom in one lvl in the case of a 'group' marker. I have all
this already working in v2, hopefully I don't have to pull out anymore
hair getting this fully ported to v3.
Either way I hope this can help someone else, gl everyone.
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.