leaflet.snap.js
function(e) {
        L.EditToolbar.Edit.prototype._enableLayerEdit.call(this, e);

        var layer = e.layer || e.target || e;

        if (!layer.snapediting) {
            if (layer.hasOwnProperty('_mRadius')) {
                if (layer.editing) {
                    layer.editing._markerGroup.clearLayers();
                    delete layer.editing;
                }
                layer.editing = layer.snapediting = new L.Handler.CircleSnap(layer._map, layer, this.snapOptions);
            }
            
            else if (layer.getLatLng) {
                layer.snapediting = new L.Handler.MarkerSnap(layer._map, layer, this.snapOptions);
            }
            
            else {
                if (layer.editing) {
                    if (layer.editing.hasOwnProperty('_shape')) {
                        layer.editing._markerGroup.clearLayers();
                        if (layer.editing._shape instanceof L.Rectangle) {
                            delete layer.editing;
                            layer.editing = layer.snapediting = new L.Handler.RectangleSnap(layer._map, layer, this.snapOptions);
                        }
                        else if (layer.editing._shape instanceof L.FeatureGroup) {
                            delete layer.editing;
                            layer.editing = layer.snapediting = new L.Handler.FeatureGroupSnap(layer._map, layer, this.snapOptions);
                        }
                        else {
                            delete layer.editing;
                            layer.editing = layer.snapediting = new L.Handler.CircleSnap(layer._map, layer, this.snapOptions);
                        }
                    }
                    else {
                        layer.editing._markerGroup.clearLayers();
                        layer.editing._verticesHandlers[0]._markerGroup.clearLayers();
                        delete layer.editing;
                        layer.editing = layer.snapediting = new L.Handler.PolylineSnap(layer._map, layer, this.snapOptions);
                    }
                }
                else {
                    layer.editing = layer.snapediting = new L.Handler.PolylineSnap(layer._map, layer, this.snapOptions);
                }
            }

            for (var i = 0, n = this._guideLayers.length; i < n; i++) {
                layer.snapediting.addGuideLayer(this._guideLayers[i]);
            }
        }

        layer.snapediting.enable();
    }
function(e) {
        L.EditToolbar.Edit.prototype._enableLayerEdit.call(this, e);

        var layer = e.layer || e.target || e;

        if (!layer.snapediting) {
            if (layer.hasOwnProperty('_mRadius')) {
                if (layer.editing) {
                    layer.editing._markerGroup.clearLayers();
                    delete layer.editing;
                }
                layer.editing = layer.snapediting = new L.Handler.CircleSnap(layer._map, layer, this.snapOptions);
            }
            
            else if (layer.getLatLng) {
                layer.snapediting = new L.Handler.MarkerSnap(layer._map, layer, this.snapOptions);
            }
            
            else {
                if (layer.editing) {
                    if (layer.editing.hasOwnProperty('_shape')) {
                        layer.editing._markerGroup.clearLayers();
                        if (layer.editing._shape instanceof L.Rectangle) {
                            delete layer.editing;
                            layer.editing = layer.snapediting = new L.Handler.RectangleSnap(layer._map, layer, this.snapOptions);
                        }
                        else if (layer.editing._shape instanceof L.FeatureGroup) {
                            delete layer.editing;
                            layer.editing = layer.snapediting = new L.Handler.FeatureGroupSnap(layer._map, layer, this.snapOptions);
                        }
                        else {
                            delete layer.editing;
                            layer.editing = layer.snapediting = new L.Handler.CircleSnap(layer._map, layer, this.snapOptions);
                        }
                    }
                    else {
                        layer.editing._markerGroup.clearLayers();
                        layer.editing._verticesHandlers[0]._markerGroup.clearLayers();
                        delete layer.editing;
                        layer.editing = layer.snapediting = new L.Handler.PolylineSnap(layer._map, layer, this.snapOptions);
                    }
                }
                else {
                    layer.editing = layer.snapediting = new L.Handler.PolylineSnap(layer._map, layer, this.snapOptions);
                }
            }

            for (var i = 0, n = this._guideLayers.length; i < n; i++) {
                layer.snapediting.addGuideLayer(this._guideLayers[i]);
            }
        }

        layer.snapediting.enable();
    }
function ( e ) { L . EditToolbar . Edit . prototype . _enableLayerEdit . call ( this , e ) ; var layer = e . layer || e . target || e ; if ( ! layer . snapediting ) { if ( layer . hasOwnProperty ( '_mRadius' ) ) { if ( layer . editing ) { layer . editing . _markerGroup . clearLayers ( ) ; delete layer . editing ; } layer . editing = layer . snapediting = new L . Handler . CircleSnap ( layer . _map , layer , this . snapOptions ) ; } else if ( layer . getLatLng ) { layer . snapediting = new L . Handler . MarkerSnap ( layer . _map , layer , this . snapOptions ) ; } else { if ( layer . editing ) { if ( layer . editing . hasOwnProperty ( '_shape' ) ) { layer . editing . _markerGroup . clearLayers ( ) ; if ( layer . editing . _shape instanceof L . Rectangle ) { delete layer . editing ; layer . editing = layer . snapediting = new L . Handler . RectangleSnap ( layer . _map , layer , this . snapOptions ) ; } else if ( layer . editing . _shape instanceof L . FeatureGroup ) { delete layer . editing ; layer . editing = layer . snapediting = new L . Handler . FeatureGroupSnap ( layer . _map , layer , this . snapOptions ) ; } else { delete layer . editing ; layer . editing = layer . snapediting = new L . Handler . CircleSnap ( layer . _map , layer , this . snapOptions ) ; } } else { layer . editing . _markerGroup . clearLayers ( ) ; layer . editing . _verticesHandlers [ 0 ] . _markerGroup . clearLayers ( ) ; delete layer . editing ; layer . editing = layer . snapediting = new L . Handler . PolylineSnap ( layer . _map , layer , this . snapOptions ) ; } } else { layer . editing = layer . snapediting = new L . Handler . PolylineSnap ( layer . _map , layer , this . snapOptions ) ; } } for ( var i = 0 , n = this . _guideLayers . length ; i < n ; i ++ ) { layer . snapediting . addGuideLayer ( this . _guideLayers [ i ] ) ; } } layer . snapediting . enable ( ) ; }
essentially, the idea here is that we're gonna find the currently instantiated L.Edit handler, figure out its type, get rid of it, and then replace it with a snapedit instead
essentially the idea here is that we re gonna find the currently instantiated L . Edit handler figure out its type get rid of it and then replace it with a snapedit instead