src/pyams_gis/resources/js/Edit.Rectangle.min.js
changeset 0 c73bb834ccbe
equal deleted inserted replaced
-1:000000000000 0:c73bb834ccbe
       
     1 L.Edit=L.Edit||{};L.Edit.Rectangle=L.Edit.SimpleShape.extend({_createMoveMarker:function(){var b=this._shape.getBounds(),a=b.getCenter();this._moveMarker=this._createMarker(a,this.options.moveIcon)},_createResizeMarker:function(){var b=this._getCorners();this._resizeMarkers=[];for(var c=0,a=b.length;c<a;c++){this._resizeMarkers.push(this._createMarker(b[c],this.options.resizeIcon));this._resizeMarkers[c]._cornerIndex=c}},_onMarkerDragStart:function(d){L.Edit.SimpleShape.prototype._onMarkerDragStart.call(this,d);var b=this._getCorners(),a=d.target,c=a._cornerIndex;this._oppositeCorner=b[(c+2)%4];this._toggleCornerMarkers(0,c)},_onMarkerDragEnd:function(d){var b=d.target,c,a;if(b===this._moveMarker){c=this._shape.getBounds();a=c.getCenter();b.setLatLng(a)}this._toggleCornerMarkers(1);this._repositionCornerMarkers();L.Edit.SimpleShape.prototype._onMarkerDragEnd.call(this,d)},_move:function(d){var b=this._shape._defaultShape?this._shape._defaultShape():this._shape.getLatLngs(),g=this._shape.getBounds(),a=g.getCenter(),h,f=[];for(var e=0,c=b.length;e<c;e++){h=[b[e].lat-a.lat,b[e].lng-a.lng];f.push([d.lat+h[0],d.lng+h[1]])}this._shape.setLatLngs(f);this._repositionCornerMarkers();this._map.fire(L.Draw.Event.EDITMOVE,{layer:this._shape})},_resize:function(b){var a;this._shape.setBounds(L.latLngBounds(b,this._oppositeCorner));a=this._shape.getBounds();this._moveMarker.setLatLng(a.getCenter());this._map.fire(L.Draw.Event.EDITRESIZE,{layer:this._shape})},_getCorners:function(){var c=this._shape.getBounds(),b=c.getNorthWest(),e=c.getNorthEast(),d=c.getSouthEast(),a=c.getSouthWest();return[b,e,d,a]},_toggleCornerMarkers:function(b){for(var c=0,a=this._resizeMarkers.length;c<a;c++){this._resizeMarkers[c].setOpacity(b)}},_repositionCornerMarkers:function(){var b=this._getCorners();for(var c=0,a=this._resizeMarkers.length;c<a;c++){this._resizeMarkers[c].setLatLng(b[c])}}});L.Rectangle.addInitHook(function(){if(L.Edit.Rectangle){this.editing=new L.Edit.Rectangle(this);if(this.options.editable){this.editing.enable()}}});