<div dir="ltr">Hi<div><br></div><div style>because you hit a classical problem with closures inside loops. </div><div style>Only one  handler  is shared for each marke, in fact the last one from the loop, the reason why you have the content of the last marker.</div>
<div style>You have to create your handler from a 'function factory' like explained here : <a href="http://felix-kling.de/blog/2011/01/09/javascript-about-loops-functions-closures/">http://felix-kling.de/blog/2011/01/09/javascript-about-loops-functions-closures/</a> </div>
<div style>Regards</div><div style>Yves</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/2/28 dolphintroop <span dir="ltr"><<a href="mailto:thymeland@hotmail.com" target="_blank">thymeland@hotmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,list:<br>
I just searched forum whole afternoon, and I still cannot find any clue<br>
about my question.<br>
<br>
Now I need to display multiple popups of markers on the map,and each popup<br>
has different content(such as the lat-lon of marker), and the content<br>
information need be loaded from background server directly(I considered the<br>
way load from txt,but it makes the thing complicated).<br>
<br>
below is the part of code, I suppose that the data has been loaded and put<br>
in an array of coodCollection [].<br>
//************************************************************<br>
var coodCollection<br>
=[10.926984840916,22.54309741608402,10.9270373628267,22.54429109286876];<br>
<br>
                markers = new OpenLayers.Layer.Markers("Markers2");<br>
                map.addLayer(markers);<br>
<br>
<br>
<br>
                for ( var i = 0; i < (coodCollection.length / 2); i++) {<br>
<br>
                        var lon = coodCollection[i * 2];<br>
                        var lat = coodCollection[i * 2 + 1];<br>
<br>
                        var size = new OpenLayers.Size(21, 25);<br>
                        var offset = new OpenLayers.Pixel(-(size.w / 2), -size.h);<br>
                        var iconName = 'img/marker.png';<br>
<br>
<br>
<br>
<br>
                        var icon = new OpenLayers.Icon(iconName, size, offset);<br>
<br>
                        marker = new OpenLayers.Marker(new OpenLayers.LonLat(lon, lat),<br>
                                        icon.clone());<br>
<br>
                        marker.events.register("mouseover", marker, function(e) {<br>
                                popup = new OpenLayers.Popup.FramedCloud("chicken",<br>
                                                marker.lonlat, new OpenLayers.Size(200, 200),<br>
                                                marker.lonlat, null, true);<br>
<br>
                                map.addPopup(popup);<br>
                        });<br>
                        marker.events.register('mouseout', marker, function(evt) {<br>
                                popup.hide();<br>
                        });<br>
<br>
                        markers.addMarker(marker);<br>
<br>
                }<br>
//************************************************************<br>
<br>
Now the marker is displayed and  arranged as I wanted, the popup is jump out<br>
when I put mouse on marker, but all the content of popup is the last<br>
coordinate pair of coodCollection [], I don't know how to figure out the<br>
reason.<br>
<br>
Any suggestion is appreciated!<br>
<br>
Thank you in advanced!<br>
<br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://osgeo-org.1560.n6.nabble.com/why-the-popups-have-same-content-tp5037498.html" target="_blank">http://osgeo-org.1560.n6.nabble.com/why-the-popups-have-same-content-tp5037498.html</a><br>

Sent from the OpenLayers Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.osgeo.org">Users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a><br>
</blockquote></div><br></div>