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,137 @@
1
+ import {TileLayer} from './TileLayer';
2
+ import {extend, setOptions, getParamString} from '../../core/Util';
3
+ import Browser from '../../core/Browser';
4
+ import {EPSG4326} from '../../geo/crs/CRS.EPSG4326';
5
+ import {toBounds} from '../../geometry/Bounds';
6
+
7
+ /*
8
+ * @class TileLayer.WMS
9
+ * @inherits TileLayer
10
+ * @aka L.TileLayer.WMS
11
+ * Used to display [WMS](https://en.wikipedia.org/wiki/Web_Map_Service) services as tile layers on the map. Extends `TileLayer`.
12
+ *
13
+ * @example
14
+ *
15
+ * ```js
16
+ * var nexrad = L.tileLayer.wms("http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi", {
17
+ * layers: 'nexrad-n0r-900913',
18
+ * format: 'image/png',
19
+ * transparent: true,
20
+ * attribution: "Weather data © 2012 IEM Nexrad"
21
+ * });
22
+ * ```
23
+ */
24
+
25
+ export var TileLayerWMS = TileLayer.extend({
26
+
27
+ // @section
28
+ // @aka TileLayer.WMS options
29
+ // If any custom options not documented here are used, they will be sent to the
30
+ // WMS server as extra parameters in each request URL. This can be useful for
31
+ // [non-standard vendor WMS parameters](https://docs.geoserver.org/stable/en/user/services/wms/vendor.html).
32
+ defaultWmsParams: {
33
+ service: 'WMS',
34
+ request: 'GetMap',
35
+
36
+ // @option layers: String = ''
37
+ // **(required)** Comma-separated list of WMS layers to show.
38
+ layers: '',
39
+
40
+ // @option styles: String = ''
41
+ // Comma-separated list of WMS styles.
42
+ styles: '',
43
+
44
+ // @option format: String = 'image/jpeg'
45
+ // WMS image format (use `'image/png'` for layers with transparency).
46
+ format: 'image/jpeg',
47
+
48
+ // @option transparent: Boolean = false
49
+ // If `true`, the WMS service will return images with transparency.
50
+ transparent: false,
51
+
52
+ // @option version: String = '1.1.1'
53
+ // Version of the WMS service to use
54
+ version: '1.1.1'
55
+ },
56
+
57
+ options: {
58
+ // @option crs: CRS = null
59
+ // Coordinate Reference System to use for the WMS requests, defaults to
60
+ // map CRS. Don't change this if you're not sure what it means.
61
+ crs: null,
62
+
63
+ // @option uppercase: Boolean = false
64
+ // If `true`, WMS request parameter keys will be uppercase.
65
+ uppercase: false
66
+ },
67
+
68
+ initialize: function (url, options) {
69
+
70
+ this._url = url;
71
+
72
+ var wmsParams = extend({}, this.defaultWmsParams);
73
+
74
+ // all keys that are not TileLayer options go to WMS params
75
+ for (var i in options) {
76
+ if (!(i in this.options)) {
77
+ wmsParams[i] = options[i];
78
+ }
79
+ }
80
+
81
+ options = setOptions(this, options);
82
+
83
+ var realRetina = options.detectRetina && Browser.retina ? 2 : 1;
84
+ var tileSize = this.getTileSize();
85
+ wmsParams.width = tileSize.x * realRetina;
86
+ wmsParams.height = tileSize.y * realRetina;
87
+
88
+ this.wmsParams = wmsParams;
89
+ },
90
+
91
+ onAdd: function (map) {
92
+
93
+ this._crs = this.options.crs || map.options.crs;
94
+ this._wmsVersion = parseFloat(this.wmsParams.version);
95
+
96
+ var projectionKey = this._wmsVersion >= 1.3 ? 'crs' : 'srs';
97
+ this.wmsParams[projectionKey] = this._crs.code;
98
+
99
+ TileLayer.prototype.onAdd.call(this, map);
100
+ },
101
+
102
+ getTileUrl: function (coords) {
103
+
104
+ var tileBounds = this._tileCoordsToNwSe(coords),
105
+ crs = this._crs,
106
+ bounds = toBounds(crs.project(tileBounds[0]), crs.project(tileBounds[1])),
107
+ min = bounds.min,
108
+ max = bounds.max,
109
+ bbox = (this._wmsVersion >= 1.3 && this._crs === EPSG4326 ?
110
+ [min.y, min.x, max.y, max.x] :
111
+ [min.x, min.y, max.x, max.y]).join(','),
112
+ url = TileLayer.prototype.getTileUrl.call(this, coords);
113
+ return url +
114
+ getParamString(this.wmsParams, url, this.options.uppercase) +
115
+ (this.options.uppercase ? '&BBOX=' : '&bbox=') + bbox;
116
+ },
117
+
118
+ // @method setParams(params: Object, noRedraw?: Boolean): this
119
+ // Merges an object with the new parameters and re-requests tiles on the current screen (unless `noRedraw` was set to true).
120
+ setParams: function (params, noRedraw) {
121
+
122
+ extend(this.wmsParams, params);
123
+
124
+ if (!noRedraw) {
125
+ this.redraw();
126
+ }
127
+
128
+ return this;
129
+ }
130
+ });
131
+
132
+
133
+ // @factory L.tileLayer.wms(baseUrl: String, options: TileLayer.WMS options)
134
+ // Instantiates a WMS tile layer object given a base URL of the WMS service and a WMS parameters/options object.
135
+ export function tileLayerWMS(url, options) {
136
+ return new TileLayerWMS(url, options);
137
+ }
@@ -0,0 +1,289 @@
1
+ import {GridLayer} from './GridLayer';
2
+ import Browser from '../../core/Browser';
3
+ import * as Util from '../../core/Util';
4
+ import * as DomEvent from '../../dom/DomEvent';
5
+ import * as DomUtil from '../../dom/DomUtil';
6
+
7
+
8
+ /*
9
+ * @class TileLayer
10
+ * @inherits GridLayer
11
+ * @aka L.TileLayer
12
+ * Used to load and display tile layers on the map. Note that most tile servers require attribution, which you can set under `Layer`. Extends `GridLayer`.
13
+ *
14
+ * @example
15
+ *
16
+ * ```js
17
+ * L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png?{foo}', {foo: 'bar', attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'}).addTo(map);
18
+ * ```
19
+ *
20
+ * @section URL template
21
+ * @example
22
+ *
23
+ * A string of the following form:
24
+ *
25
+ * ```
26
+ * 'https://{s}.somedomain.com/blabla/{z}/{x}/{y}{r}.png'
27
+ * ```
28
+ *
29
+ * `{s}` means one of the available subdomains (used sequentially to help with browser parallel requests per domain limitation; subdomain values are specified in options; `a`, `b` or `c` by default, can be omitted), `{z}` — zoom level, `{x}` and `{y}` — tile coordinates. `{r}` can be used to add "&commat;2x" to the URL to load retina tiles.
30
+ *
31
+ * You can use custom keys in the template, which will be [evaluated](#util-template) from TileLayer options, like this:
32
+ *
33
+ * ```
34
+ * L.tileLayer('https://{s}.somedomain.com/{foo}/{z}/{x}/{y}.png', {foo: 'bar'});
35
+ * ```
36
+ */
37
+
38
+
39
+ export var TileLayer = GridLayer.extend({
40
+
41
+ // @section
42
+ // @aka TileLayer options
43
+ options: {
44
+ // @option minZoom: Number = 0
45
+ // The minimum zoom level down to which this layer will be displayed (inclusive).
46
+ minZoom: 0,
47
+
48
+ // @option maxZoom: Number = 18
49
+ // The maximum zoom level up to which this layer will be displayed (inclusive).
50
+ maxZoom: 18,
51
+
52
+ // @option subdomains: String|String[] = 'abc'
53
+ // Subdomains of the tile service. Can be passed in the form of one string (where each letter is a subdomain name) or an array of strings.
54
+ subdomains: 'abc',
55
+
56
+ // @option errorTileUrl: String = ''
57
+ // URL to the tile image to show in place of the tile that failed to load.
58
+ errorTileUrl: '',
59
+
60
+ // @option zoomOffset: Number = 0
61
+ // The zoom number used in tile URLs will be offset with this value.
62
+ zoomOffset: 0,
63
+
64
+ // @option tms: Boolean = false
65
+ // If `true`, inverses Y axis numbering for tiles (turn this on for [TMS](https://en.wikipedia.org/wiki/Tile_Map_Service) services).
66
+ tms: false,
67
+
68
+ // @option zoomReverse: Boolean = false
69
+ // If set to true, the zoom number used in tile URLs will be reversed (`maxZoom - zoom` instead of `zoom`)
70
+ zoomReverse: false,
71
+
72
+ // @option detectRetina: Boolean = false
73
+ // If `true` and user is on a retina display, it will request four tiles of half the specified size and a bigger zoom level in place of one to utilize the high resolution.
74
+ detectRetina: false,
75
+
76
+ // @option crossOrigin: Boolean|String = false
77
+ // Whether the crossOrigin attribute will be added to the tiles.
78
+ // If a String is provided, all tiles will have their crossOrigin attribute set to the String provided. This is needed if you want to access tile pixel data.
79
+ // Refer to [CORS Settings](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes) for valid String values.
80
+ crossOrigin: false,
81
+
82
+ // @option referrerPolicy: Boolean|String = false
83
+ // Whether the referrerPolicy attribute will be added to the tiles.
84
+ // If a String is provided, all tiles will have their referrerPolicy attribute set to the String provided.
85
+ // This may be needed if your map's rendering context has a strict default but your tile provider expects a valid referrer
86
+ // (e.g. to validate an API token).
87
+ // Refer to [HTMLImageElement.referrerPolicy](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/referrerPolicy) for valid String values.
88
+ referrerPolicy: false
89
+ },
90
+
91
+ initialize: function (url, options) {
92
+
93
+ this._url = url;
94
+
95
+ options = Util.setOptions(this, options);
96
+
97
+ // detecting retina displays, adjusting tileSize and zoom levels
98
+ if (options.detectRetina && Browser.retina && options.maxZoom > 0) {
99
+
100
+ options.tileSize = Math.floor(options.tileSize / 2);
101
+
102
+ if (!options.zoomReverse) {
103
+ options.zoomOffset++;
104
+ options.maxZoom = Math.max(options.minZoom, options.maxZoom - 1);
105
+ } else {
106
+ options.zoomOffset--;
107
+ options.minZoom = Math.min(options.maxZoom, options.minZoom + 1);
108
+ }
109
+
110
+ options.minZoom = Math.max(0, options.minZoom);
111
+ } else if (!options.zoomReverse) {
112
+ // make sure maxZoom is gte minZoom
113
+ options.maxZoom = Math.max(options.minZoom, options.maxZoom);
114
+ } else {
115
+ // make sure minZoom is lte maxZoom
116
+ options.minZoom = Math.min(options.maxZoom, options.minZoom);
117
+ }
118
+
119
+ if (typeof options.subdomains === 'string') {
120
+ options.subdomains = options.subdomains.split('');
121
+ }
122
+
123
+ this.on('tileunload', this._onTileRemove);
124
+ },
125
+
126
+ // @method setUrl(url: String, noRedraw?: Boolean): this
127
+ // Updates the layer's URL template and redraws it (unless `noRedraw` is set to `true`).
128
+ // If the URL does not change, the layer will not be redrawn unless
129
+ // the noRedraw parameter is set to false.
130
+ setUrl: function (url, noRedraw) {
131
+ if (this._url === url && noRedraw === undefined) {
132
+ noRedraw = true;
133
+ }
134
+
135
+ this._url = url;
136
+
137
+ if (!noRedraw) {
138
+ this.redraw();
139
+ }
140
+ return this;
141
+ },
142
+
143
+ // @method createTile(coords: Object, done?: Function): HTMLElement
144
+ // Called only internally, overrides GridLayer's [`createTile()`](#gridlayer-createtile)
145
+ // to return an `<img>` HTML element with the appropriate image URL given `coords`. The `done`
146
+ // callback is called when the tile has been loaded.
147
+ createTile: function (coords, done) {
148
+ var tile = document.createElement('img');
149
+
150
+ DomEvent.on(tile, 'load', Util.bind(this._tileOnLoad, this, done, tile));
151
+ DomEvent.on(tile, 'error', Util.bind(this._tileOnError, this, done, tile));
152
+
153
+ if (this.options.crossOrigin || this.options.crossOrigin === '') {
154
+ tile.crossOrigin = this.options.crossOrigin === true ? '' : this.options.crossOrigin;
155
+ }
156
+
157
+ // for this new option we follow the documented behavior
158
+ // more closely by only setting the property when string
159
+ if (typeof this.options.referrerPolicy === 'string') {
160
+ tile.referrerPolicy = this.options.referrerPolicy;
161
+ }
162
+
163
+ // The alt attribute is set to the empty string,
164
+ // allowing screen readers to ignore the decorative image tiles.
165
+ // https://www.w3.org/WAI/tutorials/images/decorative/
166
+ // https://www.w3.org/TR/html-aria/#el-img-empty-alt
167
+ tile.alt = '';
168
+
169
+ tile.src = this.getTileUrl(coords);
170
+
171
+ return tile;
172
+ },
173
+
174
+ // @section Extension methods
175
+ // @uninheritable
176
+ // Layers extending `TileLayer` might reimplement the following method.
177
+ // @method getTileUrl(coords: Object): String
178
+ // Called only internally, returns the URL for a tile given its coordinates.
179
+ // Classes extending `TileLayer` can override this function to provide custom tile URL naming schemes.
180
+ getTileUrl: function (coords) {
181
+ var data = {
182
+ r: Browser.retina ? '@2x' : '',
183
+ s: this._getSubdomain(coords),
184
+ x: coords.x,
185
+ y: coords.y,
186
+ z: this._getZoomForUrl()
187
+ };
188
+ if (this._map && !this._map.options.crs.infinite) {
189
+ var invertedY = this._globalTileRange.max.y - coords.y;
190
+ if (this.options.tms) {
191
+ data['y'] = invertedY;
192
+ }
193
+ data['-y'] = invertedY;
194
+ }
195
+
196
+ return Util.template(this._url, Util.extend(data, this.options));
197
+ },
198
+
199
+ _tileOnLoad: function (done, tile) {
200
+ // For https://github.com/Leaflet/Leaflet/issues/3332
201
+ if (Browser.ielt9) {
202
+ setTimeout(Util.bind(done, this, null, tile), 0);
203
+ } else {
204
+ done(null, tile);
205
+ }
206
+ },
207
+
208
+ _tileOnError: function (done, tile, e) {
209
+ var errorUrl = this.options.errorTileUrl;
210
+ if (errorUrl && tile.getAttribute('src') !== errorUrl) {
211
+ tile.src = errorUrl;
212
+ }
213
+ done(e, tile);
214
+ },
215
+
216
+ _onTileRemove: function (e) {
217
+ e.tile.onload = null;
218
+ },
219
+
220
+ _getZoomForUrl: function () {
221
+ var zoom = this._tileZoom,
222
+ maxZoom = this.options.maxZoom,
223
+ zoomReverse = this.options.zoomReverse,
224
+ zoomOffset = this.options.zoomOffset;
225
+
226
+ if (zoomReverse) {
227
+ zoom = maxZoom - zoom;
228
+ }
229
+
230
+ return zoom + zoomOffset;
231
+ },
232
+
233
+ _getSubdomain: function (tilePoint) {
234
+ var index = Math.abs(tilePoint.x + tilePoint.y) % this.options.subdomains.length;
235
+ return this.options.subdomains[index];
236
+ },
237
+
238
+ // stops loading all tiles in the background layer
239
+ _abortLoading: function () {
240
+ var i, tile;
241
+ for (i in this._tiles) {
242
+ if (this._tiles[i].coords.z !== this._tileZoom) {
243
+ tile = this._tiles[i].el;
244
+
245
+ tile.onload = Util.falseFn;
246
+ tile.onerror = Util.falseFn;
247
+
248
+ if (!tile.complete) {
249
+ tile.src = Util.emptyImageUrl;
250
+ var coords = this._tiles[i].coords;
251
+ DomUtil.remove(tile);
252
+ delete this._tiles[i];
253
+ // @event tileabort: TileEvent
254
+ // Fired when a tile was loading but is now not wanted.
255
+ this.fire('tileabort', {
256
+ tile: tile,
257
+ coords: coords
258
+ });
259
+ }
260
+ }
261
+ }
262
+ },
263
+
264
+ _removeTile: function (key) {
265
+ var tile = this._tiles[key];
266
+ if (!tile) { return; }
267
+
268
+ // Cancels any pending http requests associated with the tile
269
+ tile.el.setAttribute('src', Util.emptyImageUrl);
270
+
271
+ return GridLayer.prototype._removeTile.call(this, key);
272
+ },
273
+
274
+ _tileReady: function (coords, err, tile) {
275
+ if (!this._map || (tile && tile.getAttribute('src') === Util.emptyImageUrl)) {
276
+ return;
277
+ }
278
+
279
+ return GridLayer.prototype._tileReady.call(this, coords, err, tile);
280
+ }
281
+ });
282
+
283
+
284
+ // @factory L.tilelayer(urlTemplate: String, options?: TileLayer options)
285
+ // Instantiates a tile layer object given a `URL template` and optionally an options object.
286
+
287
+ export function tileLayer(url, options) {
288
+ return new TileLayer(url, options);
289
+ }
@@ -0,0 +1,6 @@
1
+ export {GridLayer, gridLayer} from './GridLayer';
2
+ import {TileLayer, tileLayer} from './TileLayer';
3
+ import {TileLayerWMS, tileLayerWMS} from './TileLayer.WMS';
4
+ TileLayer.WMS = TileLayerWMS;
5
+ tileLayer.wms = tileLayerWMS;
6
+ export {TileLayer, tileLayer};