leaflet-with-dashoffset-canvas-fix 1.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/CHANGELOG.md +2191 -0
  2. package/LICENSE +26 -0
  3. package/README.md +3 -0
  4. package/package.json +149 -0
  5. package/src/Leaflet.js +24 -0
  6. package/src/control/Control.Attribution.js +148 -0
  7. package/src/control/Control.Layers.js +443 -0
  8. package/src/control/Control.Scale.js +132 -0
  9. package/src/control/Control.Zoom.js +146 -0
  10. package/src/control/Control.js +174 -0
  11. package/src/control/index.js +17 -0
  12. package/src/core/Browser.js +220 -0
  13. package/src/core/Class.js +135 -0
  14. package/src/core/Events.js +344 -0
  15. package/src/core/Handler.js +57 -0
  16. package/src/core/Util.js +241 -0
  17. package/src/core/index.js +15 -0
  18. package/src/dom/DomEvent.DoubleTap.js +91 -0
  19. package/src/dom/DomEvent.Pointer.js +97 -0
  20. package/src/dom/DomEvent.js +315 -0
  21. package/src/dom/DomUtil.js +349 -0
  22. package/src/dom/Draggable.js +220 -0
  23. package/src/dom/PosAnimation.js +113 -0
  24. package/src/dom/index.js +9 -0
  25. package/src/geo/LatLng.js +137 -0
  26. package/src/geo/LatLngBounds.js +251 -0
  27. package/src/geo/crs/CRS.EPSG3395.js +20 -0
  28. package/src/geo/crs/CRS.EPSG3857.js +27 -0
  29. package/src/geo/crs/CRS.EPSG4326.js +23 -0
  30. package/src/geo/crs/CRS.Earth.js +33 -0
  31. package/src/geo/crs/CRS.Simple.js +36 -0
  32. package/src/geo/crs/CRS.js +139 -0
  33. package/src/geo/crs/index.js +15 -0
  34. package/src/geo/index.js +7 -0
  35. package/src/geo/projection/Projection.LonLat.js +28 -0
  36. package/src/geo/projection/Projection.Mercator.js +49 -0
  37. package/src/geo/projection/Projection.SphericalMercator.js +44 -0
  38. package/src/geo/projection/index.js +26 -0
  39. package/src/geometry/Bounds.js +219 -0
  40. package/src/geometry/LineUtil.js +306 -0
  41. package/src/geometry/Point.js +222 -0
  42. package/src/geometry/PolyUtil.js +129 -0
  43. package/src/geometry/Transformation.js +79 -0
  44. package/src/geometry/index.js +8 -0
  45. package/src/images/layers.svg +1 -0
  46. package/src/images/logo.svg +1 -0
  47. package/src/images/marker.svg +1 -0
  48. package/src/layer/DivOverlay.js +348 -0
  49. package/src/layer/FeatureGroup.js +94 -0
  50. package/src/layer/GeoJSON.js +452 -0
  51. package/src/layer/ImageOverlay.js +270 -0
  52. package/src/layer/Layer.js +275 -0
  53. package/src/layer/LayerGroup.js +159 -0
  54. package/src/layer/Popup.js +506 -0
  55. package/src/layer/SVGOverlay.js +50 -0
  56. package/src/layer/Tooltip.js +444 -0
  57. package/src/layer/VideoOverlay.js +106 -0
  58. package/src/layer/index.js +24 -0
  59. package/src/layer/marker/DivIcon.js +74 -0
  60. package/src/layer/marker/Icon.Default.js +66 -0
  61. package/src/layer/marker/Icon.js +165 -0
  62. package/src/layer/marker/Marker.Drag.js +161 -0
  63. package/src/layer/marker/Marker.js +419 -0
  64. package/src/layer/marker/index.js +8 -0
  65. package/src/layer/tile/GridLayer.js +923 -0
  66. package/src/layer/tile/TileLayer.WMS.js +137 -0
  67. package/src/layer/tile/TileLayer.js +289 -0
  68. package/src/layer/tile/index.js +6 -0
  69. package/src/layer/vector/Canvas.js +493 -0
  70. package/src/layer/vector/Circle.js +113 -0
  71. package/src/layer/vector/CircleMarker.js +109 -0
  72. package/src/layer/vector/Path.js +148 -0
  73. package/src/layer/vector/Polygon.js +159 -0
  74. package/src/layer/vector/Polyline.js +307 -0
  75. package/src/layer/vector/Rectangle.js +57 -0
  76. package/src/layer/vector/Renderer.getRenderer.js +45 -0
  77. package/src/layer/vector/Renderer.js +133 -0
  78. package/src/layer/vector/SVG.Util.js +39 -0
  79. package/src/layer/vector/SVG.VML.js +144 -0
  80. package/src/layer/vector/SVG.js +207 -0
  81. package/src/layer/vector/index.js +14 -0
  82. package/src/map/Map.js +1751 -0
  83. package/src/map/handler/Map.BoxZoom.js +152 -0
  84. package/src/map/handler/Map.DoubleClickZoom.js +55 -0
  85. package/src/map/handler/Map.Drag.js +235 -0
  86. package/src/map/handler/Map.Keyboard.js +183 -0
  87. package/src/map/handler/Map.ScrollWheelZoom.js +91 -0
  88. package/src/map/handler/Map.TapHold.js +102 -0
  89. package/src/map/handler/Map.TouchZoom.js +130 -0
  90. package/src/map/index.js +17 -0
