[OpenLayers-Users] why the popups have same content?
Yves Gillet
ygillet at gmail.com
Thu Feb 28 11:45:54 PST 2013
HI
try this, the popupHandler closure is outside the loop for clarity but when
you are accustomed to the syntax you can declare it anonymously inline.
Regards
var popupHandler = function(marker){
return function(e){
popup = new OpenLayers.Popup.FramedCloud("chicken",
marker.lonlat, new
OpenLayers.Size(200, 200),
marker.lonlat, null, true);
map.addPopup(popup);
}
}
for ( var i = 0; i < (coodCollection.length / 2); i++) {
//snipped
marker.events.register("mouseover", marker,
popupHandler(marker));
}
2013/2/28 dolphintroop <thymeland at hotmail.com>
> Hi,Yves G
>
> Thanks for your suggestion, but the closures inside loops is hard to
> understand for me , could you give me a clear solution based on this code
> section?
> thank you!
>
>
>
> --
> View this message in context:
> http://osgeo-org.1560.n6.nabble.com/why-the-popups-have-same-content-tp5037498p5037571.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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130228/85ec4d08/attachment.html>
More information about the Users
mailing list