tags:

views:

38

answers:

1

Hello,

I use google maps marker. I have array of info to be shown with info window. I have tried like this,

markers = xml.documentElement.getElementsByTagName("marker");

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

    info = markers[i].getAttribute("info");
    GEvent.addListener(markers[i], "click", function(info) {
          this.openInfoWindowHtml(info);                      
    });
}

openInfoWindowHtml(info) must be displayed for each and every marker. I need to get the info window displayed.

thanks v.srinath

A: 

You have an error in your code at this line GEvent.addListener(marker[i], "click", function(info) { there is not such array marker

Fixed code is

markers = xml.documentElement.getElementsByTagName("marker");

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

    info = markers[i].getAttribute("info");
    GEvent.addListener(markers[i], "click", function() {
          markers[i].openInfoWindowHtml(info);                      
    });
}
antyrat
antyrat, sorry for the spelling mistake. It is indeed the GEvent.addListener(markers[i],..) and now I edited it. still it does n't work.thanksv.srinath
V.Srinath
I update my answer, try now.
antyrat
Can you show XML file example? I don't see where you create marker. It must be something like this: var marker = new GMarker(point); where var point = new GLatLng(lat,lng);
antyrat
<markers> <marker name="Restaurant Name" address="7643 qwert" lat="50.8343" lng="-100.34534"/> <marker name="Restaurant name" address="2345 mnbv" lat="51.6564" lng="-100.345"/></markers>
V.Srinath
geocoder.getLocations(.........markers = xml.documentElement.getElementsByTagName("marker");location3 = <lat, lng> //from geocoderfor (i = 0; i < markers.length; i++) { location2 = new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng"))); if(distance_in_mile(locaiton2,location3) < 5) {marker[i] = new GMarker(location2); map.addOverlay(marker[i]);info = markers[i].getAttribute("address");GEvent.addListener(marker[i], "click", function() {this.openInfoWindowHtml(info);});
V.Srinath