Skip to content

State of all shapes in the layer #1081

Discussion options

You must be logged in to vote

You can add to the Shapes directly a event forwarding. So you don't need to add the listener for each layer.

L.Polyline.include({
        _fireOnMap: function(e){
            e.firedLayer = this;
            this._map.fire(e.type,e)
        },
        addLayer: function(){
          if(this._map){
            this.on('pm:dragstart',this._fireOnMap,this)
            this.on('pm:drag',this._fireOnMap,this)
            this.on('pm:dragend',this._fireOnMap,this)
          }
        }
      });
L.Polyline.addInitHook(function(){
        this.on('add',this.addLayer, this);
      });

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@cubecleveland
Comment options

@Falke-Design
Comment options

Answer selected by Falke-Design
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants