I have been trying to get the infoWindow to show when I click on a marker.
Use to work until I added .push.
Here is what I had when it worked fine:
var infowindow = new google.maps.InfoWindow(
{
size: new google.maps.Size(150,50)
});
function createMarker(map, latlng, label, html, color) {
var contentString = label;
marker = new google.maps.Marker({
position: latlng,
map: map,
icon: getMarkerImage(color),
shape: iconShape,
zIndex: Math.round(latlng.lat()*-100000)<<5
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(contentString);
infowindow.open(map,marker);
});
}
Now what I did was in the createMarker function was added .push to markers
as you see
markers.push(new google.maps.Marker({
position: latlng,
map: map,
shadow: iconShadow,
icon: getMarkerImage(color),
shape: iconShape,
zIndex: Math.round(latlng.lat()*-100000)<<5
}));
Reason I did that was I wanted to clear markers when I clicked get direction
button, thats works, but when I load the page everything loads properly but
when I click a marker no infoWIndow shows. Now in the
google.maps.event.addListener I changed marker to markers and still doesnt
work; heres what I have
google.maps.event.addListener(markers, 'click', function() {
infowindow.setContent(contentString);
infowindow.open(map,markers);
});
}
Anyone have an Idea why it doesnt work.
Thanks
Kevin
--
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.