open popup in open layers from external list

时间:2022-06-06 11:57:09
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!

Answer this question:

function  addMarker(ll, popupClass, html, closeBox, overflow,isShow,mIndex) 
{    
    
var  feature  =   new  OpenLayers.Feature(markers, ll); 
    feature.closeBox 
=  closeBox;
    feature.popupClass 
=  popupClass;
    feature.data.popupContentHTML 
=  html;
    feature.data.overflow 
=  (overflow)  ?   " auto "  :  " hidden " ;
                        
    
var  marker  =  feature.createMarker();
    marker.setUrl(
' http://www.visitchn.com/main/map/img/marker ' + mIndex + ' .png ' );    // ICON
    marker.display( true );   
    
    
if (isShow == true )
    {        
        removeAllPopup();
        feature.popup 
=  feature.createPopup(feature.closeBox);
        map.addPopup(feature.popup);
        feature.popup.show();
    }
    
    
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);
}



open popup in open layers from external listopen popup in open layers from external listCode