Google Maps, marker info window won't show up ?
Posted
by user296516
on Stack Overflow
See other posts from Stack Overflow
or by user296516
Published on 2010-04-19T08:12:16Z
Indexed on
2010/04/19
10:13 UTC
Read the original article
Hit count: 327
google-maps
|JavaScript
Hi guys, I have written this code that loops through an array of lat/long coordinates and places a marker at each of the coordinate. Everything forks fine, exempt the info window won't appear once the marker is clicked.
var ExpTowerIcon = new GIcon();
ExpTowerIcon.image = "tower.png";
ExpTowerIcon.iconSize = new GSize(75, 75);
ExpTowerIcon.iconAnchor = new GPoint(37, 65);
ExpTowerIcon.infoWindowAnchor = new GPoint(37, 20);
var marker=new Array();
for ( i=0 ; i < lat.length ; i++ ) {
var MarkerPoint = new GLatLng(lat[i],long[i]);
marker[i] = new GMarker(MarkerPoint,{icon:ExpTowerIcon})
map.addOverlay( marker[i] );
GEvent.addListener( marker[i] , 'click', function() { marker[i].openInfoWindowHtml('Hello!') ; });
var polyline = new GPolyline([ new GLatLng(lat[i],long[i]) , new GLatLng(lat[i+1],long[i+1]) ], "#ff0000", 5);
map.addOverlay(polyline);
}
Any ideas? Thanks!
© Stack Overflow or respective owner