@@ -0,0 +1,348 @@
1
+ import {Map} from '../map/Map';
2
+ import {Layer} from './Layer';
3
+ import {FeatureGroup} from './FeatureGroup';
4
+ import * as Util from '../core/Util';
5
+ import {toLatLng, LatLng} from '../geo/LatLng';
6
+ import {toPoint} from '../geometry/Point';
7
+ import * as DomUtil from '../dom/DomUtil';
8
+
9
+ /*
10
+ * @class DivOverlay
11
+ * @inherits Interactive layer
12
+ * @aka L.DivOverlay
13
+ * Base model for L.Popup and L.Tooltip. Inherit from it for custom overlays like plugins.
14
+ */
15
+
16
+ // @namespace DivOverlay
17
+ export var DivOverlay = Layer.extend({
18
+
19
+ // @section
20
+ // @aka DivOverlay options
21
+ options: {
22
+ // @option interactive: Boolean = false
23
+ // If true, the popup/tooltip will listen to the mouse events.
24
+ interactive: false,
25
+
26
+ // @option offset: Point = Point(0, 0)
27
+ // The offset of the overlay position.
28
+ offset: [0, 0],
29
+
30
+ // @option className: String = ''
31
+ // A custom CSS class name to assign to the overlay.
32
+ className: '',
33
+
34
+ // @option pane: String = undefined
35
+ // `Map pane` where the overlay will be added.
36
+ pane: undefined,
37
+
38
+ // @option content: String|HTMLElement|Function = ''
39
+ // Sets the HTML content of the overlay while initializing. If a function is passed the source layer will be
40
+ // passed to the function. The function should return a `String` or `HTMLElement` to be used in the overlay.
41
+ content: ''
42
+ },
43
+
44
+ initialize: function (options, source) {
45
+ if (options && (options instanceof LatLng || Util.isArray(options))) {
46
+ this._latlng = toLatLng(options);
47
+ Util.setOptions(this, source);
48
+ } else {
49
+ Util.setOptions(this, options);
50
+ this._source = source;
51
+ }
52
+ if (this.options.content) {
53
+ this._content = this.options.content;
54
+ }
55
+ },
56
+
57
+ // @method openOn(map: Map): this
58
+ // Adds the overlay to the map.
59
+ // Alternative to `map.openPopup(popup)`/`.openTooltip(tooltip)`.
60
+ openOn: function (map) {
61
+ map = arguments.length ? map : this._source._map; // experimental, not the part of public api
62
+ if (!map.hasLayer(this)) {
63
+ map.addLayer(this);
64
+ }
65
+ return this;
66
+ },
67
+
68
+ // @method close(): this
69
+ // Closes the overlay.
70
+ // Alternative to `map.closePopup(popup)`/`.closeTooltip(tooltip)`
71
+ // and `layer.closePopup()`/`.closeTooltip()`.
72
+ close: function () {
73
+ if (this._map) {
74
+ this._map.removeLayer(this);
75
+ }
76
+ return this;
77
+ },
78
+
79
+ // @method toggle(layer?: Layer): this
80
+ // Opens or closes the overlay bound to layer depending on its current state.
81
+ // Argument may be omitted only for overlay bound to layer.
82
+ // Alternative to `layer.togglePopup()`/`.toggleTooltip()`.
83
+ toggle: function (layer) {
84
+ if (this._map) {
85
+ this.close();
86
+ } else {
87
+ if (arguments.length) {
88
+ this._source = layer;
89
+ } else {
90
+ layer = this._source;
91
+ }
92
+ this._prepareOpen();
93
+
94
+ // open the overlay on the map
95
+ this.openOn(layer._map);
96
+ }
97
+ return this;
98
+ },
99
+
100
+ onAdd: function (map) {
101
+ this._zoomAnimated = map._zoomAnimated;
102
+
103
+ if (!this._container) {
104
+ this._initLayout();
105
+ }
106
+
107
+ if (map._fadeAnimated) {
108
+ DomUtil.setOpacity(this._container, 0);
109
+ }
110
+
111
+ clearTimeout(this._removeTimeout);
112
+ this.getPane().appendChild(this._container);
113
+ this.update();
114
+
115
+ if (map._fadeAnimated) {
116
+ DomUtil.setOpacity(this._container, 1);
117
+ }
118
+
119
+ this.bringToFront();
120
+
121
+ if (this.options.interactive) {
122
+ DomUtil.addClass(this._container, 'leaflet-interactive');
123
+ this.addInteractiveTarget(this._container);
124
+ }
125
+ },
126
+
127
+ onRemove: function (map) {
128
+ if (map._fadeAnimated) {
129
+ DomUtil.setOpacity(this._container, 0);
130
+ this._removeTimeout = setTimeout(Util.bind(DomUtil.remove, undefined, this._container), 200);
131
+ } else {
132
+ DomUtil.remove(this._container);
133
+ }
134
+
135
+ if (this.options.interactive) {
136
+ DomUtil.removeClass(this._container, 'leaflet-interactive');
137
+ this.removeInteractiveTarget(this._container);
138
+ }
139
+ },
140
+
141
+ // @namespace DivOverlay
142
+ // @method getLatLng: LatLng
143
+ // Returns the geographical point of the overlay.
144
+ getLatLng: function () {
145
+ return this._latlng;
146
+ },
147
+
148
+ // @method setLatLng(latlng: LatLng): this
149
+ // Sets the geographical point where the overlay will open.
150
+ setLatLng: function (latlng) {
151
+ this._latlng = toLatLng(latlng);
152
+ if (this._map) {
153
+ this._updatePosition();
154
+ this._adjustPan();
155
+ }
156
+ return this;
157
+ },
158
+
159
+ // @method getContent: String|HTMLElement
160
+ // Returns the content of the overlay.
161
+ getContent: function () {
162
+ return this._content;
163
+ },
164
+
165
+ // @method setContent(htmlContent: String|HTMLElement|Function): this
166
+ // Sets the HTML content of the overlay. If a function is passed the source layer will be passed to the function.
167
+ // The function should return a `String` or `HTMLElement` to be used in the overlay.
168
+ setContent: function (content) {
169
+ this._content = content;
170
+ this.update();
171
+ return this;
172
+ },
173
+
174
+ // @method getElement: String|HTMLElement
175
+ // Returns the HTML container of the overlay.
176
+ getElement: function () {
177
+ return this._container;
178
+ },
179
+
180
+ // @method update: null
181
+ // Updates the overlay content, layout and position. Useful for updating the overlay after something inside changed, e.g. image loaded.
182
+ update: function () {
183
+ if (!this._map) { return; }
184
+
185
+ this._container.style.visibility = 'hidden';
186
+
187
+ this._updateContent();
188
+ this._updateLayout();
189
+ this._updatePosition();
190
+
191
+ this._container.style.visibility = '';
192
+
193
+ this._adjustPan();
194
+ },
195
+
196
+ getEvents: function () {
197
+ var events = {
198
+ zoom: this._updatePosition,
199
+ viewreset: this._updatePosition
200
+ };
201
+
202
+ if (this._zoomAnimated) {
203
+ events.zoomanim = this._animateZoom;
204
+ }
205
+ return events;
206
+ },
207
+
208
+ // @method isOpen: Boolean
209
+ // Returns `true` when the overlay is visible on the map.
210
+ isOpen: function () {
211
+ return !!this._map && this._map.hasLayer(this);
212
+ },
213
+
214
+ // @method bringToFront: this
215
+ // Brings this overlay in front of other overlays (in the same map pane).
216
+ bringToFront: function () {
217
+ if (this._map) {
218
+ DomUtil.toFront(this._container);
219
+ }
220
+ return this;
221
+ },
222
+
223
+ // @method bringToBack: this
224
+ // Brings this overlay to the back of other overlays (in the same map pane).
225
+ bringToBack: function () {
226
+ if (this._map) {
227
+ DomUtil.toBack(this._container);
228
+ }
229
+ return this;
230
+ },
231
+
232
+ // prepare bound overlay to open: update latlng pos / content source (for FeatureGroup)
233
+ _prepareOpen: function (latlng) {
234
+ var source = this._source;
235
+ if (!source._map) { return false; }
236
+
237
+ if (source instanceof FeatureGroup) {
238
+ source = null;
239
+ var layers = this._source._layers;
240
+ for (var id in layers) {
241
+ if (layers[id]._map) {
242
+ source = layers[id];
243
+ break;
244
+ }
245
+ }
246
+ if (!source) { return false; } // Unable to get source layer.
247
+
248
+ // set overlay source to this layer
249
+ this._source = source;
250
+ }
251
+
252
+ if (!latlng) {
253
+ if (source.getCenter) {
254
+ latlng = source.getCenter();
255
+ } else if (source.getLatLng) {
256
+ latlng = source.getLatLng();
257
+ } else if (source.getBounds) {
258
+ latlng = source.getBounds().getCenter();
259
+ } else {
260
+ throw new Error('Unable to get source layer LatLng.');
261
+ }
262
+ }
263
+ this.setLatLng(latlng);
264
+
265
+ if (this._map) {
266
+ // update the overlay (content, layout, etc...)
267
+ this.update();
268
+ }
269
+
270
+ return true;
271
+ },
272
+
273
+ _updateContent: function () {
274
+ if (!this._content) { return; }
275
+
276
+ var node = this._contentNode;
277
+ var content = (typeof this._content === 'function') ? this._content(this._source || this) : this._content;
278
+
279
+ if (typeof content === 'string') {
280
+ node.innerHTML = content;
281
+ } else {
282
+ while (node.hasChildNodes()) {
283
+ node.removeChild(node.firstChild);
284
+ }
285
+ node.appendChild(content);
286
+ }
287
+
288
+ // @namespace DivOverlay
289
+ // @section DivOverlay events
290
+ // @event contentupdate: Event
291
+ // Fired when the content of the overlay is updated
292
+ this.fire('contentupdate');
293
+ },
294
+
295
+ _updatePosition: function () {
296
+ if (!this._map) { return; }
297
+
298
+ var pos = this._map.latLngToLayerPoint(this._latlng),
299
+ offset = toPoint(this.options.offset),
300
+ anchor = this._getAnchor();
301
+
302
+ if (this._zoomAnimated) {
303
+ DomUtil.setPosition(this._container, pos.add(anchor));
304
+ } else {
305
+ offset = offset.add(pos).add(anchor);
306
+ }
307
+
308
+ var bottom = this._containerBottom = -offset.y,
309
+ left = this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x;
310
+
311
+ // bottom position the overlay in case the height of the overlay changes (images loading etc)
312
+ this._container.style.bottom = bottom + 'px';
313
+ this._container.style.left = left + 'px';
314
+ },
315
+
316
+ _getAnchor: function () {
317
+ return [0, 0];
318
+ }
319
+
320
+ });
321
+
322
+ Map.include({
323
+ _initOverlay: function (OverlayClass, content, latlng, options) {
324
+ var overlay = content;
325
+ if (!(overlay instanceof OverlayClass)) {
326
+ overlay = new OverlayClass(options).setContent(content);
327
+ }
328
+ if (latlng) {
329
+ overlay.setLatLng(latlng);
330
+ }
331
+ return overlay;
332
+ }
333
+ });
334
+
335
+
336
+ Layer.include({
337
+ _initOverlay: function (OverlayClass, old, content, options) {
338
+ var overlay = content;
339
+ if (overlay instanceof OverlayClass) {
340
+ Util.setOptions(overlay, options);
341
+ overlay._source = this;
342
+ } else {
343
+ overlay = (old && !options) ? old : new OverlayClass(options, this);
344
+ overlay.setContent(content);
345
+ }
346
+ return overlay;
347
+ }
348
+ });
@@ -0,0 +1,94 @@
1
+ import {LayerGroup} from './LayerGroup';
2
+ import {LatLngBounds} from '../geo/LatLngBounds';
3
+
4
+ /*
5
+ * @class FeatureGroup
6
+ * @aka L.FeatureGroup
7
+ * @inherits LayerGroup
8
+ *
9
+ * Extended `LayerGroup` that makes it easier to do the same thing to all its member layers:
10
+ * * [`bindPopup`](#layer-bindpopup) binds a popup to all of the layers at once (likewise with [`bindTooltip`](#layer-bindtooltip))
11
+ * * Events are propagated to the `FeatureGroup`, so if the group has an event
12
+ * handler, it will handle events from any of the layers. This includes mouse events
13
+ * and custom events.
14
+ * * Has `layeradd` and `layerremove` events
15
+ *
16
+ * @example
17
+ *
18
+ * ```js
19
+ * L.featureGroup([marker1, marker2, polyline])
20
+ * .bindPopup('Hello world!')
21
+ * .on('click', function() { alert('Clicked on a member of the group!'); })
22
+ * .addTo(map);
23
+ * ```
24
+ */
25
+
26
+ export var FeatureGroup = LayerGroup.extend({
27
+
28
+ addLayer: function (layer) {
29
+ if (this.hasLayer(layer)) {
30
+ return this;
31
+ }
32
+
33
+ layer.addEventParent(this);
34
+
35
+ LayerGroup.prototype.addLayer.call(this, layer);
36
+
37
+ // @event layeradd: LayerEvent
38
+ // Fired when a layer is added to this `FeatureGroup`
39
+ return this.fire('layeradd', {layer: layer});
40
+ },
41
+
42
+ removeLayer: function (layer) {
43
+ if (!this.hasLayer(layer)) {
44
+ return this;
45
+ }
46
+ if (layer in this._layers) {
47
+ layer = this._layers[layer];
48
+ }
49
+
50
+ layer.removeEventParent(this);
51
+
52
+ LayerGroup.prototype.removeLayer.call(this, layer);
53
+
54
+ // @event layerremove: LayerEvent
55
+ // Fired when a layer is removed from this `FeatureGroup`
56
+ return this.fire('layerremove', {layer: layer});
57
+ },
58
+
59
+ // @method setStyle(style: Path options): this
60
+ // Sets the given path options to each layer of the group that has a `setStyle` method.
61
+ setStyle: function (style) {
62
+ return this.invoke('setStyle', style);
63
+ },
64
+
65
+ // @method bringToFront(): this
66
+ // Brings the layer group to the top of all other layers
67
+ bringToFront: function () {
68
+ return this.invoke('bringToFront');
69
+ },
70
+
71
+ // @method bringToBack(): this
72
+ // Brings the layer group to the back of all other layers
73
+ bringToBack: function () {
74
+ return this.invoke('bringToBack');
75
+ },
76
+
77
+ // @method getBounds(): LatLngBounds
78
+ // Returns the LatLngBounds of the Feature Group (created from bounds and coordinates of its children).
79
+ getBounds: function () {
80
+ var bounds = new LatLngBounds();
81
+
82
+ for (var id in this._layers) {
83
+ var layer = this._layers[id];
84
+ bounds.extend(layer.getBounds ? layer.getBounds() : layer.getLatLng());
85
+ }
86
+ return bounds;
87
+ }
88
+ });
89
+
90
+ // @factory L.featureGroup(layers?: Layer[], options?: Object)
91
+ // Create a feature group, optionally given an initial set of layers and an `options` object.
92
+ export var featureGroup = function (layers, options) {
93
+ return new FeatureGroup(layers, options);
94
+ };