Closed TheInvoker closed 8 years ago
I found a workaround
function addMarker(map, marker, content) {
map.marker(marker).then(function(marker) {
map.infowindow({
'content' : content
})
.then(function (infowindow) {
var map = this.get(0);
marker.addListener('click', function(event, data) {
infowindow.open(map, this);
});
});
});
}
Yes, "get" return the created items from the beginning, And yes, your "workaround" is how you're supposed to do, this is done like this in the example
btw, I note that it might be useful to handle negative index in get, ie: get(-1) to get the last item... I'll add it i guess
In gmap3 google maps library, I am trying to make a function that makes a marker with an infowindow.
http://gmap3.net/api-infowindow.html
This is what I have, but the problem is, in the top, where I try to get a marker (i put a comment in the code), it seems to be referencing the wrong marker. Both times I call it, it references the first marker I make. As a result, if I click the first marker on the map, I get both infowindows showing up on that marker.
Does anyone know whats wrong?
Thanks