Hi Carlos,

I think the 'feature' is not known outside the 'addMarker()' function. So if 
the click is done the feature is undefined, the same is for the markerClick 
function, i think it's also undefined.

Move both outside 'addMarker()' so that they are known when there is clicked on 
the marker.

Roy
  _____  

From: carlos [mailto:[email protected]]
To: [email protected]
Sent: Tue, 11 Jan 2011 08:39:37 +0100
Subject: [OpenLayers-Users] Icon marker and popup

                      
    

Hi all!!!    

     

I have this function, in order to, add markers to my  map.    

     

function addMarker(ll, popupClass, popupContentHTML,  closeBox, overflow) {    

                 

     

             var feature = new OpenLayers.Feature(markers, ll);             

             feature.closeBox = closeBox;    

             feature.popupClass = popupClass;    

             feature.data.popupContentHTML = popupContentHTML;    

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

                         

             var marker = feature.createMarker();    

                                        

             var size = new OpenLayers.Size(25,25);    

             var offset = new OpenLayers.Pixel(-12, -24);    

             var icon = new 
OpenLayers.Icon('http://www.openlayers.org/dev/img/marker-blue.png',   size, 
offset);    

             marker.icon = icon;           

     

             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);    

        }    

     

I have a problem with the icon of the marker. If I  put an icon the event 
mousedown don’t work. The pop-up of my marker don't  appear. There is any 
trouble with that?    

     

Thanks!!!                
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to