decidim 0.26.9 → 0.26.10

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of decidim might be problematic. Click here for more details.

Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/lib/decidim/version.rb +1 -1
  3. data/package-lock.json +7 -7
  4. data/packages/browserslist-config/package.json +1 -1
  5. data/packages/core/node_modules/leaflet/CHANGELOG.md +2191 -0
  6. data/packages/core/node_modules/leaflet/LICENSE +26 -0
  7. data/packages/core/node_modules/leaflet/README.md +55 -0
  8. data/packages/core/node_modules/leaflet/dist/images/layers-2x.png +0 -0
  9. data/packages/core/node_modules/leaflet/dist/images/layers.png +0 -0
  10. data/packages/core/node_modules/leaflet/dist/images/marker-icon-2x.png +0 -0
  11. data/packages/core/node_modules/leaflet/dist/images/marker-icon.png +0 -0
  12. data/packages/core/node_modules/leaflet/dist/images/marker-shadow.png +0 -0
  13. data/packages/core/node_modules/leaflet/dist/leaflet-src.esm.js +14419 -0
  14. data/packages/core/node_modules/leaflet/dist/leaflet-src.esm.js.map +1 -0
  15. data/packages/core/node_modules/leaflet/dist/leaflet-src.js +14512 -0
  16. data/packages/core/node_modules/leaflet/dist/leaflet-src.js.map +1 -0
  17. data/packages/core/node_modules/leaflet/dist/leaflet.css +661 -0
  18. data/packages/core/node_modules/leaflet/dist/leaflet.js +6 -0
  19. data/packages/core/node_modules/leaflet/dist/leaflet.js.map +1 -0
  20. data/packages/core/node_modules/leaflet/package.json +149 -0
  21. data/packages/core/node_modules/leaflet/src/Leaflet.js +24 -0
  22. data/packages/core/node_modules/leaflet/src/control/Control.Attribution.js +148 -0
  23. data/packages/core/node_modules/leaflet/src/control/Control.Layers.js +443 -0
  24. data/packages/core/node_modules/leaflet/src/control/Control.Scale.js +132 -0
  25. data/packages/core/node_modules/leaflet/src/control/Control.Zoom.js +146 -0
  26. data/packages/core/node_modules/leaflet/src/control/Control.js +174 -0
  27. data/packages/core/node_modules/leaflet/src/control/index.js +17 -0
  28. data/packages/core/node_modules/leaflet/src/core/Browser.js +220 -0
  29. data/packages/core/node_modules/leaflet/src/core/Class.js +135 -0
  30. data/packages/core/node_modules/leaflet/src/core/Class.leafdoc +197 -0
  31. data/packages/core/node_modules/leaflet/src/core/Events.js +344 -0
  32. data/packages/core/node_modules/leaflet/src/core/Events.leafdoc +143 -0
  33. data/packages/core/node_modules/leaflet/src/core/Handler.js +57 -0
  34. data/packages/core/node_modules/leaflet/src/core/Util.js +241 -0
  35. data/packages/core/node_modules/leaflet/src/core/index.js +15 -0
  36. data/packages/core/node_modules/leaflet/src/dom/DomEvent.DoubleTap.js +91 -0
  37. data/packages/core/node_modules/leaflet/src/dom/DomEvent.Pointer.js +97 -0
  38. data/packages/core/node_modules/leaflet/src/dom/DomEvent.js +315 -0
  39. data/packages/core/node_modules/leaflet/src/dom/DomUtil.js +349 -0
  40. data/packages/core/node_modules/leaflet/src/dom/Draggable.js +220 -0
  41. data/packages/core/node_modules/leaflet/src/dom/PosAnimation.js +113 -0
  42. data/packages/core/node_modules/leaflet/src/dom/index.js +9 -0
  43. data/packages/core/node_modules/leaflet/src/geo/LatLng.js +137 -0
  44. data/packages/core/node_modules/leaflet/src/geo/LatLngBounds.js +251 -0
  45. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.EPSG3395.js +20 -0
  46. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.EPSG3857.js +27 -0
  47. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.EPSG4326.js +23 -0
  48. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.Earth.js +33 -0
  49. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.Simple.js +36 -0
  50. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.js +139 -0
  51. data/packages/core/node_modules/leaflet/src/geo/crs/index.js +15 -0
  52. data/packages/core/node_modules/leaflet/src/geo/index.js +7 -0
  53. data/packages/core/node_modules/leaflet/src/geo/projection/Projection.LonLat.js +28 -0
  54. data/packages/core/node_modules/leaflet/src/geo/projection/Projection.Mercator.js +49 -0
  55. data/packages/core/node_modules/leaflet/src/geo/projection/Projection.SphericalMercator.js +44 -0
  56. data/packages/core/node_modules/leaflet/src/geo/projection/index.js +26 -0
  57. data/packages/core/node_modules/leaflet/src/geometry/Bounds.js +219 -0
  58. data/packages/core/node_modules/leaflet/src/geometry/LineUtil.js +306 -0
  59. data/packages/core/node_modules/leaflet/src/geometry/Point.js +222 -0
  60. data/packages/core/node_modules/leaflet/src/geometry/PolyUtil.js +129 -0
  61. data/packages/core/node_modules/leaflet/src/geometry/Transformation.js +79 -0
  62. data/packages/core/node_modules/leaflet/src/geometry/index.js +8 -0
  63. data/packages/core/node_modules/leaflet/src/images/layers.svg +1 -0
  64. data/packages/core/node_modules/leaflet/src/images/logo.svg +1 -0
  65. data/packages/core/node_modules/leaflet/src/images/marker.svg +1 -0
  66. data/packages/core/node_modules/leaflet/src/layer/DivOverlay.js +348 -0
  67. data/packages/core/node_modules/leaflet/src/layer/FeatureGroup.js +94 -0
  68. data/packages/core/node_modules/leaflet/src/layer/GeoJSON.js +452 -0
  69. data/packages/core/node_modules/leaflet/src/layer/ImageOverlay.js +270 -0
  70. data/packages/core/node_modules/leaflet/src/layer/Layer.Interactive.leafdoc +39 -0
  71. data/packages/core/node_modules/leaflet/src/layer/Layer.js +275 -0
  72. data/packages/core/node_modules/leaflet/src/layer/LayerGroup.js +159 -0
  73. data/packages/core/node_modules/leaflet/src/layer/Popup.js +506 -0
  74. data/packages/core/node_modules/leaflet/src/layer/SVGOverlay.js +50 -0
  75. data/packages/core/node_modules/leaflet/src/layer/Tooltip.js +444 -0
  76. data/packages/core/node_modules/leaflet/src/layer/VideoOverlay.js +106 -0
  77. data/packages/core/node_modules/leaflet/src/layer/index.js +24 -0
  78. data/packages/core/node_modules/leaflet/src/layer/marker/DivIcon.js +74 -0
  79. data/packages/core/node_modules/leaflet/src/layer/marker/Icon.Default.js +66 -0
  80. data/packages/core/node_modules/leaflet/src/layer/marker/Icon.js +165 -0
  81. data/packages/core/node_modules/leaflet/src/layer/marker/Marker.Drag.js +161 -0
  82. data/packages/core/node_modules/leaflet/src/layer/marker/Marker.js +419 -0
  83. data/packages/core/node_modules/leaflet/src/layer/marker/index.js +8 -0
  84. data/packages/core/node_modules/leaflet/src/layer/tile/GridLayer.js +923 -0
  85. data/packages/core/node_modules/leaflet/src/layer/tile/TileLayer.WMS.js +137 -0
  86. data/packages/core/node_modules/leaflet/src/layer/tile/TileLayer.js +289 -0
  87. data/packages/core/node_modules/leaflet/src/layer/tile/index.js +6 -0
  88. data/packages/core/node_modules/leaflet/src/layer/vector/Canvas.js +492 -0
  89. data/packages/core/node_modules/leaflet/src/layer/vector/Circle.js +113 -0
  90. data/packages/core/node_modules/leaflet/src/layer/vector/CircleMarker.js +109 -0
  91. data/packages/core/node_modules/leaflet/src/layer/vector/Path.js +148 -0
  92. data/packages/core/node_modules/leaflet/src/layer/vector/Polygon.js +159 -0
  93. data/packages/core/node_modules/leaflet/src/layer/vector/Polyline.js +307 -0
  94. data/packages/core/node_modules/leaflet/src/layer/vector/Rectangle.js +57 -0
  95. data/packages/core/node_modules/leaflet/src/layer/vector/Renderer.getRenderer.js +45 -0
  96. data/packages/core/node_modules/leaflet/src/layer/vector/Renderer.js +133 -0
  97. data/packages/core/node_modules/leaflet/src/layer/vector/SVG.Util.js +39 -0
  98. data/packages/core/node_modules/leaflet/src/layer/vector/SVG.VML.js +144 -0
  99. data/packages/core/node_modules/leaflet/src/layer/vector/SVG.js +207 -0
  100. data/packages/core/node_modules/leaflet/src/layer/vector/index.js +14 -0
  101. data/packages/core/node_modules/leaflet/src/map/Map.js +1751 -0
  102. data/packages/core/node_modules/leaflet/src/map/Map.methodOptions.leafdoc +112 -0
  103. data/packages/core/node_modules/leaflet/src/map/handler/Map.BoxZoom.js +152 -0
  104. data/packages/core/node_modules/leaflet/src/map/handler/Map.DoubleClickZoom.js +55 -0
  105. data/packages/core/node_modules/leaflet/src/map/handler/Map.Drag.js +235 -0
  106. data/packages/core/node_modules/leaflet/src/map/handler/Map.Keyboard.js +183 -0
  107. data/packages/core/node_modules/leaflet/src/map/handler/Map.ScrollWheelZoom.js +91 -0
  108. data/packages/core/node_modules/leaflet/src/map/handler/Map.TapHold.js +102 -0
  109. data/packages/core/node_modules/leaflet/src/map/handler/Map.TouchZoom.js +130 -0
  110. data/packages/core/node_modules/leaflet/src/map/index.js +17 -0
  111. data/packages/core/package.json +1 -1
  112. data/packages/dev/package.json +1 -1
  113. data/packages/elections/package.json +1 -1
  114. data/packages/eslint-config/package.json +1 -1
  115. data/packages/stylelint-config/package.json +1 -1
  116. data/packages/webpacker/package.json +1 -1
  117. metadata +148 -42
