Thanks all for your replies.
I've modified my code (posted below), but now when I do a mouse over,
it'll show the InfoWindow, but no text are shown... Anybody can
identify the problem? Thanks in advance!
function showAllMarkers(){
//First, clear all overlays
//clearAllOverlay();
var myLat;
var myLng;
var myName;
for (var i=1;arrayName[i]!=null;i++){
myLat = arrayLat[i];
myLng = arrayLng[i];
myName = arrayName[i];
var options = {
title: arrayName[i]
};
// Add marker and show overlay
var point = new GLatLng(myLat,myLng);
alert('MyName is '+myName);
var marker = createMarker(point,options,'I\'m
'+myName+'');
map.addOverlay(marker);
}
}
function createMarker(point,options,html) {
var marker = new GMarker(point,options);
GEvent.addListener(marker, "mouseover", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
the "myName" alert will show the value correct.
On Mar 12, 8:54 pm, Andrew Leach <[email protected]>
wrote:
> On Mar 12, 12:40 pm, Gan <[email protected]> wrote:
>
> > I have the following code:
> > However, no matter which marker I mouse over, it will show me the same
> > value from the last array.
>
> You need a helper function to create your markers.
> Seehttp://econym.org.uk/gmap/basic1.htm-- currently you have fallen into
> Pitfall Number Three.
>
> Andrew
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" 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-API?hl=en
-~----------~----~----~----~------~----~------~--~---