123456789101112131415161718192021222324252627282930313233343536373839404142 |
- L.Edit = L.Edit || {};
- L.Edit.Painting = L.Edit.SimpleShape.extend({
- _createMoveMarker: function () {
- var center = this._shape.getLatLng();
- this._moveMarker = this._createMarker(center, this.options.moveIcon);
- },
- _createResizeMarker: function () {
- var center = this._shape.getLatLng(),
- resizemarkerPoint = this._getResizeMarkerPoint(center);
- this._resizeMarkers = [];
- this._resizeMarkers.push(this._createMarker(resizemarkerPoint, this.options.resizeIcon));
- },
- _getResizeMarkerPoint: function (latlng) {
- // From L.shape.getBounds()
- var delta = this._shape._radius * Math.cos(Math.PI / 4),
- point = this._map.project(latlng);
- return this._map.unproject([point.x + delta, point.y - delta]);
- },
- _move: function (latlng) {
- var resizemarkerPoint = this._getResizeMarkerPoint(latlng);
- // Move the resize marker
- this._resizeMarkers[0].setLatLng(resizemarkerPoint);
- // Move the circle
- this._shape.setLatLng(latlng);
- },
- _resize: function (latlng) {
- var moveLatLng = this._moveMarker.getLatLng(),
- radius = moveLatLng.distanceTo(latlng);
- this._shape.setRadius(radius);
- }
- });
|