[OpenLayers-Users] Bind Popup Window To A Marker
Brian Behling
brian.behling at gmail.com
Thu Oct 22 16:49:07 EDT 2009
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?
Thanks
var markers = new OpenLayers.Layer.Markers("Markers",
{displayInLayerSwitcher:true});
xmlDoc = req.responseXML;
xmlValues = xmlDoc.getElementsByTagName("pt");
for ( var i = 0; i < xmlValues.length ; i++ ){
map.addLayer(markers);
lat = xmlValues[i].getAttribute("lat");
lng = xmlValues[i].getAttribute("lon");
var zip = xmlValues[i].getAttribute("zip");
var content = zip;
var popup = new OpenLayers.Popup("popup", new
OpenLayers.LonLat(parseXml.lng,parseXml.lat), new OpenLayers.Size(200,200))
popup.setContentHTML(content);
map.addPopup(popup);
popup.setContentHTML;
popup.hide();
markers.events.register("mousedown", markers,
function(){popup.show()});
markers.addMarker(new OpenLayers.Marker(new
OpenLayers.LonLat(lng,lat)));
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20091022/bebe29ef/attachment.html
More information about the Users
mailing list