Hi there,
I’m using new to this forum, so first of all: hello!
I got a problem in the piece of javascript code below.
A for loop reads an XML file and creates an object (marker)
for each XML item. Now all objects have the name/id ‘marker’
and so only the last create is called by my javascript.
How can I make this code work so it creates: marker1 = new GMarker, marker2 = new GMarker ect.
and use them in het GEvent.addListener function and in the last 2 lines of code?
_j
[CODE]
for (i=0;i<x.length;i++) {
var redIcon = new GIcon(G_DEFAULT_ICON);
redIcon.image = “images/” + x[i].getElementsByTagName(“TYPE”)[0].childNodes[0].nodeValue + “.png”;
redIcon.shadow = “images/shadow.png”;
redIcon.iconSize = new GSize(25,31);
redIcon.shadowSize = new GSize(1,1);
redIcon.iconAnchor = new GPoint(0, 0);
redIcon.infoWindowAnchor = new GPoint(135,20);
marker = new GMarker( new GLatLng(x[i].getElementsByTagName(“LATITUDE”)[0].childNodes[0].nodeValue,x[i].getElementsByTagName(“LONGITUDE”)[0].childNodes[0].nodeValue),{icon:redIcon,zIndexProcess:importanceOrder});
var icon_type = x[i].getElementsByTagName(“TITLE”)[0].childNodes[0].nodeValue;
var icon_description = x[i].getElementsByTagName(“DESCRIPTION”)[0].childNodes[0].nodeValue;
var icon_image = x[i].getElementsByTagName(“IMAGE”)[0].childNodes[0].nodeValue;
var icon_link = x[i].getElementsByTagName(“LINK”)[0].childNodes[0].nodeValue;
GEvent.addListener(marker, “mouseover”, function(){
marker.openExtInfoWindow(
map,
“opacity_window”,
“<div class=’title’>”+icon_type+”</div>”+
“<div class=’section2′><p><img src='”+icon_image+”‘>”+icon_description+”</p></div>”+
“<div class=’section3′><p><img src=’images/link.png’><a href='”+icon_link+”‘> Meer info en boeken</a></p>”,
{ beakOffset: 18 }
);
});
marker.importance = 2;
map.addOverlay(marker);
}