Hello. I'm reading in an XML file to create points. I'm trying to assign a popup window with separate content for each marker. When I use the code below, it will only create a popup window for the last XML element in the for loop. Can someone tell me how I can go about binding a popup window to a marker, similar to what the bindinfowindow method does in google maps?<br>
<br>Thanks<br><br><br>var markers = new OpenLayers.Layer.Markers("Markers", {displayInLayerSwitcher:true});<br> <br>xmlDoc = req.responseXML;<br>xmlValues = xmlDoc.getElementsByTagName("pt");<br>
<br>for ( var i = 0; i < xmlValues.length ; i++ ){<br> <br> map.addLayer(markers);<br> lat = xmlValues[i].getAttribute("lat");<br> lng = xmlValues[i].getAttribute("lon");<br>
var zip = xmlValues[i].getAttribute("zip");<br> <br> var content = zip;<br> var popup = new OpenLayers.Popup("popup", new OpenLayers.LonLat(parseXml.lng,parseXml.lat), new OpenLayers.Size(200,200))<br>
popup.setContentHTML(content);<br> map.addPopup(popup);<br> popup.setContentHTML;<br> popup.hide();<br> markers.events.register("mousedown", markers, function(){popup.show()});<br>
markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(lng,lat)));<br> }<br>