Hey guys!
I thought that this is going to be a really easy task, but for some
reason it is not...
I have this code here:
for(i = 0; i < hotspotsPlaces.length; i++) {
var hotspot = hotspotsPlaces[i];
var marker = createMarker(hotspot);
var refInfoWindow = createInfoWindow(marker, hotspot);
google.maps.event.addListener(marker, 'click', refInfoWindow);
marker.setMap(map);
bounds.extend(marker.position);
markers.push(marker);
}
once you click the marker, the infowindow opens:
function createInfoWindow(marker, hotspot) {
return (function() {
infowindow.setOptions({
'content': hotspot.description,
'position': hotspot.position
});
infowindow.open(map,marker);
google.maps.event.addDomListener(document.getElementById('direction'),'click',
function(){
alert('clicked!');
});
}
);
}
The infowindow content always contain a <span id="direction"></span>
and I want to dynamically attach a Listener for click on it. (it
should act like a button).
if I print document.getElementById('direction') to the console I get
the appropriate span shown. But no click event is attached to it.
I also don't see any error in the console so I'm really confused to
why it is not working.
I've tried to add an event to the direction span with mootools, plain
js, google.maps.event and nothing is working and I just can't
understand why???
Can someone tell me what did I do wrong???
Thank you in advance!
--
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.