[OpenLayers-Users] Load all the popups in map.popups

jvonrudno jvonrudno at hotmail.com
Tue Jul 31 08:20:59 PDT 2012


Hi everybody

I have a problem and I hope I you can help me!!!

Tipically when we use a map with markers and you click over it you can see
the popup, but my situation is in the other way I have a map and I have
defined the markers and its respective popups, but I want to see the pop up
when the user click over one list to choose an element.

All the things work properly but my problem is that they show me only the
popups that I have showed previously. This is because I am using the funcion
"map.popups" to reach all the popups that are in the map. But the problem is
that the popups are added at the map only when it was opened with clip in
the marker.

I have tried to create all the popups at the beginning but I have the
following mistake when I run the class: "typeError: Extent is null"

This is part of my code. I will be very glad if someone can give some
solution:

thousands of thanks in advance.


//With this part I build the list
liCompanyList = document.createElement("LI");
liCompanyList.innerHTML = customer[i]['firma'];
liCompanyList.addEventListener("mousemove", showPopup, false);
liCompanyList.addEventListener("mouseout", hidePopup, false);
var ulCompanyList = document.getElementById("companyList");
ulCompanyList.appendChild(liCompanyList);

//Function to add the markers and popups.
function addMarkers(latitude, longitude, layerMarkersNumber, company,
street, citycode, city, telephon, fax, indexCustomer) {
	var position;
	var popupClass
	var popupContentHTML;
	//anchored bubble popup small contents autosize closebox;
	position = new OpenLayers.LonLat(latitude,
longitude).transform(fromProjection, toProjection);
	popupClass = AutoSizeFramedCloud;
	popupContentHTML = "<div>" + company + "<br>" + street + "<br>" + citycode
+ " " + city + "<br>Tel.: " + telephon + "<br>Fax: " + fax + "</div>";

	feature = new OpenLayers.Feature('layer_markers_'+layerMarkersNumber,
position);
	feature.closeBox = true;
	feature.popupClass = popupClass;
	feature.data.popupContentHTML = popupContentHTML;
	feature.data.overflow = (true) ? "auto" : "hidden";
	feature.data.icon =  icono.clone();
	feature.id = company;
	
	//Create the marker
	marker = feature.createMarker();

	//Create the popups and add to the map.
	var popup = feature.createPopup(feature.closeBox);
	if (popup != null)
	{
		map.addPopup(popup);		//This instruction is who give the problem.
	}

	var markerClick = function (evt) {
		if (this.popup == null) {
			this.popup = this.createPopup(this.closeBox);
			map.addPopup(this.popup);
			this.popup.show();
		} else {
			this.popup.toggle();
			this.popup.updateSize();
		}
		currentPopup = this.popup;
		OpenLayers.Event.stop(evt);
	};

	marker.events.register("mouseover", feature, markerClick);
	marker.events.register("mouseout", feature, markerClick);
	marker.events.register("mousedown", feature, markerClick);

	marker.events.register("mousedown", map, mouseMoveHandler);

	//marker.events.register("mousemove",map,mouseMoveHandler);

	switch (layerMarkersNumber)
	{
		case 0: layer_markers_0.addMarker(marker);	//add the marker.
				break;
		case 1: layer_markers_1.addMarker(marker);	//add the marker.
				break;
		case 2: layer_markers_2.addMarker(marker);	//add the marker.
				break;
		case 3: layer_markers_3.addMarker(marker);	//add the marker.
				break;
		case 4: layer_markers_4.addMarker(marker);	//add the marker.
				break;
	}
	
	
}

function showPopup()
{
	var arrayPopups = map.popups;
	for (i=0; i<map.popups.length; i++)
	{
		var popup_id = arrayPopups[i].id;
		if (this.innerHTML+"_popup" == popup_id)
		{
			arrayPopups[i].show();
		}
	}
}




--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Load-all-the-popups-in-map-popups-tp4992197.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list