Try to make your themarker array global. Then you can try it this way

for(var i = 0; i < markers.length; i++) {

 var html ="<div class='infowindow'>" +
  lat + lng +
  "<\/div>";
  themarker[i].prop = html;
  addClickevent(themarker[i]);

 .....
}


function addClickevent(marker) {

 GEvent.addListener(marker, "click", function() {

  marker.openInfoWindowHtml(marker.prop);

 });
 return marker;
}


Try to define marker.prop also in your for-loop






On Dec 26, 12:10 pm, "Michael M." <[email protected]> wrote:
> > You should review Mike Williams' tutorial that Ralph pointed you to,
> > in particular the part about function closure and pitfall #3 on this
> > page:
> > Part 1 Markers with info windowshttp://econym.org.uk/gmap/basic1.htm
>
> I can't find any information about using arrays
>
> It seem like its the ”addlistener” that don’t work with arrays.
>
> -- this works --
> GEvent.addListener(themarker, "click", function() {
> themarker.openInfoWindow(load_php("arbplads",aid));
>
> })
>
> -- this do NOT work --
> GEvent.addListener(themarker[i], "click", function() {
> Themarker[i].openInfoWindow(load_php("arbplads",aid));
>
> })
>
> If I remove the addListener everything works (http://www.dbioc.dk/
> integration/sitephp/googlemapstest.php) but then there is no onclick
> event on the markers
>
> If I don’t use array (http://www.dbioc.dk/integration/sitephp/
> googlemapstest2.php) only the latest created marker works.
>
> Is there not a way to make this work with arrays ??
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to