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,66 @@
1
+ import {Icon} from './Icon';
2
+ import * as DomUtil from '../../dom/DomUtil';
3
+
4
+ /*
5
+ * @miniclass Icon.Default (Icon)
6
+ * @aka L.Icon.Default
7
+ * @section
8
+ *
9
+ * A trivial subclass of `Icon`, represents the icon to use in `Marker`s when
10
+ * no icon is specified. Points to the blue marker image distributed with Leaflet
11
+ * releases.
12
+ *
13
+ * In order to customize the default icon, just change the properties of `L.Icon.Default.prototype.options`
14
+ * (which is a set of `Icon options`).
15
+ *
16
+ * If you want to _completely_ replace the default icon, override the
17
+ * `L.Marker.prototype.options.icon` with your own icon instead.
18
+ */
19
+
20
+ export var IconDefault = Icon.extend({
21
+
22
+ options: {
23
+ iconUrl: 'marker-icon.png',
24
+ iconRetinaUrl: 'marker-icon-2x.png',
25
+ shadowUrl: 'marker-shadow.png',
26
+ iconSize: [25, 41],
27
+ iconAnchor: [12, 41],
28
+ popupAnchor: [1, -34],
29
+ tooltipAnchor: [16, -28],
30
+ shadowSize: [41, 41]
31
+ },
32
+
33
+ _getIconUrl: function (name) {
34
+ if (typeof IconDefault.imagePath !== 'string') { // Deprecated, backwards-compatibility only
35
+ IconDefault.imagePath = this._detectIconPath();
36
+ }
37
+
38
+ // @option imagePath: String
39
+ // `Icon.Default` will try to auto-detect the location of the
40
+ // blue icon images. If you are placing these images in a non-standard
41
+ // way, set this option to point to the right path.
42
+ return (this.options.imagePath || IconDefault.imagePath) + Icon.prototype._getIconUrl.call(this, name);
43
+ },
44
+
45
+ _stripUrl: function (path) { // separate function to use in tests
46
+ var strip = function (str, re, idx) {
47
+ var match = re.exec(str);
48
+ return match && match[idx];
49
+ };
50
+ path = strip(path, /^url\((['"])?(.+)\1\)$/, 2);
51
+ return path && strip(path, /^(.*)marker-icon\.png$/, 1);
52
+ },
53
+
54
+ _detectIconPath: function () {
55
+ var el = DomUtil.create('div', 'leaflet-default-icon-path', document.body);
56
+ var path = DomUtil.getStyle(el, 'background-image') ||
57
+ DomUtil.getStyle(el, 'backgroundImage'); // IE8
58
+
59
+ document.body.removeChild(el);
60
+ path = this._stripUrl(path);
61
+ if (path) { return path; }
62
+ var link = document.querySelector('link[href$="leaflet.css"]');
63
+ if (!link) { return ''; }
64
+ return link.href.substring(0, link.href.length - 'leaflet.css'.length - 1);
65
+ }
66
+ });
@@ -0,0 +1,165 @@
1
+ import {Class} from '../../core/Class';
2
+ import {setOptions} from '../../core/Util';
3
+ import {toPoint as point} from '../../geometry/Point';
4
+ import Browser from '../../core/Browser';
5
+
6
+ /*
7
+ * @class Icon
8
+ * @aka L.Icon
9
+ *
10
+ * Represents an icon to provide when creating a marker.
11
+ *
12
+ * @example
13
+ *
14
+ * ```js
15
+ * var myIcon = L.icon({
16
+ * iconUrl: 'my-icon.png',
17
+ * iconRetinaUrl: 'my-icon@2x.png',
18
+ * iconSize: [38, 95],
19
+ * iconAnchor: [22, 94],
20
+ * popupAnchor: [-3, -76],
21
+ * shadowUrl: 'my-icon-shadow.png',
22
+ * shadowRetinaUrl: 'my-icon-shadow@2x.png',
23
+ * shadowSize: [68, 95],
24
+ * shadowAnchor: [22, 94]
25
+ * });
26
+ *
27
+ * L.marker([50.505, 30.57], {icon: myIcon}).addTo(map);
28
+ * ```
29
+ *
30
+ * `L.Icon.Default` extends `L.Icon` and is the blue icon Leaflet uses for markers by default.
31
+ *
32
+ */
33
+
34
+ export var Icon = Class.extend({
35
+
36
+ /* @section
37
+ * @aka Icon options
38
+ *
39
+ * @option iconUrl: String = null
40
+ * **(required)** The URL to the icon image (absolute or relative to your script path).
41
+ *
42
+ * @option iconRetinaUrl: String = null
43
+ * The URL to a retina sized version of the icon image (absolute or relative to your
44
+ * script path). Used for Retina screen devices.
45
+ *
46
+ * @option iconSize: Point = null
47
+ * Size of the icon image in pixels.
48
+ *
49
+ * @option iconAnchor: Point = null
50
+ * The coordinates of the "tip" of the icon (relative to its top left corner). The icon
51
+ * will be aligned so that this point is at the marker's geographical location. Centered
52
+ * by default if size is specified, also can be set in CSS with negative margins.
53
+ *
54
+ * @option popupAnchor: Point = [0, 0]
55
+ * The coordinates of the point from which popups will "open", relative to the icon anchor.
56
+ *
57
+ * @option tooltipAnchor: Point = [0, 0]
58
+ * The coordinates of the point from which tooltips will "open", relative to the icon anchor.
59
+ *
60
+ * @option shadowUrl: String = null
61
+ * The URL to the icon shadow image. If not specified, no shadow image will be created.
62
+ *
63
+ * @option shadowRetinaUrl: String = null
64
+ *
65
+ * @option shadowSize: Point = null
66
+ * Size of the shadow image in pixels.
67
+ *
68
+ * @option shadowAnchor: Point = null
69
+ * The coordinates of the "tip" of the shadow (relative to its top left corner) (the same
70
+ * as iconAnchor if not specified).
71
+ *
72
+ * @option className: String = ''
73
+ * A custom class name to assign to both icon and shadow images. Empty by default.
74
+ */
75
+
76
+ options: {
77
+ popupAnchor: [0, 0],
78
+ tooltipAnchor: [0, 0],
79
+
80
+ // @option crossOrigin: Boolean|String = false
81
+ // Whether the crossOrigin attribute will be added to the tiles.
82
+ // 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.
83
+ // Refer to [CORS Settings](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes) for valid String values.
84
+ crossOrigin: false
85
+ },
86
+
87
+ initialize: function (options) {
88
+ setOptions(this, options);
89
+ },
90
+
91
+ // @method createIcon(oldIcon?: HTMLElement): HTMLElement
92
+ // Called internally when the icon has to be shown, returns a `<img>` HTML element
93
+ // styled according to the options.
94
+ createIcon: function (oldIcon) {
95
+ return this._createIcon('icon', oldIcon);
96
+ },
97
+
98
+ // @method createShadow(oldIcon?: HTMLElement): HTMLElement
99
+ // As `createIcon`, but for the shadow beneath it.
100
+ createShadow: function (oldIcon) {
101
+ return this._createIcon('shadow', oldIcon);
102
+ },
103
+
104
+ _createIcon: function (name, oldIcon) {
105
+ var src = this._getIconUrl(name);
106
+
107
+ if (!src) {
108
+ if (name === 'icon') {
109
+ throw new Error('iconUrl not set in Icon options (see the docs).');
110
+ }
111
+ return null;
112
+ }
113
+
114
+ var img = this._createImg(src, oldIcon && oldIcon.tagName === 'IMG' ? oldIcon : null);
115
+ this._setIconStyles(img, name);
116
+
117
+ if (this.options.crossOrigin || this.options.crossOrigin === '') {
118
+ img.crossOrigin = this.options.crossOrigin === true ? '' : this.options.crossOrigin;
119
+ }
120
+
121
+ return img;
122
+ },
123
+
124
+ _setIconStyles: function (img, name) {
125
+ var options = this.options;
126
+ var sizeOption = options[name + 'Size'];
127
+
128
+ if (typeof sizeOption === 'number') {
129
+ sizeOption = [sizeOption, sizeOption];
130
+ }
131
+
132
+ var size = point(sizeOption),
133
+ anchor = point(name === 'shadow' && options.shadowAnchor || options.iconAnchor ||
134
+ size && size.divideBy(2, true));
135
+
136
+ img.className = 'leaflet-marker-' + name + ' ' + (options.className || '');
137
+
138
+ if (anchor) {
139
+ img.style.marginLeft = (-anchor.x) + 'px';
140
+ img.style.marginTop = (-anchor.y) + 'px';
141
+ }
142
+
143
+ if (size) {
144
+ img.style.width = size.x + 'px';
145
+ img.style.height = size.y + 'px';
146
+ }
147
+ },
148
+
149
+ _createImg: function (src, el) {
150
+ el = el || document.createElement('img');
151
+ el.src = src;
152
+ return el;
153
+ },
154
+
155
+ _getIconUrl: function (name) {
156
+ return Browser.retina && this.options[name + 'RetinaUrl'] || this.options[name + 'Url'];
157
+ }
158
+ });
159
+
160
+
161
+ // @factory L.icon(options: Icon options)
162
+ // Creates an icon instance with the given options.
163
+ export function icon(options) {
164
+ return new Icon(options);
165
+ }
@@ -0,0 +1,161 @@
1
+ import {Handler} from '../../core/Handler';
2
+ import * as DomUtil from '../../dom/DomUtil';
3
+ import {Draggable} from '../../dom/Draggable';
4
+ import {toBounds} from '../../geometry/Bounds';
5
+ import {toPoint} from '../../geometry/Point';
6
+ import {requestAnimFrame, cancelAnimFrame} from '../../core/Util';
7
+
8
+ /*
9
+ * L.Handler.MarkerDrag is used internally by L.Marker to make the markers draggable.
10
+ */
11
+
12
+
13
+ /* @namespace Marker
14
+ * @section Interaction handlers
15
+ *
16
+ * Interaction handlers are properties of a marker instance that allow you to control interaction behavior in runtime, enabling or disabling certain features such as dragging (see `Handler` methods). Example:
17
+ *
18
+ * ```js
19
+ * marker.dragging.disable();
20
+ * ```
21
+ *
22
+ * @property dragging: Handler
23
+ * Marker dragging handler (by both mouse and touch). Only valid when the marker is on the map (Otherwise set [`marker.options.draggable`](#marker-draggable)).
24
+ */
25
+
26
+ export var MarkerDrag = Handler.extend({
27
+ initialize: function (marker) {
28
+ this._marker = marker;
29
+ },
30
+
31
+ addHooks: function () {
32
+ var icon = this._marker._icon;
33
+
34
+ if (!this._draggable) {
35
+ this._draggable = new Draggable(icon, icon, true);
36
+ }
37
+
38
+ this._draggable.on({
39
+ dragstart: this._onDragStart,
40
+ predrag: this._onPreDrag,
41
+ drag: this._onDrag,
42
+ dragend: this._onDragEnd
43
+ }, this).enable();
44
+
45
+ DomUtil.addClass(icon, 'leaflet-marker-draggable');
46
+ },
47
+
48
+ removeHooks: function () {
49
+ this._draggable.off({
50
+ dragstart: this._onDragStart,
51
+ predrag: this._onPreDrag,
52
+ drag: this._onDrag,
53
+ dragend: this._onDragEnd
54
+ }, this).disable();
55
+
56
+ if (this._marker._icon) {
57
+ DomUtil.removeClass(this._marker._icon, 'leaflet-marker-draggable');
58
+ }
59
+ },
60
+
61
+ moved: function () {
62
+ return this._draggable && this._draggable._moved;
63
+ },
64
+
65
+ _adjustPan: function (e) {
66
+ var marker = this._marker,
67
+ map = marker._map,
68
+ speed = this._marker.options.autoPanSpeed,
69
+ padding = this._marker.options.autoPanPadding,
70
+ iconPos = DomUtil.getPosition(marker._icon),
71
+ bounds = map.getPixelBounds(),
72
+ origin = map.getPixelOrigin();
73
+
74
+ var panBounds = toBounds(
75
+ bounds.min._subtract(origin).add(padding),
76
+ bounds.max._subtract(origin).subtract(padding)
77
+ );
78
+
79
+ if (!panBounds.contains(iconPos)) {
80
+ // Compute incremental movement
81
+ var movement = toPoint(
82
+ (Math.max(panBounds.max.x, iconPos.x) - panBounds.max.x) / (bounds.max.x - panBounds.max.x) -
83
+ (Math.min(panBounds.min.x, iconPos.x) - panBounds.min.x) / (bounds.min.x - panBounds.min.x),
84
+
85
+ (Math.max(panBounds.max.y, iconPos.y) - panBounds.max.y) / (bounds.max.y - panBounds.max.y) -
86
+ (Math.min(panBounds.min.y, iconPos.y) - panBounds.min.y) / (bounds.min.y - panBounds.min.y)
87
+ ).multiplyBy(speed);
88
+
89
+ map.panBy(movement, {animate: false});
90
+
91
+ this._draggable._newPos._add(movement);
92
+ this._draggable._startPos._add(movement);
93
+
94
+ DomUtil.setPosition(marker._icon, this._draggable._newPos);
95
+ this._onDrag(e);
96
+
97
+ this._panRequest = requestAnimFrame(this._adjustPan.bind(this, e));
98
+ }
99
+ },
100
+
101
+ _onDragStart: function () {
102
+ // @section Dragging events
103
+ // @event dragstart: Event
104
+ // Fired when the user starts dragging the marker.
105
+
106
+ // @event movestart: Event
107
+ // Fired when the marker starts moving (because of dragging).
108
+
109
+ this._oldLatLng = this._marker.getLatLng();
110
+
111
+ // When using ES6 imports it could not be set when `Popup` was not imported as well
112
+ this._marker.closePopup && this._marker.closePopup();
113
+
114
+ this._marker
115
+ .fire('movestart')
116
+ .fire('dragstart');
117
+ },
118
+
119
+ _onPreDrag: function (e) {
120
+ if (this._marker.options.autoPan) {
121
+ cancelAnimFrame(this._panRequest);
122
+ this._panRequest = requestAnimFrame(this._adjustPan.bind(this, e));
123
+ }
124
+ },
125
+
126
+ _onDrag: function (e) {
127
+ var marker = this._marker,
128
+ shadow = marker._shadow,
129
+ iconPos = DomUtil.getPosition(marker._icon),
130
+ latlng = marker._map.layerPointToLatLng(iconPos);
131
+
132
+ // update shadow position
133
+ if (shadow) {
134
+ DomUtil.setPosition(shadow, iconPos);
135
+ }
136
+
137
+ marker._latlng = latlng;
138
+ e.latlng = latlng;
139
+ e.oldLatLng = this._oldLatLng;
140
+
141
+ // @event drag: Event
142
+ // Fired repeatedly while the user drags the marker.
143
+ marker
144
+ .fire('move', e)
145
+ .fire('drag', e);
146
+ },
147
+
148
+ _onDragEnd: function (e) {
149
+ // @event dragend: DragEndEvent
150
+ // Fired when the user stops dragging the marker.
151
+
152
+ cancelAnimFrame(this._panRequest);
153
+
154
+ // @event moveend: Event
155
+ // Fired when the marker stops moving (because of dragging).
156
+ delete this._oldLatLng;
157
+ this._marker
158
+ .fire('moveend')
159
+ .fire('dragend', e);
160
+ }
161
+ });