[OpenLayers-Users] Change marker-icon on click // Layer.redraw() fails !!

Bytechanger Bytechanger at gmx.de
Wed Oct 21 05:36:15 EDT 2009


Hi,

I want to change marker icon on click, but when I call Layer.redraw() to
show the change ist happens!
After that i can´t click the marker anymore ! Only this marker!

It seems that Layer.redraw() destroys the mousdown event on this
marker???!!!!

Greetings

Byte


########### snip ##################################
function addMarker(layer, lon2, lat2, popupContentHTML, iconId, ZielProj) {

[...]
 

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

    feature.closeBox = true;


    feature.popupClass = OpenLayers.Class(OpenLayers.Popup.FramedCloud,
{autoSize: false });
    feature.data.popupContentHTML = popupContentHTML;
    feature.data.overflow = "hidden";
    feature.data.icon = makeIcon(iconId);

// my one -------------------------------------
     feature.data.orgIcon=makeIcon(iconId);
     feature.data.ClickIcon=makeIcon(6);
     feature.data.OverIcon=makeIcon(6);
//----------------------------------------------

     var marker = feature.createMarker();

    var markerClick = function(evt) {

        if (this.popup==null) {

                                   this.popup =
this.createPopup(this.closeBox);

                               
                                   
this.data.marker.icon=this.data.ClickIcon;

                                   LayerP.redraw();

            map.addPopup(this.popup);

            this.popup.show();

          

        } else {

    

            if (this.popup.visible==false) {

                                  
this.data.marker.icon=this.data.ClickIcon;

                                   LayerP.redraw();            }

            else {

                                   this.data.marker.icon=this.data.orgIcon;

                                   LayerP.redraw();

            }

          

            this.popup.toggle();           

 

        }

            // ###################################

                        OpenLayers.Event.stop(evt);

    };

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

            feature.data.marker=marker;

 
    layer.addMarker(marker);


}


###############################################
-- 
View this message in context: http://n2.nabble.com/Change-marker-icon-on-click-Layer-redraw-fails-tp3864144p3864144.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list