Sha256: 5c62edbffa71f77062f906c2d43a5465fc876edea74694dcf018c554db7913d4

Contents?: true

Size: 1.49 KB

Versions: 10

Compression:

Stored size: 1.49 KB

Contents

L.Edit = L.Edit || {};

L.Edit.Circle = 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);
	}
});

L.Circle.addInitHook(function () {
	if (L.Edit.Circle) {
		this.editing = new L.Edit.Circle(this);

		if (this.options.editable) {
			this.editing.enable();
		}
	}

	this.on('add', function () {
		if (this.editing && this.editing.enabled()) {
			this.editing.addHooks();
		}
	});

	this.on('remove', function () {
		if (this.editing && this.editing.enabled()) {
			this.editing.removeHooks();
		}
	});
});

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
leaflet-js-0.7.9 vendor/assets/Leaflet.draw/src/edit/handler/Edit.Circle.js
leaflet-js-0.7.8 vendor/assets/Leaflet.draw/src/edit/handler/Edit.Circle.js
leaflet-js-0.7.7 vendor/assets/Leaflet.draw/src/edit/handler/Edit.Circle.js
leaflet-js-0.8.dev2 lib/leaflet.draw/src/edit/handler/Edit.Circle.js
leaflet-js-0.7.0.4 lib/leaflet.draw/src/edit/handler/Edit.Circle.js
leaflet-js-0.7.0.3 lib/leaflet.draw/src/edit/handler/Edit.Circle.js
leaflet-js-0.7.0.2 lib/leaflet.draw/src/edit/handler/Edit.Circle.js
leaflet-js-0.7.0.1 lib/leaflet.draw/src/edit/handler/Edit.Circle.js
leaflet-js-0.7.0 lib/leaflet.draw/src/edit/handler/Edit.Circle.js
leaflet-js-0.6.beta4 lib/leaflet.draw/src/edit/handler/Edit.Circle.js