[OpenLayers-Users] why the popups have same content?

Gery . gamejihou at hotmail.com
Thu Feb 28 05:25:11 PST 2013


From here for instance:

var coodCollection
=[10.926984840916,22.54309741608402,10.9270373628267,22.54429109286876];

Which values do you get always?

Sent from my iBath

On Feb 28, 2013, at 14:17, "dolphintroop" <thymeland at hotmail.com> wrote:

Hi,list:
I just searched forum whole afternoon, and I still cannot find any clue
about my question.

Now I need to display multiple popups of markers on the map,and each popup
has different content(such as the lat-lon of marker), and the content
information need be loaded from background server directly(I considered the
way load from txt,but it makes the thing complicated).

below is the part of code, I suppose that the data has been loaded and put
in an array of coodCollection [].
//************************************************************
var coodCollection
=[10.926984840916,22.54309741608402,10.9270373628267,22.54429109286876];

       markers = new OpenLayers.Layer.Markers("Markers2");
       map.addLayer(markers);



       for ( var i = 0; i < (coodCollection.length / 2); i++) {

           var lon = coodCollection[i * 2];
           var lat = coodCollection[i * 2 + 1];

           var size = new OpenLayers.Size(21, 25);
           var offset = new OpenLayers.Pixel(-(size.w / 2), -size.h);
           var iconName = 'img/marker.png';




           var icon = new OpenLayers.Icon(iconName, size, offset);

           marker = new OpenLayers.Marker(new OpenLayers.LonLat(lon, lat),
                   icon.clone());

           marker.events.register("mouseover", marker, function(e) {
               popup = new OpenLayers.Popup.FramedCloud("chicken",
                       marker.lonlat, new OpenLayers.Size(200, 200),
                       marker.lonlat, null, true);

               map.addPopup(popup);
           });
           marker.events.register('mouseout', marker, function(evt) {
               popup.hide();
           });

           markers.addMarker(marker);

       }
//************************************************************

Now the marker is displayed and  arranged as I wanted, the popup is jump out
when I put mouse on marker, but all the content of popup is the last
coordinate pair of coodCollection [], I don't know how to figure out the
reason.

Any suggestion is appreciated!

Thank you in advanced!






--
View this message in context: http://osgeo-org.1560.n6.nabble.com/why-the-popups-have-same-content-tp5037498.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users


More information about the Users mailing list