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