@@ -0,0 +1,220 @@
1
+ import {Evented} from '../core/Events';
2
+ import Browser from '../core/Browser';
3
+ import * as DomEvent from './DomEvent';
4
+ import * as DomUtil from './DomUtil';
5
+ import * as Util from '../core/Util';
6
+ import {Point} from '../geometry/Point';
7
+
8
+ /*
9
+ * @class Draggable
10
+ * @aka L.Draggable
11
+ * @inherits Evented
12
+ *
13
+ * A class for making DOM elements draggable (including touch support).
14
+ * Used internally for map and marker dragging. Only works for elements
15
+ * that were positioned with [`L.DomUtil.setPosition`](#domutil-setposition).
16
+ *
17
+ * @example
18
+ * ```js
19
+ * var draggable = new L.Draggable(elementToDrag);
20
+ * draggable.enable();
21
+ * ```
22
+ */
23
+
24
+ var START = Browser.touch ? 'touchstart mousedown' : 'mousedown';
25
+
26
+ export var Draggable = Evented.extend({
27
+
28
+ options: {
29
+ // @section
30
+ // @aka Draggable options
31
+ // @option clickTolerance: Number = 3
32
+ // The max number of pixels a user can shift the mouse pointer during a click
33
+ // for it to be considered a valid click (as opposed to a mouse drag).
34
+ clickTolerance: 3
35
+ },
36
+
37
+ // @constructor L.Draggable(el: HTMLElement, dragHandle?: HTMLElement, preventOutline?: Boolean, options?: Draggable options)
38
+ // Creates a `Draggable` object for moving `el` when you start dragging the `dragHandle` element (equals `el` itself by default).
39
+ initialize: function (element, dragStartTarget, preventOutline, options) {
40
+ Util.setOptions(this, options);
41
+
42
+ this._element = element;
43
+ this._dragStartTarget = dragStartTarget || element;
44
+ this._preventOutline = preventOutline;
45
+ },
46
+
47
+ // @method enable()
48
+ // Enables the dragging ability
49
+ enable: function () {
50
+ if (this._enabled) { return; }
51
+
52
+ DomEvent.on(this._dragStartTarget, START, this._onDown, this);
53
+
54
+ this._enabled = true;
55
+ },
56
+
57
+ // @method disable()
58
+ // Disables the dragging ability
59
+ disable: function () {
60
+ if (!this._enabled) { return; }
61
+
62
+ // If we're currently dragging this draggable,
63
+ // disabling it counts as first ending the drag.
64
+ if (Draggable._dragging === this) {
65
+ this.finishDrag(true);
66
+ }
67
+
68
+ DomEvent.off(this._dragStartTarget, START, this._onDown, this);
69
+
70
+ this._enabled = false;
71
+ this._moved = false;
72
+ },
73
+
74
+ _onDown: function (e) {
75
+ // Ignore the event if disabled; this happens in IE11
76
+ // under some circumstances, see #3666.
77
+ if (!this._enabled) { return; }
78
+
79
+ this._moved = false;
80
+
81
+ if (DomUtil.hasClass(this._element, 'leaflet-zoom-anim')) { return; }
82
+
83
+ if (e.touches && e.touches.length !== 1) {
84
+ // Finish dragging to avoid conflict with touchZoom
85
+ if (Draggable._dragging === this) {
86
+ this.finishDrag();
87
+ }
88
+ return;
89
+ }
90
+
91
+ if (Draggable._dragging || e.shiftKey || ((e.which !== 1) && (e.button !== 1) && !e.touches)) { return; }
92
+ Draggable._dragging = this; // Prevent dragging multiple objects at once.
93
+
94
+ if (this._preventOutline) {
95
+ DomUtil.preventOutline(this._element);
96
+ }
97
+
98
+ DomUtil.disableImageDrag();
99
+ DomUtil.disableTextSelection();
100
+
101
+ if (this._moving) { return; }
102
+
103
+ // @event down: Event
104
+ // Fired when a drag is about to start.
105
+ this.fire('down');
106
+
107
+ var first = e.touches ? e.touches[0] : e,
108
+ sizedParent = DomUtil.getSizedParentNode(this._element);
109
+
110
+ this._startPoint = new Point(first.clientX, first.clientY);
111
+ this._startPos = DomUtil.getPosition(this._element);
112
+
113
+ // Cache the scale, so that we can continuously compensate for it during drag (_onMove).
114
+ this._parentScale = DomUtil.getScale(sizedParent);
115
+
116
+ var mouseevent = e.type === 'mousedown';
117
+ DomEvent.on(document, mouseevent ? 'mousemove' : 'touchmove', this._onMove, this);
118
+ DomEvent.on(document, mouseevent ? 'mouseup' : 'touchend touchcancel', this._onUp, this);
119
+ },
120
+
121
+ _onMove: function (e) {
122
+ // Ignore the event if disabled; this happens in IE11
123
+ // under some circumstances, see #3666.
124
+ if (!this._enabled) { return; }
125
+
126
+ if (e.touches && e.touches.length > 1) {
127
+ this._moved = true;
128
+ return;
129
+ }
130
+
131
+ var first = (e.touches && e.touches.length === 1 ? e.touches[0] : e),
132
+ offset = new Point(first.clientX, first.clientY)._subtract(this._startPoint);
133
+
134
+ if (!offset.x && !offset.y) { return; }
135
+ if (Math.abs(offset.x) + Math.abs(offset.y) < this.options.clickTolerance) { return; }
136
+
137
+ // We assume that the parent container's position, border and scale do not change for the duration of the drag.
138
+ // Therefore there is no need to account for the position and border (they are eliminated by the subtraction)
139
+ // and we can use the cached value for the scale.
140
+ offset.x /= this._parentScale.x;
141
+ offset.y /= this._parentScale.y;
142
+
143
+ DomEvent.preventDefault(e);
144
+
145
+ if (!this._moved) {
146
+ // @event dragstart: Event
147
+ // Fired when a drag starts
148
+ this.fire('dragstart');
149
+
150
+ this._moved = true;
151
+
152
+ DomUtil.addClass(document.body, 'leaflet-dragging');
153
+
154
+ this._lastTarget = e.target || e.srcElement;
155
+ // IE and Edge do not give the <use> element, so fetch it
156
+ // if necessary
157
+ if (window.SVGElementInstance && this._lastTarget instanceof window.SVGElementInstance) {
158
+ this._lastTarget = this._lastTarget.correspondingUseElement;
159
+ }
160
+ DomUtil.addClass(this._lastTarget, 'leaflet-drag-target');
161
+ }
162
+
163
+ this._newPos = this._startPos.add(offset);
164
+ this._moving = true;
165
+
166
+ this._lastEvent = e;
167
+ this._updatePosition();
168
+ },
169
+
170
+ _updatePosition: function () {
171
+ var e = {originalEvent: this._lastEvent};
172
+
173
+ // @event predrag: Event
174
+ // Fired continuously during dragging *before* each corresponding
175
+ // update of the element's position.
176
+ this.fire('predrag', e);
177
+ DomUtil.setPosition(this._element, this._newPos);
178
+
179
+ // @event drag: Event
180
+ // Fired continuously during dragging.
181
+ this.fire('drag', e);
182
+ },
183
+
184
+ _onUp: function () {
185
+ // Ignore the event if disabled; this happens in IE11
186
+ // under some circumstances, see #3666.
187
+ if (!this._enabled) { return; }
188
+ this.finishDrag();
189
+ },
190
+
191
+ finishDrag: function (noInertia) {
192
+ DomUtil.removeClass(document.body, 'leaflet-dragging');
193
+
194
+ if (this._lastTarget) {
195
+ DomUtil.removeClass(this._lastTarget, 'leaflet-drag-target');
196
+ this._lastTarget = null;
197
+ }
198
+
199
+ DomEvent.off(document, 'mousemove touchmove', this._onMove, this);
200
+ DomEvent.off(document, 'mouseup touchend touchcancel', this._onUp, this);
201
+
202
+ DomUtil.enableImageDrag();
203
+ DomUtil.enableTextSelection();
204
+
205
+ var fireDragend = this._moved && this._moving;
206
+
207
+ this._moving = false;
208
+ Draggable._dragging = false;
209
+
210
+ if (fireDragend) {
211
+ // @event dragend: DragEndEvent
212
+ // Fired when the drag ends.
213
+ this.fire('dragend', {
214
+ noInertia: noInertia,
215
+ distance: this._newPos.distanceTo(this._startPos)
216
+ });
217
+ }
218
+ }
219
+
220
+ });
@@ -0,0 +1,113 @@
1
+ import * as Util from '../core/Util';
2
+ import {Evented} from '../core/Events';
3
+ import * as DomUtil from '../dom/DomUtil';
4
+
5
+
6
+ /*
7
+ * @class PosAnimation
8
+ * @aka L.PosAnimation
9
+ * @inherits Evented
10
+ * Used internally for panning animations, utilizing CSS3 Transitions for modern browsers and a timer fallback for IE6-9.
11
+ *
12
+ * @example
13
+ * ```js
14
+ * var myPositionMarker = L.marker([48.864716, 2.294694]).addTo(map);
15
+ *
16
+ * myPositionMarker.on("click", function() {
17
+ * var pos = map.latLngToLayerPoint(myPositionMarker.getLatLng());
18
+ * pos.y -= 25;
19
+ * var fx = new L.PosAnimation();
20
+ *
21
+ * fx.once('end',function() {
22
+ * pos.y += 25;
23
+ * fx.run(myPositionMarker._icon, pos, 0.8);
24
+ * });
25
+ *
26
+ * fx.run(myPositionMarker._icon, pos, 0.3);
27
+ * });
28
+ *
29
+ * ```
30
+ *
31
+ * @constructor L.PosAnimation()
32
+ * Creates a `PosAnimation` object.
33
+ *
34
+ */
35
+
36
+ export var PosAnimation = Evented.extend({
37
+
38
+ // @method run(el: HTMLElement, newPos: Point, duration?: Number, easeLinearity?: Number)
39
+ // Run an animation of a given element to a new position, optionally setting
40
+ // duration in seconds (`0.25` by default) and easing linearity factor (3rd
41
+ // argument of the [cubic bezier curve](https://cubic-bezier.com/#0,0,.5,1),
42
+ // `0.5` by default).
43
+ run: function (el, newPos, duration, easeLinearity) {
44
+ this.stop();
45
+
46
+ this._el = el;
47
+ this._inProgress = true;
48
+ this._duration = duration || 0.25;
49
+ this._easeOutPower = 1 / Math.max(easeLinearity || 0.5, 0.2);
50
+
51
+ this._startPos = DomUtil.getPosition(el);
52
+ this._offset = newPos.subtract(this._startPos);
53
+ this._startTime = +new Date();
54
+
55
+ // @event start: Event
56
+ // Fired when the animation starts
57
+ this.fire('start');
58
+
59
+ this._animate();
60
+ },
61
+
62
+ // @method stop()
63
+ // Stops the animation (if currently running).
64
+ stop: function () {
65
+ if (!this._inProgress) { return; }
66
+
67
+ this._step(true);
68
+ this._complete();
69
+ },
70
+
71
+ _animate: function () {
72
+ // animation loop
73
+ this._animId = Util.requestAnimFrame(this._animate, this);
74
+ this._step();
75
+ },
76
+
77
+ _step: function (round) {
78
+ var elapsed = (+new Date()) - this._startTime,
79
+ duration = this._duration * 1000;
80
+
81
+ if (elapsed < duration) {
82
+ this._runFrame(this._easeOut(elapsed / duration), round);
83
+ } else {
84
+ this._runFrame(1);
85
+ this._complete();
86
+ }
87
+ },
88
+
89
+ _runFrame: function (progress, round) {
90
+ var pos = this._startPos.add(this._offset.multiplyBy(progress));
91
+ if (round) {
92
+ pos._round();
93
+ }
94
+ DomUtil.setPosition(this._el, pos);
95
+
96
+ // @event step: Event
97
+ // Fired continuously during the animation.
98
+ this.fire('step');
99
+ },
100
+
101
+ _complete: function () {
102
+ Util.cancelAnimFrame(this._animId);
103
+
104
+ this._inProgress = false;
105
+ // @event end: Event
106
+ // Fired when the animation ends.
107
+ this.fire('end');
108
+ },
109
+
110
+ _easeOut: function (t) {
111
+ return 1 - Math.pow(1 - t, this._easeOutPower);
112
+ }
113
+ });
@@ -0,0 +1,9 @@
1
+ export {PosAnimation} from './PosAnimation';
2
+
3
+ import * as DomEvent from './DomEvent';
4
+ export {DomEvent};
5
+
6
+ import * as DomUtil from './DomUtil';
7
+ export {DomUtil};
8
+
9
+ export {Draggable} from './Draggable';
@@ -0,0 +1,137 @@
1
+ import * as Util from '../core/Util';
2
+ import {Earth} from './crs/CRS.Earth';
3
+ import {toLatLngBounds} from './LatLngBounds';
4
+
5
+ /* @class LatLng
6
+ * @aka L.LatLng
7
+ *
8
+ * Represents a geographical point with a certain latitude and longitude.
9
+ *
10
+ * @example
11
+ *
12
+ * ```
13
+ * var latlng = L.latLng(50.5, 30.5);
14
+ * ```
15
+ *
16
+ * All Leaflet methods that accept LatLng objects also accept them in a simple Array form and simple object form (unless noted otherwise), so these lines are equivalent:
17
+ *
18
+ * ```
19
+ * map.panTo([50, 30]);
20
+ * map.panTo({lon: 30, lat: 50});
21
+ * map.panTo({lat: 50, lng: 30});
22
+ * map.panTo(L.latLng(50, 30));
23
+ * ```
24
+ *
25
+ * Note that `LatLng` does not inherit from Leaflet's `Class` object,
26
+ * which means new classes can't inherit from it, and new methods
27
+ * can't be added to it with the `include` function.
28
+ */
29
+
30
+ export function LatLng(lat, lng, alt) {
31
+ if (isNaN(lat) || isNaN(lng)) {
32
+ throw new Error('Invalid LatLng object: (' + lat + ', ' + lng + ')');
33
+ }
34
+
35
+ // @property lat: Number
36
+ // Latitude in degrees
37
+ this.lat = +lat;
38
+
39
+ // @property lng: Number
40
+ // Longitude in degrees
41
+ this.lng = +lng;
42
+
43
+ // @property alt: Number
44
+ // Altitude in meters (optional)
45
+ if (alt !== undefined) {
46
+ this.alt = +alt;
47
+ }
48
+ }
49
+
50
+ LatLng.prototype = {
51
+ // @method equals(otherLatLng: LatLng, maxMargin?: Number): Boolean
52
+ // Returns `true` if the given `LatLng` point is at the same position (within a small margin of error). The margin of error can be overridden by setting `maxMargin` to a small number.
53
+ equals: function (obj, maxMargin) {
54
+ if (!obj) { return false; }
55
+
56
+ obj = toLatLng(obj);
57
+
58
+ var margin = Math.max(
59
+ Math.abs(this.lat - obj.lat),
60
+ Math.abs(this.lng - obj.lng));
61
+
62
+ return margin <= (maxMargin === undefined ? 1.0E-9 : maxMargin);
63
+ },
64
+
65
+ // @method toString(): String
66
+ // Returns a string representation of the point (for debugging purposes).
67
+ toString: function (precision) {
68
+ return 'LatLng(' +
69
+ Util.formatNum(this.lat, precision) + ', ' +
70
+ Util.formatNum(this.lng, precision) + ')';
71
+ },
72
+
73
+ // @method distanceTo(otherLatLng: LatLng): Number
74
+ // Returns the distance (in meters) to the given `LatLng` calculated using the [Spherical Law of Cosines](https://en.wikipedia.org/wiki/Spherical_law_of_cosines).
75
+ distanceTo: function (other) {
76
+ return Earth.distance(this, toLatLng(other));
77
+ },
78
+
79
+ // @method wrap(): LatLng
80
+ // Returns a new `LatLng` object with the longitude wrapped so it's always between -180 and +180 degrees.
81
+ wrap: function () {
82
+ return Earth.wrapLatLng(this);
83
+ },
84
+
85
+ // @method toBounds(sizeInMeters: Number): LatLngBounds
86
+ // Returns a new `LatLngBounds` object in which each boundary is `sizeInMeters/2` meters apart from the `LatLng`.
87
+ toBounds: function (sizeInMeters) {
88
+ var latAccuracy = 180 * sizeInMeters / 40075017,
89
+ lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);
90
+
91
+ return toLatLngBounds(
92
+ [this.lat - latAccuracy, this.lng - lngAccuracy],
93
+ [this.lat + latAccuracy, this.lng + lngAccuracy]);
94
+ },
95
+
96
+ clone: function () {
97
+ return new LatLng(this.lat, this.lng, this.alt);
98
+ }
99
+ };
100
+
101
+
102
+
103
+ // @factory L.latLng(latitude: Number, longitude: Number, altitude?: Number): LatLng
104
+ // Creates an object representing a geographical point with the given latitude and longitude (and optionally altitude).
105
+
106
+ // @alternative
107
+ // @factory L.latLng(coords: Array): LatLng
108
+ // Expects an array of the form `[Number, Number]` or `[Number, Number, Number]` instead.
109
+
110
+ // @alternative
111
+ // @factory L.latLng(coords: Object): LatLng
112
+ // Expects an plain object of the form `{lat: Number, lng: Number}` or `{lat: Number, lng: Number, alt: Number}` instead.
113
+
114
+ export function toLatLng(a, b, c) {
115
+ if (a instanceof LatLng) {
116
+ return a;
117
+ }
118
+ if (Util.isArray(a) && typeof a[0] !== 'object') {
119
+ if (a.length === 3) {
120
+ return new LatLng(a[0], a[1], a[2]);
121
+ }
122
+ if (a.length === 2) {
123
+ return new LatLng(a[0], a[1]);
124
+ }
125
+ return null;
126
+ }
127
+ if (a === undefined || a === null) {
128
+ return a;
129
+ }
130
+ if (typeof a === 'object' && 'lat' in a) {
131
+ return new LatLng(a.lat, 'lng' in a ? a.lng : a.lon, a.alt);
132
+ }
133
+ if (b === undefined) {
134
+ return null;
135
+ }
136
+ return new LatLng(a, b, c);
137
+ }