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,452 @@
1
+ import {LayerGroup} from './LayerGroup';
2
+ import {FeatureGroup} from './FeatureGroup';
3
+ import * as Util from '../core/Util';
4
+ import {Marker} from './marker/Marker';
5
+ import {Circle} from './vector/Circle';
6
+ import {CircleMarker} from './vector/CircleMarker';
7
+ import {Polyline} from './vector/Polyline';
8
+ import {Polygon} from './vector/Polygon';
9
+ import {LatLng} from '../geo/LatLng';
10
+ import * as LineUtil from '../geometry/LineUtil';
11
+ import {toLatLng} from '../geo/LatLng';
12
+
13
+
14
+ /*
15
+ * @class GeoJSON
16
+ * @aka L.GeoJSON
17
+ * @inherits FeatureGroup
18
+ *
19
+ * Represents a GeoJSON object or an array of GeoJSON objects. Allows you to parse
20
+ * GeoJSON data and display it on the map. Extends `FeatureGroup`.
21
+ *
22
+ * @example
23
+ *
24
+ * ```js
25
+ * L.geoJSON(data, {
26
+ * style: function (feature) {
27
+ * return {color: feature.properties.color};
28
+ * }
29
+ * }).bindPopup(function (layer) {
30
+ * return layer.feature.properties.description;
31
+ * }).addTo(map);
32
+ * ```
33
+ */
34
+
35
+ export var GeoJSON = FeatureGroup.extend({
36
+
37
+ /* @section
38
+ * @aka GeoJSON options
39
+ *
40
+ * @option pointToLayer: Function = *
41
+ * A `Function` defining how GeoJSON points spawn Leaflet layers. It is internally
42
+ * called when data is added, passing the GeoJSON point feature and its `LatLng`.
43
+ * The default is to spawn a default `Marker`:
44
+ * ```js
45
+ * function(geoJsonPoint, latlng) {
46
+ * return L.marker(latlng);
47
+ * }
48
+ * ```
49
+ *
50
+ * @option style: Function = *
51
+ * A `Function` defining the `Path options` for styling GeoJSON lines and polygons,
52
+ * called internally when data is added.
53
+ * The default value is to not override any defaults:
54
+ * ```js
55
+ * function (geoJsonFeature) {
56
+ * return {}
57
+ * }
58
+ * ```
59
+ *
60
+ * @option onEachFeature: Function = *
61
+ * A `Function` that will be called once for each created `Feature`, after it has
62
+ * been created and styled. Useful for attaching events and popups to features.
63
+ * The default is to do nothing with the newly created layers:
64
+ * ```js
65
+ * function (feature, layer) {}
66
+ * ```
67
+ *
68
+ * @option filter: Function = *
69
+ * A `Function` that will be used to decide whether to include a feature or not.
70
+ * The default is to include all features:
71
+ * ```js
72
+ * function (geoJsonFeature) {
73
+ * return true;
74
+ * }
75
+ * ```
76
+ * Note: dynamically changing the `filter` option will have effect only on newly
77
+ * added data. It will _not_ re-evaluate already included features.
78
+ *
79
+ * @option coordsToLatLng: Function = *
80
+ * A `Function` that will be used for converting GeoJSON coordinates to `LatLng`s.
81
+ * The default is the `coordsToLatLng` static method.
82
+ *
83
+ * @option markersInheritOptions: Boolean = false
84
+ * Whether default Markers for "Point" type Features inherit from group options.
85
+ */
86
+
87
+ initialize: function (geojson, options) {
88
+ Util.setOptions(this, options);
89
+
90
+ this._layers = {};
91
+
92
+ if (geojson) {
93
+ this.addData(geojson);
94
+ }
95
+ },
96
+
97
+ // @method addData( <GeoJSON> data ): this
98
+ // Adds a GeoJSON object to the layer.
99
+ addData: function (geojson) {
100
+ var features = Util.isArray(geojson) ? geojson : geojson.features,
101
+ i, len, feature;
102
+
103
+ if (features) {
104
+ for (i = 0, len = features.length; i < len; i++) {
105
+ // only add this if geometry or geometries are set and not null
106
+ feature = features[i];
107
+ if (feature.geometries || feature.geometry || feature.features || feature.coordinates) {
108
+ this.addData(feature);
109
+ }
110
+ }
111
+ return this;
112
+ }
113
+
114
+ var options = this.options;
115
+
116
+ if (options.filter && !options.filter(geojson)) { return this; }
117
+
118
+ var layer = geometryToLayer(geojson, options);
119
+ if (!layer) {
120
+ return this;
121
+ }
122
+ layer.feature = asFeature(geojson);
123
+
124
+ layer.defaultOptions = layer.options;
125
+ this.resetStyle(layer);
126
+
127
+ if (options.onEachFeature) {
128
+ options.onEachFeature(geojson, layer);
129
+ }
130
+
131
+ return this.addLayer(layer);
132
+ },
133
+
134
+ // @method resetStyle( <Path> layer? ): this
135
+ // Resets the given vector layer's style to the original GeoJSON style, useful for resetting style after hover events.
136
+ // If `layer` is omitted, the style of all features in the current layer is reset.
137
+ resetStyle: function (layer) {
138
+ if (layer === undefined) {
139
+ return this.eachLayer(this.resetStyle, this);
140
+ }
141
+ // reset any custom styles
142
+ layer.options = Util.extend({}, layer.defaultOptions);
143
+ this._setLayerStyle(layer, this.options.style);
144
+ return this;
145
+ },
146
+
147
+ // @method setStyle( <Function> style ): this
148
+ // Changes styles of GeoJSON vector layers with the given style function.
149
+ setStyle: function (style) {
150
+ return this.eachLayer(function (layer) {
151
+ this._setLayerStyle(layer, style);
152
+ }, this);
153
+ },
154
+
155
+ _setLayerStyle: function (layer, style) {
156
+ if (layer.setStyle) {
157
+ if (typeof style === 'function') {
158
+ style = style(layer.feature);
159
+ }
160
+ layer.setStyle(style);
161
+ }
162
+ }
163
+ });
164
+
165
+ // @section
166
+ // There are several static functions which can be called without instantiating L.GeoJSON:
167
+
168
+ // @function geometryToLayer(featureData: Object, options?: GeoJSON options): Layer
169
+ // Creates a `Layer` from a given GeoJSON feature. Can use a custom
170
+ // [`pointToLayer`](#geojson-pointtolayer) and/or [`coordsToLatLng`](#geojson-coordstolatlng)
171
+ // functions if provided as options.
172
+ export function geometryToLayer(geojson, options) {
173
+
174
+ var geometry = geojson.type === 'Feature' ? geojson.geometry : geojson,
175
+ coords = geometry ? geometry.coordinates : null,
176
+ layers = [],
177
+ pointToLayer = options && options.pointToLayer,
178
+ _coordsToLatLng = options && options.coordsToLatLng || coordsToLatLng,
179
+ latlng, latlngs, i, len;
180
+
181
+ if (!coords && !geometry) {
182
+ return null;
183
+ }
184
+
185
+ switch (geometry.type) {
186
+ case 'Point':
187
+ latlng = _coordsToLatLng(coords);
188
+ return _pointToLayer(pointToLayer, geojson, latlng, options);
189
+
190
+ case 'MultiPoint':
191
+ for (i = 0, len = coords.length; i < len; i++) {
192
+ latlng = _coordsToLatLng(coords[i]);
193
+ layers.push(_pointToLayer(pointToLayer, geojson, latlng, options));
194
+ }
195
+ return new FeatureGroup(layers);
196
+
197
+ case 'LineString':
198
+ case 'MultiLineString':
199
+ latlngs = coordsToLatLngs(coords, geometry.type === 'LineString' ? 0 : 1, _coordsToLatLng);
200
+ return new Polyline(latlngs, options);
201
+
202
+ case 'Polygon':
203
+ case 'MultiPolygon':
204
+ latlngs = coordsToLatLngs(coords, geometry.type === 'Polygon' ? 1 : 2, _coordsToLatLng);
205
+ return new Polygon(latlngs, options);
206
+
207
+ case 'GeometryCollection':
208
+ for (i = 0, len = geometry.geometries.length; i < len; i++) {
209
+ var geoLayer = geometryToLayer({
210
+ geometry: geometry.geometries[i],
211
+ type: 'Feature',
212
+ properties: geojson.properties
213
+ }, options);
214
+
215
+ if (geoLayer) {
216
+ layers.push(geoLayer);
217
+ }
218
+ }
219
+ return new FeatureGroup(layers);
220
+
221
+ case 'FeatureCollection':
222
+ for (i = 0, len = geometry.features.length; i < len; i++) {
223
+ var featureLayer = geometryToLayer(geometry.features[i], options);
224
+
225
+ if (featureLayer) {
226
+ layers.push(featureLayer);
227
+ }
228
+ }
229
+ return new FeatureGroup(layers);
230
+
231
+ default:
232
+ throw new Error('Invalid GeoJSON object.');
233
+ }
234
+ }
235
+
236
+ function _pointToLayer(pointToLayerFn, geojson, latlng, options) {
237
+ return pointToLayerFn ?
238
+ pointToLayerFn(geojson, latlng) :
239
+ new Marker(latlng, options && options.markersInheritOptions && options);
240
+ }
241
+
242
+ // @function coordsToLatLng(coords: Array): LatLng
243
+ // Creates a `LatLng` object from an array of 2 numbers (longitude, latitude)
244
+ // or 3 numbers (longitude, latitude, altitude) used in GeoJSON for points.
245
+ export function coordsToLatLng(coords) {
246
+ return new LatLng(coords[1], coords[0], coords[2]);
247
+ }
248
+
249
+ // @function coordsToLatLngs(coords: Array, levelsDeep?: Number, coordsToLatLng?: Function): Array
250
+ // Creates a multidimensional array of `LatLng`s from a GeoJSON coordinates array.
251
+ // `levelsDeep` specifies the nesting level (0 is for an array of points, 1 for an array of arrays of points, etc., 0 by default).
252
+ // Can use a custom [`coordsToLatLng`](#geojson-coordstolatlng) function.
253
+ export function coordsToLatLngs(coords, levelsDeep, _coordsToLatLng) {
254
+ var latlngs = [];
255
+
256
+ for (var i = 0, len = coords.length, latlng; i < len; i++) {
257
+ latlng = levelsDeep ?
258
+ coordsToLatLngs(coords[i], levelsDeep - 1, _coordsToLatLng) :
259
+ (_coordsToLatLng || coordsToLatLng)(coords[i]);
260
+
261
+ latlngs.push(latlng);
262
+ }
263
+
264
+ return latlngs;
265
+ }
266
+
267
+ // @function latLngToCoords(latlng: LatLng, precision?: Number|false): Array
268
+ // Reverse of [`coordsToLatLng`](#geojson-coordstolatlng)
269
+ // Coordinates values are rounded with [`formatNum`](#util-formatnum) function.
270
+ export function latLngToCoords(latlng, precision) {
271
+ latlng = toLatLng(latlng);
272
+ return latlng.alt !== undefined ?
273
+ [Util.formatNum(latlng.lng, precision), Util.formatNum(latlng.lat, precision), Util.formatNum(latlng.alt, precision)] :
274
+ [Util.formatNum(latlng.lng, precision), Util.formatNum(latlng.lat, precision)];
275
+ }
276
+
277
+ // @function latLngsToCoords(latlngs: Array, levelsDeep?: Number, closed?: Boolean, precision?: Number|false): Array
278
+ // Reverse of [`coordsToLatLngs`](#geojson-coordstolatlngs)
279
+ // `closed` determines whether the first point should be appended to the end of the array to close the feature, only used when `levelsDeep` is 0. False by default.
280
+ // Coordinates values are rounded with [`formatNum`](#util-formatnum) function.
281
+ export function latLngsToCoords(latlngs, levelsDeep, closed, precision) {
282
+ var coords = [];
283
+
284
+ for (var i = 0, len = latlngs.length; i < len; i++) {
285
+ // Check for flat arrays required to ensure unbalanced arrays are correctly converted in recursion
286
+ coords.push(levelsDeep ?
287
+ latLngsToCoords(latlngs[i], LineUtil.isFlat(latlngs[i]) ? 0 : levelsDeep - 1, closed, precision) :
288
+ latLngToCoords(latlngs[i], precision));
289
+ }
290
+
291
+ if (!levelsDeep && closed && coords.length > 0) {
292
+ coords.push(coords[0].slice());
293
+ }
294
+
295
+ return coords;
296
+ }
297
+
298
+ export function getFeature(layer, newGeometry) {
299
+ return layer.feature ?
300
+ Util.extend({}, layer.feature, {geometry: newGeometry}) :
301
+ asFeature(newGeometry);
302
+ }
303
+
304
+ // @function asFeature(geojson: Object): Object
305
+ // Normalize GeoJSON geometries/features into GeoJSON features.
306
+ export function asFeature(geojson) {
307
+ if (geojson.type === 'Feature' || geojson.type === 'FeatureCollection') {
308
+ return geojson;
309
+ }
310
+
311
+ return {
312
+ type: 'Feature',
313
+ properties: {},
314
+ geometry: geojson
315
+ };
316
+ }
317
+
318
+ var PointToGeoJSON = {
319
+ toGeoJSON: function (precision) {
320
+ return getFeature(this, {
321
+ type: 'Point',
322
+ coordinates: latLngToCoords(this.getLatLng(), precision)
323
+ });
324
+ }
325
+ };
326
+
327
+ // @namespace Marker
328
+ // @section Other methods
329
+ // @method toGeoJSON(precision?: Number|false): Object
330
+ // Coordinates values are rounded with [`formatNum`](#util-formatnum) function with given `precision`.
331
+ // Returns a [`GeoJSON`](https://en.wikipedia.org/wiki/GeoJSON) representation of the marker (as a GeoJSON `Point` Feature).
332
+ Marker.include(PointToGeoJSON);
333
+
334
+ // @namespace CircleMarker
335
+ // @method toGeoJSON(precision?: Number|false): Object
336
+ // Coordinates values are rounded with [`formatNum`](#util-formatnum) function with given `precision`.
337
+ // Returns a [`GeoJSON`](https://en.wikipedia.org/wiki/GeoJSON) representation of the circle marker (as a GeoJSON `Point` Feature).
338
+ Circle.include(PointToGeoJSON);
339
+ CircleMarker.include(PointToGeoJSON);
340
+
341
+
342
+ // @namespace Polyline
343
+ // @method toGeoJSON(precision?: Number|false): Object
344
+ // Coordinates values are rounded with [`formatNum`](#util-formatnum) function with given `precision`.
345
+ // Returns a [`GeoJSON`](https://en.wikipedia.org/wiki/GeoJSON) representation of the polyline (as a GeoJSON `LineString` or `MultiLineString` Feature).
346
+ Polyline.include({
347
+ toGeoJSON: function (precision) {
348
+ var multi = !LineUtil.isFlat(this._latlngs);
349
+
350
+ var coords = latLngsToCoords(this._latlngs, multi ? 1 : 0, false, precision);
351
+
352
+ return getFeature(this, {
353
+ type: (multi ? 'Multi' : '') + 'LineString',
354
+ coordinates: coords
355
+ });
356
+ }
357
+ });
358
+
359
+ // @namespace Polygon
360
+ // @method toGeoJSON(precision?: Number|false): Object
361
+ // Coordinates values are rounded with [`formatNum`](#util-formatnum) function with given `precision`.
362
+ // Returns a [`GeoJSON`](https://en.wikipedia.org/wiki/GeoJSON) representation of the polygon (as a GeoJSON `Polygon` or `MultiPolygon` Feature).
363
+ Polygon.include({
364
+ toGeoJSON: function (precision) {
365
+ var holes = !LineUtil.isFlat(this._latlngs),
366
+ multi = holes && !LineUtil.isFlat(this._latlngs[0]);
367
+
368
+ var coords = latLngsToCoords(this._latlngs, multi ? 2 : holes ? 1 : 0, true, precision);
369
+
370
+ if (!holes) {
371
+ coords = [coords];
372
+ }
373
+
374
+ return getFeature(this, {
375
+ type: (multi ? 'Multi' : '') + 'Polygon',
376
+ coordinates: coords
377
+ });
378
+ }
379
+ });
380
+
381
+
382
+ // @namespace LayerGroup
383
+ LayerGroup.include({
384
+ toMultiPoint: function (precision) {
385
+ var coords = [];
386
+
387
+ this.eachLayer(function (layer) {
388
+ coords.push(layer.toGeoJSON(precision).geometry.coordinates);
389
+ });
390
+
391
+ return getFeature(this, {
392
+ type: 'MultiPoint',
393
+ coordinates: coords
394
+ });
395
+ },
396
+
397
+ // @method toGeoJSON(precision?: Number|false): Object
398
+ // Coordinates values are rounded with [`formatNum`](#util-formatnum) function with given `precision`.
399
+ // Returns a [`GeoJSON`](https://en.wikipedia.org/wiki/GeoJSON) representation of the layer group (as a GeoJSON `FeatureCollection`, `GeometryCollection`, or `MultiPoint`).
400
+ toGeoJSON: function (precision) {
401
+
402
+ var type = this.feature && this.feature.geometry && this.feature.geometry.type;
403
+
404
+ if (type === 'MultiPoint') {
405
+ return this.toMultiPoint(precision);
406
+ }
407
+
408
+ var isGeometryCollection = type === 'GeometryCollection',
409
+ jsons = [];
410
+
411
+ this.eachLayer(function (layer) {
412
+ if (layer.toGeoJSON) {
413
+ var json = layer.toGeoJSON(precision);
414
+ if (isGeometryCollection) {
415
+ jsons.push(json.geometry);
416
+ } else {
417
+ var feature = asFeature(json);
418
+ // Squash nested feature collections
419
+ if (feature.type === 'FeatureCollection') {
420
+ jsons.push.apply(jsons, feature.features);
421
+ } else {
422
+ jsons.push(feature);
423
+ }
424
+ }
425
+ }
426
+ });
427
+
428
+ if (isGeometryCollection) {
429
+ return getFeature(this, {
430
+ geometries: jsons,
431
+ type: 'GeometryCollection'
432
+ });
433
+ }
434
+
435
+ return {
436
+ type: 'FeatureCollection',
437
+ features: jsons
438
+ };
439
+ }
440
+ });
441
+
442
+ // @namespace GeoJSON
443
+ // @factory L.geoJSON(geojson?: Object, options?: GeoJSON options)
444
+ // Creates a GeoJSON layer. Optionally accepts an object in
445
+ // [GeoJSON format](https://tools.ietf.org/html/rfc7946) to display on the map
446
+ // (you can alternatively add it later with `addData` method) and an `options` object.
447
+ export function geoJSON(geojson, options) {
448
+ return new GeoJSON(geojson, options);
449
+ }
450
+
451
+ // Backward compatibility.
452
+ export var geoJson = geoJSON;