summaryrefslogtreecommitdiffstats
path: root/debian/missing-sources/leaflet.js/layer/vector/Rectangle.js
diff options
context:
space:
mode:
Diffstat (limited to 'debian/missing-sources/leaflet.js/layer/vector/Rectangle.js')
-rw-r--r--debian/missing-sources/leaflet.js/layer/vector/Rectangle.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/debian/missing-sources/leaflet.js/layer/vector/Rectangle.js b/debian/missing-sources/leaflet.js/layer/vector/Rectangle.js
new file mode 100644
index 0000000..ceec041
--- /dev/null
+++ b/debian/missing-sources/leaflet.js/layer/vector/Rectangle.js
@@ -0,0 +1,57 @@
+import {Polygon} from './Polygon';
+import {toLatLngBounds} from '../../geo/LatLngBounds';
+
+/*
+ * L.Rectangle extends Polygon and creates a rectangle when passed a LatLngBounds object.
+ */
+
+/*
+ * @class Rectangle
+ * @aka L.Rectangle
+ * @inherits Polygon
+ *
+ * A class for drawing rectangle overlays on a map. Extends `Polygon`.
+ *
+ * @example
+ *
+ * ```js
+ * // define rectangle geographical bounds
+ * var bounds = [[54.559322, -5.767822], [56.1210604, -3.021240]];
+ *
+ * // create an orange rectangle
+ * L.rectangle(bounds, {color: "#ff7800", weight: 1}).addTo(map);
+ *
+ * // zoom the map to the rectangle bounds
+ * map.fitBounds(bounds);
+ * ```
+ *
+ */
+
+
+export var Rectangle = Polygon.extend({
+ initialize: function (latLngBounds, options) {
+ Polygon.prototype.initialize.call(this, this._boundsToLatLngs(latLngBounds), options);
+ },
+
+ // @method setBounds(latLngBounds: LatLngBounds): this
+ // Redraws the rectangle with the passed bounds.
+ setBounds: function (latLngBounds) {
+ return this.setLatLngs(this._boundsToLatLngs(latLngBounds));
+ },
+
+ _boundsToLatLngs: function (latLngBounds) {
+ latLngBounds = toLatLngBounds(latLngBounds);
+ return [
+ latLngBounds.getSouthWest(),
+ latLngBounds.getNorthWest(),
+ latLngBounds.getNorthEast(),
+ latLngBounds.getSouthEast()
+ ];
+ }
+});
+
+
+// @factory L.rectangle(latLngBounds: LatLngBounds, options?: Polyline options)
+export function rectangle(latLngBounds, options) {
+ return new Rectangle(latLngBounds, options);
+}