[OpenLayers-Users] markers + popup problem

smengl smengl at mit.edu
Sun Jun 8 17:45:16 EDT 2008


Hi I am trying to create info box popups when there is a click on a marker.
See below for my javascript code. The problem is that only the first click
will generate a popup box and after that, nothing happens.
I think the problem is that i declare the popup variable inside the for
loops, but cannot figure out how to solve the problem.

Could some one please help me with this problem?	

for(var i=0; i<places.length;i++){

		var place = places[i];
		var marker= new OpenLayers.Marker(new OpenLayers.LonLat(place.y,place.x),
new
OpenLayers.Icon('http://www.projectliberty.org/var/liberty/storage/images/files/images/icons/oil_icon/24263-1-eng-US/oil_icon_small.jpg',iconSize,iconOffset));

		markerlist= new Array();

		markerlist[i]= marker;
		markersLayer.addMarker(markerlist[i]);	
		var testPopup = new OpenLayers.Popup("details", new
OpenLayers.LonLat(place.y,place.x),new OpenLayers.Size(200,200),place.name,
true);
	
markerlist[i].events.register("click",markerlist[i],function(e){map.addPopup(testPopup,true)});	
		
}
		markersLayer.setVisibility(true);
		map.addLayer(markersLayer);
		map.setCenter(new OpenLayers.LonLat(-104.680212,37.393279),5);
 	        }
-- 
View this message in context: http://www.nabble.com/markers-%2B-popup-problem-tp17701070p17701070.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list