[OpenLayers-Users] open popup in open layers from external list

Arnd Wippermann arnd.wippermann at web.de
Mon Oct 6 12:45:24 EDT 2008


Hi,

I'm not familiar with Markers, but I would think

If you create your list with an onclick function ie. togglePopup(idx) with
the index of the marker, then 
you should be able to show and hide the popup. What I don't know, if
marker.length and feature[idx] is the right way to reference to the markers.

After creating the markers, create the html of the list:

for(var i=0;i<marker.length;i++)
    theHTML = '<span onclick="togglePopup('+i+')">Marker ' + i +
'</span><br>';

document.getElementById("yourListDiv").innerHTML = theHTML;


and use as onclick function something like this:

function togglePopup(idx)
{
    if (feature[idx].popup == null) {
   	    feature[idx].popup =
feature[idx].createPopup(feature[idx].closeBox);
      	 	map.addPopup(feature[idx].popup);
      		feature[idx].popup.show();
   	} else {
       	feature[idx].popup.toggle();
    }
  currentPopup = feature[idx].popup;
}
 
Arnd Wippermann

-----Ursprüngliche Nachricht-----
Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von Bijoy K. Anupam
Gesendet: Montag, 6. Oktober 2008 09:04
An: users at openlayers.org
Betreff: Re: [OpenLayers-Users] open popup in open layers from external list

Hi Leo,

I exactly have the same problem. And, I don't know if this can be done.
Currently, my work is on hold in this direction :-(

If you find any solution on this, please share this with me too... :)

<BIJOY>

-----Original Message-----
From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] On
Behalf Of Leo
Sent: Sunday, October 05, 2008 6:27 PM
To: users at openlayers.org
Subject: [OpenLayers-Users] open popup in open layers from external list


Hi to all, I have a map with a lot of marker. Every marker is added by the
function at the bottom. All works very well and i can see all marker in the
map with its popup if i click on it. Now I would create a popup window with
an html list of all markers in the map and if i click an item i want the
marker associated in the map opens its popup.
I've looked in the example, but i can't find the solution. Is there a way to
do what i need?

Thank you very much for your help!

function addMarker(ll, popupClass, popupContentHTML, closeBox, overflow,
iconID) {        
				
				var size = "";
				var offset = "";
				var icon = "";
				switch (iconID)
				{				
					case 1:
					{
						size = new
OpenLayers.Size(17,29);
	    		        offset = new OpenLayers.Pixel(-(size.w/2),
-size.h);				
						icon = new
OpenLayers.Icon(\'./templates/images/GREEN.png\',size,offset);
					}break;				
					case 2:
					{
						size = new
OpenLayers.Size(8,8);
	    		        offset = new OpenLayers.Pixel(-(size.w/2),
-size.h);				
						icon = new
OpenLayers.Icon(\'./templates/images/listitem.png\',size,offset);
					}break;
					case 3:
					{
						size = new
OpenLayers.Size(17,29);
	    		        offset = new OpenLayers.Pixel(-(size.w/2),
-size.h);				
						icon = new
OpenLayers.Icon(\'./templates/images/RED.png\',size,offset);
					}break;
					default:
					{
						size = new
OpenLayers.Size(17,29);
	    		        offset = new OpenLayers.Pixel(-(size.w/2),
-size.h);				
						icon = new
OpenLayers.Icon(\'./templates/images/AQUA.png\',size,offset);
					}break;
				}
									
				
				var feature = new
OpenLayers.Feature(markers, ll, {icon: icon});

				
            	feature.closeBox = closeBox;
	            feature.popupClass = popupClass;
	            feature.data.popupContentHTML = popupContentHTML;
	            feature.data.overflow = (overflow) ? "auto" : "hidden";

                    
    	        var marker = feature.createMarker();


        	    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();
	                }
    		         currentPopup = this.popup;
            	    OpenLayers.Event.stop(evt);
            	};
	            marker.events.register("mousedown", feature,
markerClick);					

    	        markers.addMarker(marker);				

        	}
--
View this message in context:
http://n2.nabble.com/open-popup-in-open-layers-from-external-list-tp1298733p
1298733.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.

_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users

_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users




More information about the Users mailing list