I have a set of draggable markers on a map. Getting the coordinate
information is no issue, but I'd like to have the coordinate location
update in the infowindow in real time.
Is there a way to do this without creating multiple InfoWindows?
My current solution is to implement a drag listener for the marker and
create a new InfoWindow object when the event fires. Needless to say, this
is very inefficient.
//anonymous function for event listeners
(function(newMarker){
google.maps.event.addListener(newMarker, "click", function(){
infowindow = new google.maps.InfoWindow({
content: infoWindowData(newMarker, newMarker.title)
});
infowindow.open(map, newMarker)
});
google.maps.event.addListener(newMarker, 'dragend', function(){
//log.info(newMarker.getPosition());
console.log(newMarker.getPosition());
newMarker.animation;
currentMarker = newMarker;
infowindow = new google.maps.InfoWindow({content:
infoWindowData(newMarker, newMarker.title)});
infowindow.open(map, currentMarker);
});
//listen for the rightclick event to close the infowindow
google.maps.event.addListener(newMarker, 'rightclick', function(){
infowindow.close();
currentMarker = null;
});
google.maps.event.addListener(newMarker, 'drag', function(){
var data = infoWindowData(newMarker, newMarker.title);
console.log("Window Data: "+data);
infowindow = new google.maps.InfoWindow({content: data});
infowindow.open(map, newMarker);
});
})(newMarker);
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-maps-js-api-v3/-/pyCDl3K9GosJ.
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.