Sha256: 2632bd0914304c73a0eed03e028b7a381fbbd28b1184348f1df911fb282f9b02

Contents?: true

Size: 1.07 KB

Versions: 6

Compression:

Stored size: 1.07 KB

Contents

L.Draw.Rectangle = L.Draw.SimpleShape.extend({
	statics: {
		TYPE: 'rectangle'
	},

	options: {
		shapeOptions: {
			stroke: true,
			color: '#f06eaa',
			weight: 4,
			opacity: 0.5,
			fill: true,
			fillColor: null, //same as color by default
			fillOpacity: 0.2,
			clickable: true
		}
	},

	initialize: function (map, options) {
		// Save the type so super can fire, need to do this as cannot do this.TYPE :(
		this.type = L.Draw.Rectangle.TYPE;

		this._initialLabelText = L.drawLocal.draw.handlers.rectangle.tooltip.start;

		L.Draw.SimpleShape.prototype.initialize.call(this, map, options);
	},

	_drawShape: function (latlng) {
		if (!this._shape) {
			this._shape = new L.Rectangle(new L.LatLngBounds(this._startLatLng, latlng), this.options.shapeOptions);
			this._map.addLayer(this._shape);
		} else {
			this._shape.setBounds(new L.LatLngBounds(this._startLatLng, latlng));
		}
	},

	_fireCreatedEvent: function () {
		var rectangle = new L.Rectangle(this._shape.getBounds(), this.options.shapeOptions);
		L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, rectangle);
	}
});

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
leaflet-js-0.8.dev2 lib/leaflet.draw/src/draw/handler/Draw.Rectangle.js
leaflet-js-0.7.0.4 lib/leaflet.draw/src/draw/handler/Draw.Rectangle.js
leaflet-js-0.7.0.3 lib/leaflet.draw/src/draw/handler/Draw.Rectangle.js
leaflet-js-0.7.0.2 lib/leaflet.draw/src/draw/handler/Draw.Rectangle.js
leaflet-js-0.7.0.1 lib/leaflet.draw/src/draw/handler/Draw.Rectangle.js
leaflet-js-0.7.0 lib/leaflet.draw/src/draw/handler/Draw.Rectangle.js