maplair 4.0.0 → 4.2.0
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.
- package/CHANGELOG.md +178 -0
- package/dist/esm/Maplair.js +18 -17
- package/dist/esm/Maplair.js.map +1 -1
- package/dist/esm/_virtual/_rolldown/runtime.js +1 -2
- package/dist/esm/control/AttributionControl.js +25 -16
- package/dist/esm/control/AttributionControl.js.map +1 -1
- package/dist/esm/control/ButtonControl.js +10 -13
- package/dist/esm/control/ButtonControl.js.map +1 -1
- package/dist/esm/control/ContextMenu.js +2 -5
- package/dist/esm/control/ContextMenu.js.map +1 -1
- package/dist/esm/control/Control.js +10 -18
- package/dist/esm/control/Control.js.map +1 -1
- package/dist/esm/control/FullscreenControl.js +6 -9
- package/dist/esm/control/FullscreenControl.js.map +1 -1
- package/dist/esm/control/LayersControl.js +170 -65
- package/dist/esm/control/LayersControl.js.map +1 -1
- package/dist/esm/control/LegendControl.js +8 -11
- package/dist/esm/control/LegendControl.js.map +1 -1
- package/dist/esm/control/MiniMapControl.js +15 -18
- package/dist/esm/control/MiniMapControl.js.map +1 -1
- package/dist/esm/control/RotateControl.js +2 -5
- package/dist/esm/control/RotateControl.js.map +1 -1
- package/dist/esm/control/ScaleControl.js +8 -11
- package/dist/esm/control/ScaleControl.js.map +1 -1
- package/dist/esm/control/SearchControl.js +100 -19
- package/dist/esm/control/SearchControl.js.map +1 -1
- package/dist/esm/control/SideBySideControl.js +2 -5
- package/dist/esm/control/SideBySideControl.js.map +1 -1
- package/dist/esm/control/TextControl.js +6 -9
- package/dist/esm/control/TextControl.js.map +1 -1
- package/dist/esm/control/TimeControl.js +407 -0
- package/dist/esm/control/TimeControl.js.map +1 -0
- package/dist/esm/control/ZoomControl.js +23 -36
- package/dist/esm/control/ZoomControl.js.map +1 -1
- package/dist/esm/core/Class.js +28 -44
- package/dist/esm/core/Class.js.map +1 -1
- package/dist/esm/core/Events.js +22 -10
- package/dist/esm/core/Events.js.map +1 -1
- package/dist/esm/core/Handler.js +23 -14
- package/dist/esm/core/Handler.js.map +1 -1
- package/dist/esm/core/I18n.js +1 -2
- package/dist/esm/core/Util.js +15 -4
- package/dist/esm/core/Util.js.map +1 -1
- package/dist/esm/dom/DomEvent.DoubleTap.js +26 -24
- package/dist/esm/dom/DomEvent.DoubleTap.js.map +1 -1
- package/dist/esm/dom/DomEvent.PointerEvents.js +3 -18
- package/dist/esm/dom/DomEvent.PointerEvents.js.map +1 -1
- package/dist/esm/dom/DomEvent.js +18 -60
- package/dist/esm/dom/DomEvent.js.map +1 -1
- package/dist/esm/dom/DomUtil.js +15 -70
- package/dist/esm/dom/DomUtil.js.map +1 -1
- package/dist/esm/dom/Draggable.js +21 -21
- package/dist/esm/dom/Draggable.js.map +1 -1
- package/dist/esm/dom/PosAnimation.js +4 -27
- package/dist/esm/dom/PosAnimation.js.map +1 -1
- package/dist/esm/geo/LatLng.js +16 -7
- package/dist/esm/geo/LatLng.js.map +1 -1
- package/dist/esm/geo/LatLngBounds.js +9 -15
- package/dist/esm/geo/LatLngBounds.js.map +1 -1
- package/dist/esm/geo/crs/CRS.js +1 -2
- package/dist/esm/geo/crs/EPSG3395.js +5 -6
- package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
- package/dist/esm/geo/crs/EPSG3857.js +5 -6
- package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
- package/dist/esm/geo/crs/EPSG4326.js +4 -5
- package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
- package/dist/esm/geo/crs/EarthCRS.js +3 -4
- package/dist/esm/geo/crs/EarthCRS.js.map +1 -1
- package/dist/esm/geo/crs/SimpleCRS.js +4 -5
- package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
- package/dist/esm/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +5 -6
- package/dist/esm/geo/projection/LonLatProjection.js.map +1 -0
- package/dist/esm/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +4 -5
- package/dist/esm/geo/projection/MercatorProjection.js.map +1 -0
- package/dist/esm/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +5 -6
- package/dist/esm/geo/projection/SphericalMercatorProjection.js.map +1 -0
- package/dist/esm/geometry/Bounds.js +10 -14
- package/dist/esm/geometry/Bounds.js.map +1 -1
- package/dist/esm/geometry/LineUtil.js +37 -32
- package/dist/esm/geometry/LineUtil.js.map +1 -1
- package/dist/esm/geometry/Point.js +1 -2
- package/dist/esm/geometry/PolyUtil.js +24 -51
- package/dist/esm/geometry/PolyUtil.js.map +1 -1
- package/dist/esm/geometry/Transformation.js +1 -2
- package/dist/esm/layer/BlanketOverlay.js +7 -10
- package/dist/esm/layer/BlanketOverlay.js.map +1 -1
- package/dist/esm/layer/Classification.js +1 -2
- package/dist/esm/layer/DivOverlay.js +16 -22
- package/dist/esm/layer/DivOverlay.js.map +1 -1
- package/dist/esm/layer/FeatureGroup.js +5 -4
- package/dist/esm/layer/FeatureGroup.js.map +1 -1
- package/dist/esm/layer/GeoJSON.Load.js +1 -2
- package/dist/esm/layer/GeoJSON.js +17 -155
- package/dist/esm/layer/GeoJSON.js.map +1 -1
- package/dist/esm/layer/GeoJSONUtil.js +74 -0
- package/dist/esm/layer/GeoJSONUtil.js.map +1 -0
- package/dist/esm/layer/HeatLayer.js +17 -20
- package/dist/esm/layer/HeatLayer.js.map +1 -1
- package/dist/esm/layer/ImageOverlay.js +22 -29
- package/dist/esm/layer/ImageOverlay.js.map +1 -1
- package/dist/esm/layer/Layer.js +9 -12
- package/dist/esm/layer/Layer.js.map +1 -1
- package/dist/esm/layer/LayerGroup.js +53 -3
- package/dist/esm/layer/LayerGroup.js.map +1 -1
- package/dist/esm/layer/Popup.js +35 -58
- package/dist/esm/layer/Popup.js.map +1 -1
- package/dist/esm/layer/SVGOverlay.js +3 -7
- package/dist/esm/layer/SVGOverlay.js.map +1 -1
- package/dist/esm/layer/Tooltip.js +31 -34
- package/dist/esm/layer/Tooltip.js.map +1 -1
- package/dist/esm/layer/VideoOverlay.js +13 -17
- package/dist/esm/layer/VideoOverlay.js.map +1 -1
- package/dist/esm/layer/marker/DefaultIcon.js +38 -49
- package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
- package/dist/esm/layer/marker/DivIcon.js +8 -11
- package/dist/esm/layer/marker/DivIcon.js.map +1 -1
- package/dist/esm/layer/marker/Icon.js +9 -12
- package/dist/esm/layer/marker/Icon.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Drag.js +44 -5
- package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Move.js +5 -8
- package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
- package/dist/esm/layer/marker/Marker.js +115 -47
- package/dist/esm/layer/marker/Marker.js.map +1 -1
- package/dist/esm/layer/marker/MarkerClusterGroup.js +301 -0
- package/dist/esm/layer/marker/MarkerClusterGroup.js.map +1 -0
- package/dist/esm/layer/marker/SvgIcon.js +7 -10
- package/dist/esm/layer/marker/SvgIcon.js.map +1 -1
- package/dist/esm/layer/tile/GridLayer.js +89 -101
- package/dist/esm/layer/tile/GridLayer.js.map +1 -1
- package/dist/esm/layer/tile/TileLayer.js +36 -44
- package/dist/esm/layer/tile/TileLayer.js.map +1 -1
- package/dist/esm/layer/tile/WMSTileLayer.js +33 -27
- package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
- package/dist/esm/layer/vector/Canvas.js +8 -17
- package/dist/esm/layer/vector/Canvas.js.map +1 -1
- package/dist/esm/layer/vector/Circle.js +6 -5
- package/dist/esm/layer/vector/Circle.js.map +1 -1
- package/dist/esm/layer/vector/CircleMarker.js +19 -10
- package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
- package/dist/esm/layer/vector/Path.DashAnimation.js +3 -5
- package/dist/esm/layer/vector/Path.DashAnimation.js.map +1 -1
- package/dist/esm/layer/vector/Path.ZoomStyles.js +1 -2
- package/dist/esm/layer/vector/Path.js +28 -22
- package/dist/esm/layer/vector/Path.js.map +1 -1
- package/dist/esm/layer/vector/Polygon.js +22 -7
- package/dist/esm/layer/vector/Polygon.js.map +1 -1
- package/dist/esm/layer/vector/Polyline.Decorations.js +3 -4
- package/dist/esm/layer/vector/Polyline.js +25 -10
- package/dist/esm/layer/vector/Polyline.js.map +1 -1
- package/dist/esm/layer/vector/Rectangle.js +1 -2
- package/dist/esm/layer/vector/Renderer.getRenderer.js +17 -17
- package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
- package/dist/esm/layer/vector/Renderer.js +1 -2
- package/dist/esm/layer/vector/SVG.js +12 -9
- package/dist/esm/layer/vector/SVG.js.map +1 -1
- package/dist/esm/map/Hash.js +1 -2
- package/dist/esm/map/Map.Rotation.js +41 -22
- package/dist/esm/map/Map.Rotation.js.map +1 -1
- package/dist/esm/map/Map.js +125 -126
- package/dist/esm/map/Map.js.map +1 -1
- package/dist/esm/map/MapSync.js +1 -2
- package/dist/esm/map/handler/BoxZoomHandler.js +25 -47
- package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/DisplaceHandler.js +7 -10
- package/dist/esm/map/handler/DisplaceHandler.js.map +1 -1
- package/dist/esm/map/handler/DoubleClickZoomHandler.js +1 -2
- package/dist/esm/map/handler/DragHandler.js +20 -21
- package/dist/esm/map/handler/DragHandler.js.map +1 -1
- package/dist/esm/map/handler/KeyboardHandler.js +48 -68
- package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
- package/dist/esm/map/handler/PinchZoomHandler.js +13 -5
- package/dist/esm/map/handler/PinchZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js +4 -6
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/TapDragZoomHandler.js +1 -2
- package/dist/esm/map/handler/TapHoldHandler.js +13 -7
- package/dist/esm/map/handler/TapHoldHandler.js.map +1 -1
- package/dist/esm/package.js +2 -3
- package/dist/maplair-global-src.js +6495 -5981
- package/dist/maplair-global-src.js.map +1 -1
- package/dist/maplair-global.js +2 -2
- package/dist/maplair-global.js.map +1 -1
- package/dist/maplair-src.js +6206 -5673
- package/dist/maplair-src.js.map +1 -1
- package/dist/maplair.css +1 -1213
- package/dist/maplair.js +2 -2
- package/dist/maplair.js.map +1 -1
- package/i18n/cs.json +6 -0
- package/i18n/de.json +6 -0
- package/i18n/en.json +6 -0
- package/i18n/es.json +6 -0
- package/i18n/fr.json +6 -0
- package/i18n/hu.json +6 -0
- package/i18n/it.json +6 -0
- package/i18n/rm.json +6 -0
- package/i18n/sk.json +6 -0
- package/i18n/sl.json +6 -0
- package/package.json +11 -18
- package/src/Maplair.all.js +0 -1
- package/src/control/AttributionControl.js +25 -18
- package/src/control/ButtonControl.js +9 -11
- package/src/control/ContextMenu.js +3 -5
- package/src/control/Control.js +9 -19
- package/src/control/FullscreenControl.js +5 -7
- package/src/control/LayersControl.js +196 -86
- package/src/control/LegendControl.js +7 -9
- package/src/control/MiniMapControl.js +9 -11
- package/src/control/RotateControl.js +3 -5
- package/src/control/ScaleControl.js +7 -9
- package/src/control/SearchControl.js +102 -19
- package/src/control/SideBySideControl.js +3 -5
- package/src/control/TextControl.js +5 -7
- package/src/control/TimeControl.js +471 -0
- package/src/control/ZoomControl.js +22 -38
- package/src/control/index.js +1 -0
- package/src/core/Class.js +37 -45
- package/src/core/Events.js +22 -3
- package/src/core/Handler.js +25 -13
- package/src/core/Util.js +20 -2
- package/src/core/index.js +0 -1
- package/src/dom/DomEvent.DoubleTap.js +18 -10
- package/src/dom/DomEvent.PointerEvents.js +3 -26
- package/src/dom/DomEvent.js +17 -85
- package/src/dom/DomUtil.js +22 -78
- package/src/dom/Draggable.js +32 -23
- package/src/dom/PosAnimation.js +3 -25
- package/src/dom/index.js +0 -1
- package/src/geo/LatLng.js +20 -3
- package/src/geo/LatLngBounds.js +8 -15
- package/src/geo/crs/EPSG3395.js +4 -4
- package/src/geo/crs/EPSG3857.js +4 -4
- package/src/geo/crs/EPSG4326.js +3 -3
- package/src/geo/crs/EarthCRS.js +2 -8
- package/src/geo/crs/SimpleCRS.js +3 -3
- package/src/geo/index.js +1 -2
- package/src/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +2 -2
- package/src/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +2 -2
- package/src/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +2 -2
- package/src/geo/projection/index.js +5 -5
- package/src/geometry/Bounds.js +12 -17
- package/src/geometry/LineUtil.js +48 -49
- package/src/geometry/PolyUtil.js +39 -76
- package/src/layer/BlanketOverlay.js +6 -10
- package/src/layer/DivOverlay.js +16 -27
- package/src/layer/FeatureGroup.js +8 -2
- package/src/layer/GeoJSON.js +17 -218
- package/src/layer/GeoJSONUtil.js +85 -0
- package/src/layer/HeatLayer.js +10 -12
- package/src/layer/ImageOverlay.js +21 -32
- package/src/layer/Layer.js +8 -10
- package/src/layer/LayerGroup.js +72 -1
- package/src/layer/Popup.js +37 -62
- package/src/layer/SVGOverlay.js +1 -5
- package/src/layer/Tooltip.js +34 -36
- package/src/layer/VideoOverlay.js +12 -15
- package/src/layer/marker/DefaultIcon.js +40 -58
- package/src/layer/marker/DivIcon.js +9 -11
- package/src/layer/marker/Icon.js +9 -10
- package/src/layer/marker/Marker.Drag.js +54 -6
- package/src/layer/marker/Marker.Move.js +4 -6
- package/src/layer/marker/Marker.js +145 -52
- package/src/layer/marker/MarkerClusterGroup.js +370 -0
- package/src/layer/marker/SvgIcon.js +7 -9
- package/src/layer/marker/index.js +1 -0
- package/src/layer/tile/GridLayer.js +108 -135
- package/src/layer/tile/TileLayer.js +44 -49
- package/src/layer/tile/WMSTileLayer.js +31 -26
- package/src/layer/vector/Canvas.js +13 -19
- package/src/layer/vector/Circle.js +9 -3
- package/src/layer/vector/CircleMarker.js +19 -7
- package/src/layer/vector/Path.DashAnimation.js +1 -2
- package/src/layer/vector/Path.js +30 -21
- package/src/layer/vector/Polygon.js +29 -6
- package/src/layer/vector/Polyline.js +26 -7
- package/src/layer/vector/Renderer.getRenderer.js +20 -19
- package/src/layer/vector/SVG.js +17 -7
- package/src/map/Map.Rotation.js +40 -8
- package/src/map/Map.js +158 -153
- package/src/map/handler/BoxZoomHandler.js +30 -50
- package/src/map/handler/DisplaceHandler.js +6 -8
- package/src/map/handler/DragHandler.js +25 -28
- package/src/map/handler/KeyboardHandler.js +65 -90
- package/src/map/handler/PinchZoomHandler.js +16 -5
- package/src/map/handler/ScrollWheelZoomHandler.js +6 -4
- package/src/map/handler/TapHoldHandler.js +15 -4
- package/src/map/index.js +1 -1
- package/src/maplair.css +153 -98
- package/dist/esm/core/Browser.js +0 -100
- package/dist/esm/core/Browser.js.map +0 -1
- package/dist/esm/geo/projection/Projection.LonLat.js.map +0 -1
- package/dist/esm/geo/projection/Projection.Mercator.js.map +0 -1
- package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +0 -1
- package/dist/esm/geo/projection/index.js +0 -14
- package/dist/esm/geo/projection/index.js.map +0 -1
- package/dist/esm/layer/marker/Marker.Rotation.js +0 -70
- package/dist/esm/layer/marker/Marker.Rotation.js.map +0 -1
- package/dist/images/layers.svg +0 -1
- package/dist/images/marker-icon.svg +0 -1
- package/dist/images/marker-shadow.svg +0 -1
- package/src/core/Browser.js +0 -110
- package/src/images/layers.svg +0 -1
- package/src/images/marker-icon.svg +0 -1
- package/src/images/marker-shadow.svg +0 -1
- package/src/layer/marker/Marker.Rotation.js +0 -103
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {Layer} from '../Layer.js';
|
|
2
|
-
import Browser from '../../core/Browser.js';
|
|
3
2
|
import * as Util from '../../core/Util.js';
|
|
4
3
|
import * as DomUtil from '../../dom/DomUtil.js';
|
|
5
4
|
import {Point} from '../../geometry/Point.js';
|
|
@@ -22,16 +21,13 @@ import {LatLngBounds} from '../../geo/LatLngBounds.js';
|
|
|
22
21
|
* of tiles while they are loading, e.g. `'#ddd'` or
|
|
23
22
|
* `'url(loading.svg) center no-repeat #eee'`. Tiles with a placeholder appear without
|
|
24
23
|
* fading in.
|
|
25
|
-
* @property {boolean} [updateWhenIdle] Load new tiles only when panning ends.
|
|
26
|
-
* to `false` (tiles are loaded _during_ panning) unless the browser is configured for
|
|
27
|
-
* reduced motion.
|
|
24
|
+
* @property {boolean} [updateWhenIdle=false] Load new tiles only when panning ends.
|
|
28
25
|
* @property {boolean} [updateWhenZooming=true] By default, a smooth zoom animation
|
|
29
26
|
* (during a [pinch zoom](#map-pinchzoom) or a [`flyTo()`](#map-flyto)) will update grid
|
|
30
27
|
* layers every integer zoom level. Setting this option to `false` will update the grid
|
|
31
28
|
* layer only when the smooth animation ends.
|
|
32
|
-
* @property {number} [updateInterval] Tiles will not update more than once every
|
|
33
|
-
* `updateInterval` milliseconds when panning.
|
|
34
|
-
* seconds if the browser is configured for reduced motion.
|
|
29
|
+
* @property {number} [updateInterval=200] Tiles will not update more than once every
|
|
30
|
+
* `updateInterval` milliseconds when panning.
|
|
35
31
|
* @property {number} [zIndex=1] The explicit zIndex of the tile layer.
|
|
36
32
|
* @property {LatLngBoundsExpression|null} [bounds=null] If set, tiles will only be
|
|
37
33
|
* loaded inside the set `LatLngBounds`.
|
|
@@ -144,27 +140,25 @@ import {LatLngBounds} from '../../geo/LatLngBounds.js';
|
|
|
144
140
|
*/
|
|
145
141
|
export class GridLayer extends Layer {
|
|
146
142
|
|
|
147
|
-
static {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
});
|
|
167
|
-
}
|
|
143
|
+
static defaultOptions = {
|
|
144
|
+
tileSize: 256,
|
|
145
|
+
opacity: 1,
|
|
146
|
+
placeholder: null,
|
|
147
|
+
updateWhenIdle: false,
|
|
148
|
+
updateWhenZooming: true,
|
|
149
|
+
updateInterval: 200,
|
|
150
|
+
zIndex: 1,
|
|
151
|
+
bounds: null,
|
|
152
|
+
minZoom: 0,
|
|
153
|
+
maxZoom: undefined,
|
|
154
|
+
maxNativeZoom: undefined,
|
|
155
|
+
minNativeZoom: undefined,
|
|
156
|
+
noWrap: false,
|
|
157
|
+
pane: 'tilePane',
|
|
158
|
+
className: '',
|
|
159
|
+
pixelated: false,
|
|
160
|
+
keepBuffer: 2
|
|
161
|
+
};
|
|
168
162
|
|
|
169
163
|
/**
|
|
170
164
|
* Creates a new instance of GridLayer with the supplied options.
|
|
@@ -212,6 +206,8 @@ export class GridLayer extends Layer {
|
|
|
212
206
|
this._container = null;
|
|
213
207
|
this._tileZoom = undefined;
|
|
214
208
|
clearTimeout(this._pruneTimeout);
|
|
209
|
+
cancelAnimationFrame(this._fadePruneFrame);
|
|
210
|
+
this._fadePruneFrame = 0;
|
|
215
211
|
}
|
|
216
212
|
|
|
217
213
|
/**
|
|
@@ -274,7 +270,7 @@ export class GridLayer extends Layer {
|
|
|
274
270
|
* @returns {boolean}
|
|
275
271
|
*/
|
|
276
272
|
isLoading() {
|
|
277
|
-
return this._loading;
|
|
273
|
+
return !!this._loading;
|
|
278
274
|
}
|
|
279
275
|
|
|
280
276
|
/**
|
|
@@ -284,7 +280,7 @@ export class GridLayer extends Layer {
|
|
|
284
280
|
redraw() {
|
|
285
281
|
if (this._map) {
|
|
286
282
|
this._removeAllTiles();
|
|
287
|
-
const tileZoom = this._clampZoom(this._map.getZoom());
|
|
283
|
+
const tileZoom = this._clampZoom(Math.round(this._map.getZoom()));
|
|
288
284
|
if (tileZoom !== this._tileZoom) {
|
|
289
285
|
this._tileZoom = tileZoom;
|
|
290
286
|
this._updateLevels();
|
|
@@ -303,7 +299,9 @@ export class GridLayer extends Layer {
|
|
|
303
299
|
viewprereset: this._invalidateAll,
|
|
304
300
|
viewreset: this._resetView,
|
|
305
301
|
zoom: this._resetView,
|
|
306
|
-
moveend: this._onMoveEnd
|
|
302
|
+
moveend: this._onMoveEnd,
|
|
303
|
+
worldcopyjump: this._onWorldCopyJump,
|
|
304
|
+
zoomanim: this._animateZoom
|
|
307
305
|
};
|
|
308
306
|
|
|
309
307
|
if (!this.options.updateWhenIdle) {
|
|
@@ -315,10 +313,6 @@ export class GridLayer extends Layer {
|
|
|
315
313
|
events.move = this._onMove;
|
|
316
314
|
}
|
|
317
315
|
|
|
318
|
-
if (this._zoomAnimated) {
|
|
319
|
-
events.zoomanim = this._animateZoom;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
316
|
return events;
|
|
323
317
|
}
|
|
324
318
|
|
|
@@ -350,7 +344,7 @@ export class GridLayer extends Layer {
|
|
|
350
344
|
|
|
351
345
|
_updateZIndex() {
|
|
352
346
|
if (this._container && this.options.zIndex !== undefined && this.options.zIndex !== null) {
|
|
353
|
-
this._container.style.zIndex = this.options.zIndex
|
|
347
|
+
this._container.style.zIndex = `${this.options.zIndex}`;
|
|
354
348
|
}
|
|
355
349
|
}
|
|
356
350
|
|
|
@@ -377,36 +371,7 @@ export class GridLayer extends Layer {
|
|
|
377
371
|
_updateOpacity() {
|
|
378
372
|
if (!this._map) { return; }
|
|
379
373
|
|
|
380
|
-
this._container.style.opacity = this.options.opacity
|
|
381
|
-
|
|
382
|
-
const now = Date.now();
|
|
383
|
-
let nextFrame = false,
|
|
384
|
-
willPrune = false;
|
|
385
|
-
|
|
386
|
-
for (const tile of Object.values(this._tiles ?? {})) {
|
|
387
|
-
if (!tile.current || !tile.loaded) { continue; }
|
|
388
|
-
|
|
389
|
-
const fade = tile.noFade ? 1 : Math.min(1, (now - tile.loaded) / 200);
|
|
390
|
-
|
|
391
|
-
tile.el.style.opacity = fade;
|
|
392
|
-
if (fade < 1) {
|
|
393
|
-
nextFrame = true;
|
|
394
|
-
} else {
|
|
395
|
-
if (tile.active) {
|
|
396
|
-
willPrune = true;
|
|
397
|
-
} else {
|
|
398
|
-
this._onOpaqueTile(tile);
|
|
399
|
-
}
|
|
400
|
-
tile.active = true;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
if (willPrune && !this._noPrune) { this._pruneTiles(); }
|
|
405
|
-
|
|
406
|
-
if (nextFrame) {
|
|
407
|
-
cancelAnimationFrame(this._fadeFrame);
|
|
408
|
-
this._fadeFrame = requestAnimationFrame(this._updateOpacity.bind(this));
|
|
409
|
-
}
|
|
374
|
+
this._container.style.opacity = `${this.options.opacity}`;
|
|
410
375
|
}
|
|
411
376
|
|
|
412
377
|
_onOpaqueTile() {}
|
|
@@ -487,7 +452,7 @@ export class GridLayer extends Layer {
|
|
|
487
452
|
for (let z of Object.keys(this._levels)) {
|
|
488
453
|
z = Number(z);
|
|
489
454
|
if (this._levels[z].el.children.length || z === zoom) {
|
|
490
|
-
this._levels[z].el.style.zIndex = maxZoom - Math.abs(zoom - z)
|
|
455
|
+
this._levels[z].el.style.zIndex = `${maxZoom - Math.abs(zoom - z)}`;
|
|
491
456
|
this._onUpdateLevel(z);
|
|
492
457
|
} else {
|
|
493
458
|
this._levels[z].el.remove();
|
|
@@ -504,7 +469,7 @@ export class GridLayer extends Layer {
|
|
|
504
469
|
level = this._levels[zoom] = {};
|
|
505
470
|
|
|
506
471
|
level.el = DomUtil.create('div', 'maplair-tile-container maplair-zoom-animated', this._container);
|
|
507
|
-
level.el.style.zIndex = maxZoom
|
|
472
|
+
level.el.style.zIndex = `${maxZoom}`;
|
|
508
473
|
|
|
509
474
|
level.origin = map.project(map.unproject(map.getPixelOrigin()), zoom).round();
|
|
510
475
|
level.zoom = zoom;
|
|
@@ -574,7 +539,12 @@ export class GridLayer extends Layer {
|
|
|
574
539
|
}
|
|
575
540
|
}
|
|
576
541
|
|
|
577
|
-
_invalidateAll() {
|
|
542
|
+
_invalidateAll(e) {
|
|
543
|
+
// a zoom without animation keeps the old levels until new tiles load, like the end of an animated one,
|
|
544
|
+
// unless the view jumps somewhere else
|
|
545
|
+
const map = this._map;
|
|
546
|
+
if (e?.zoom !== undefined && e.zoom !== map.getZoom() && map.getBounds().contains(e.center)) { return; }
|
|
547
|
+
|
|
578
548
|
for (const z of Object.keys(this._levels)) {
|
|
579
549
|
this._levels[z].el.remove();
|
|
580
550
|
this._onRemoveLevel(Number(z));
|
|
@@ -586,56 +556,31 @@ export class GridLayer extends Layer {
|
|
|
586
556
|
}
|
|
587
557
|
|
|
588
558
|
_retainParent(x, y, z, minZoom) {
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
coords2.z = +z2;
|
|
594
|
-
|
|
595
|
-
const key = this._tileCoordsToKey(coords2),
|
|
596
|
-
tile = this._tiles[key];
|
|
597
|
-
|
|
598
|
-
if (tile?.active) {
|
|
599
|
-
tile.retain = true;
|
|
600
|
-
return true;
|
|
601
|
-
|
|
602
|
-
} else if (tile?.loaded) {
|
|
603
|
-
tile.retain = true;
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
if (z2 > minZoom) {
|
|
607
|
-
return this._retainParent(x2, y2, z2, minZoom);
|
|
559
|
+
for (z--; z >= minZoom; z--) {
|
|
560
|
+
x = Math.floor(x / 2);
|
|
561
|
+
y = Math.floor(y / 2);
|
|
562
|
+
if (this._retain(x, y, z)) { return true; }
|
|
608
563
|
}
|
|
609
|
-
|
|
610
564
|
return false;
|
|
611
565
|
}
|
|
612
566
|
|
|
613
567
|
_retainChildren(x, y, z, maxZoom) {
|
|
614
|
-
|
|
615
568
|
for (let i = 2 * x; i < 2 * x + 2; i++) {
|
|
616
569
|
for (let j = 2 * y; j < 2 * y + 2; j++) {
|
|
617
|
-
|
|
618
|
-
const coords = new Point(i, j);
|
|
619
|
-
coords.z = z + 1;
|
|
620
|
-
|
|
621
|
-
const key = this._tileCoordsToKey(coords),
|
|
622
|
-
tile = this._tiles[key];
|
|
623
|
-
|
|
624
|
-
if (tile?.active) {
|
|
625
|
-
tile.retain = true;
|
|
626
|
-
continue;
|
|
627
|
-
|
|
628
|
-
} else if (tile?.loaded) {
|
|
629
|
-
tile.retain = true;
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
if (z + 1 < maxZoom) {
|
|
570
|
+
if (!this._retain(i, j, z + 1) && z + 1 < maxZoom) {
|
|
633
571
|
this._retainChildren(i, j, z + 1, maxZoom);
|
|
634
572
|
}
|
|
635
573
|
}
|
|
636
574
|
}
|
|
637
575
|
}
|
|
638
576
|
|
|
577
|
+
// retains the tile if it's loaded; returns true if it's active, so there's no need to look further
|
|
578
|
+
_retain(x, y, z) {
|
|
579
|
+
const tile = this._tiles[this._tileCoordsToKey({x, y, z})];
|
|
580
|
+
if (tile?.loaded) { tile.retain = true; }
|
|
581
|
+
return tile?.active;
|
|
582
|
+
}
|
|
583
|
+
|
|
639
584
|
_resetView(e) {
|
|
640
585
|
const animating = e && (e.pinch || e.flyTo || e.continuous);
|
|
641
586
|
this._setView(this._map.getCenter(), this._map.getZoom(), animating, animating);
|
|
@@ -689,7 +634,7 @@ export class GridLayer extends Layer {
|
|
|
689
634
|
this._pruneTiles();
|
|
690
635
|
}
|
|
691
636
|
|
|
692
|
-
// Flag to prevent
|
|
637
|
+
// Flag to prevent finished tile fades from pruning tiles during
|
|
693
638
|
// a zoom anim or a pinch gesture
|
|
694
639
|
this._noPrune = !!noPrune;
|
|
695
640
|
}
|
|
@@ -724,10 +669,10 @@ export class GridLayer extends Layer {
|
|
|
724
669
|
|
|
725
670
|
this._wrapX = crs.wrapLng && !this.options.noWrap && [
|
|
726
671
|
Math.floor(map.project([0, crs.wrapLng[0]], tileZoom).x / tileSize.x),
|
|
727
|
-
Math.ceil(map.project([0, crs.wrapLng[1]], tileZoom).x / tileSize.
|
|
672
|
+
Math.ceil(map.project([0, crs.wrapLng[1]], tileZoom).x / tileSize.x)
|
|
728
673
|
];
|
|
729
674
|
this._wrapY = crs.wrapLat && !this.options.noWrap && [
|
|
730
|
-
Math.floor(map.project([crs.wrapLat[0], 0], tileZoom).y / tileSize.
|
|
675
|
+
Math.floor(map.project([crs.wrapLat[0], 0], tileZoom).y / tileSize.y),
|
|
731
676
|
Math.ceil(map.project([crs.wrapLat[1], 0], tileZoom).y / tileSize.y)
|
|
732
677
|
];
|
|
733
678
|
}
|
|
@@ -738,6 +683,28 @@ export class GridLayer extends Layer {
|
|
|
738
683
|
this._update();
|
|
739
684
|
}
|
|
740
685
|
|
|
686
|
+
_onWorldCopyJump({worlds}) {
|
|
687
|
+
// noWrap tiles cannot be reused in another world copy.
|
|
688
|
+
if (!this._wrapX) { return; }
|
|
689
|
+
|
|
690
|
+
const tileSize = this.getTileSize(),
|
|
691
|
+
tiles = {};
|
|
692
|
+
|
|
693
|
+
for (const tile of Object.values(this._tiles)) {
|
|
694
|
+
const {coords, el} = tile,
|
|
695
|
+
dx = worlds * this._map.getPixelWorldBounds(coords.z).getSize().x;
|
|
696
|
+
|
|
697
|
+
// tiles can't be shifted by a fraction of a column, so leave those to be reloaded
|
|
698
|
+
if (dx % tileSize.x === 0) {
|
|
699
|
+
coords.x -= dx / tileSize.x;
|
|
700
|
+
DomUtil.setPosition(el, DomUtil.getPosition(el).subtract([dx, 0]), true);
|
|
701
|
+
}
|
|
702
|
+
tiles[this._tileCoordsToKey(coords)] = tile;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
this._tiles = tiles;
|
|
706
|
+
}
|
|
707
|
+
|
|
741
708
|
_getTiledPixelBounds(center) {
|
|
742
709
|
const map = this._map,
|
|
743
710
|
mapZoom = map._animatingZoom ? Math.max(map._animateToZoom, map.getZoom()) : map.getZoom(),
|
|
@@ -838,10 +805,6 @@ export class GridLayer extends Layer {
|
|
|
838
805
|
return LatLngBounds.from(this.options.bounds).overlaps(tileBounds);
|
|
839
806
|
}
|
|
840
807
|
|
|
841
|
-
_keyToBounds(key) {
|
|
842
|
-
return this._tileCoordsToBounds(this._keyToTileCoords(key));
|
|
843
|
-
}
|
|
844
|
-
|
|
845
808
|
_tileCoordsToNwSe(coords) {
|
|
846
809
|
const map = this._map,
|
|
847
810
|
tileSize = this.getTileSize(),
|
|
@@ -867,14 +830,6 @@ export class GridLayer extends Layer {
|
|
|
867
830
|
return `${coords.x}:${coords.y}:${coords.z}`;
|
|
868
831
|
}
|
|
869
832
|
|
|
870
|
-
// converts tile cache key to coordinates
|
|
871
|
-
_keyToTileCoords(key) {
|
|
872
|
-
const k = key.split(':'),
|
|
873
|
-
coords = new Point(+k[0], +k[1]);
|
|
874
|
-
coords.z = +k[2];
|
|
875
|
-
return coords;
|
|
876
|
-
}
|
|
877
|
-
|
|
878
833
|
_removeTile(key) {
|
|
879
834
|
const tile = this._tiles[key];
|
|
880
835
|
if (!tile) { return; }
|
|
@@ -885,7 +840,7 @@ export class GridLayer extends Layer {
|
|
|
885
840
|
|
|
886
841
|
this.fire('tileunload', {
|
|
887
842
|
tile: tile.el,
|
|
888
|
-
coords:
|
|
843
|
+
coords: tile.coords
|
|
889
844
|
});
|
|
890
845
|
}
|
|
891
846
|
|
|
@@ -896,9 +851,6 @@ export class GridLayer extends Layer {
|
|
|
896
851
|
tile.style.width = `${tileSize.x}px`;
|
|
897
852
|
tile.style.height = `${tileSize.y}px`;
|
|
898
853
|
|
|
899
|
-
tile.onselectstart = Util.falseFn;
|
|
900
|
-
tile.onpointermove = Util.falseFn;
|
|
901
|
-
|
|
902
854
|
if (this.options.placeholder) {
|
|
903
855
|
tile.style.background = this.options.placeholder;
|
|
904
856
|
}
|
|
@@ -919,7 +871,9 @@ export class GridLayer extends Layer {
|
|
|
919
871
|
requestAnimationFrame(this._tileReady.bind(this, coords, null, tile));
|
|
920
872
|
}
|
|
921
873
|
|
|
922
|
-
|
|
874
|
+
// 2D, so tiles raster into the level's layer: as separate layers they get compositor edge antialiasing,
|
|
875
|
+
// and the overlapping edge ramps show as light seams under plus-lighter blending
|
|
876
|
+
DomUtil.setPosition(tile, tilePos, true);
|
|
923
877
|
|
|
924
878
|
// save tile in cache
|
|
925
879
|
this._tiles[key] = {
|
|
@@ -949,20 +903,20 @@ export class GridLayer extends Layer {
|
|
|
949
903
|
tile = this._tiles[key];
|
|
950
904
|
if (!tile) { return; }
|
|
951
905
|
|
|
952
|
-
tile.loaded = Date.now();
|
|
953
906
|
if (this.options.placeholder) {
|
|
954
|
-
// fading in would show the map below instead of the placeholder at first
|
|
955
|
-
tile.noFade = true;
|
|
956
907
|
tile.el.style.background = '';
|
|
957
908
|
}
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
cancelAnimationFrame(this._fadeFrame);
|
|
961
|
-
this._fadeFrame = requestAnimationFrame(this._updateOpacity.bind(this));
|
|
962
|
-
} else {
|
|
909
|
+
// fading in with a placeholder would show the map below instead of the placeholder at first
|
|
910
|
+
if (!this._map._fadeAnimated || this.options.placeholder) {
|
|
963
911
|
tile.active = true;
|
|
964
912
|
this._pruneTiles();
|
|
913
|
+
} else if (!tile.loaded) { // with errorTileUrl, a tile is ready twice (on error and on fallback load)
|
|
914
|
+
// while fading, the tile is a compositor layer of its own where plus-lighter would light up its
|
|
915
|
+
// antialiased edges, so it's blended normally until the fade ends
|
|
916
|
+
tile.el.classList.add('maplair-tile-fading');
|
|
917
|
+
tile.el.animate({opacity: [0, 1]}, 200).onfinish = this._onTileFaded.bind(this, tile);
|
|
965
918
|
}
|
|
919
|
+
tile.loaded = true;
|
|
966
920
|
|
|
967
921
|
if (!err) {
|
|
968
922
|
tile.el.classList.add('maplair-tile-loaded');
|
|
@@ -973,9 +927,12 @@ export class GridLayer extends Layer {
|
|
|
973
927
|
});
|
|
974
928
|
}
|
|
975
929
|
|
|
976
|
-
|
|
930
|
+
// a tileload listener may have removed the layer, emptying the tile list
|
|
931
|
+
if (this._map && this._noTilesToLoad()) {
|
|
977
932
|
this._loading = false;
|
|
978
933
|
this.fire('load');
|
|
934
|
+
|
|
935
|
+
if (!this._map) { return; } // removed by a load listener
|
|
979
936
|
this._map._scheduleIdleCheck();
|
|
980
937
|
|
|
981
938
|
if (!this._map._fadeAnimated) {
|
|
@@ -988,6 +945,22 @@ export class GridLayer extends Layer {
|
|
|
988
945
|
}
|
|
989
946
|
}
|
|
990
947
|
|
|
948
|
+
_onTileFaded(tile) {
|
|
949
|
+
tile.el.classList.remove('maplair-tile-fading');
|
|
950
|
+
// the tile's key may have changed after a world copy jump, so look it up again
|
|
951
|
+
if (this._tiles[this._tileCoordsToKey(tile.coords)] !== tile) { return; }
|
|
952
|
+
|
|
953
|
+
tile.active = true;
|
|
954
|
+
this._onOpaqueTile(tile);
|
|
955
|
+
|
|
956
|
+
// one prune for all the tiles that finish fading in the same frame
|
|
957
|
+
if (this._noPrune || this._fadePruneFrame) { return; }
|
|
958
|
+
this._fadePruneFrame = requestAnimationFrame(() => {
|
|
959
|
+
this._fadePruneFrame = 0;
|
|
960
|
+
if (!this._noPrune) { this._pruneTiles(); }
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
|
|
991
964
|
_getTilePos(coords) {
|
|
992
965
|
return coords.scaleBy(this.getTileSize()).subtract(this._level.origin);
|
|
993
966
|
}
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import {GridLayer} from './GridLayer.js';
|
|
2
|
-
import Browser from '../../core/Browser.js';
|
|
3
2
|
import * as Util from '../../core/Util.js';
|
|
4
3
|
import * as DomEvent from '../../dom/DomEvent.js';
|
|
5
4
|
import {I18n} from '../../core/I18n.js';
|
|
6
|
-
|
|
5
|
+
import {Point} from '../../geometry/Point.js';
|
|
7
6
|
/** @import {GridLayerOptions, TileDoneCallback} from './GridLayer.js' */
|
|
8
7
|
/** @import {TileEvent} from '../../core/Events.js' */
|
|
9
8
|
|
|
9
|
+
const osmHosts = ['tile.openstreetmap.org', 'tile.osm.org'];
|
|
10
|
+
const hostRe = /^(https?:)?\/\/([^/?#:]*)/i;
|
|
11
|
+
const httpRe = /^http:/i;
|
|
12
|
+
|
|
13
|
+
function isOSMUrl(url) {
|
|
14
|
+
const host = hostRe.exec(url)?.[2] ?? '';
|
|
15
|
+
return osmHosts.some(osmHost => host === osmHost || host.endsWith(`.${osmHost}`));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// OSM tiles are upgraded to HTTPS so that the referrer policy works
|
|
19
|
+
const upgradeOSMUrl = url => (isOSMUrl(url) ? url.replace(httpRe, 'https:') : url);
|
|
20
|
+
|
|
10
21
|
/**
|
|
11
22
|
* Options of `TileLayer`.
|
|
12
23
|
* @typedef {object} TileLayerOptions
|
|
@@ -89,22 +100,20 @@ import {I18n} from '../../core/I18n.js';
|
|
|
89
100
|
*/
|
|
90
101
|
export class TileLayer extends GridLayer {
|
|
91
102
|
|
|
92
|
-
static {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
});
|
|
107
|
-
}
|
|
103
|
+
static defaultOptions = {
|
|
104
|
+
minZoom: 0,
|
|
105
|
+
maxZoom: 18,
|
|
106
|
+
subdomains: 'abc',
|
|
107
|
+
errorTileUrl: '',
|
|
108
|
+
zoomOffset: 0,
|
|
109
|
+
tms: false,
|
|
110
|
+
zoomReverse: false,
|
|
111
|
+
detectRetina: false,
|
|
112
|
+
crossOrigin: false,
|
|
113
|
+
referrerPolicy: 'strict-origin-when-cross-origin',
|
|
114
|
+
fetchOptions: null
|
|
115
|
+
|
|
116
|
+
};
|
|
108
117
|
|
|
109
118
|
/**
|
|
110
119
|
* Instantiates a tile layer object given a [URL template](#tilelayer) and optionally an
|
|
@@ -116,23 +125,13 @@ export class TileLayer extends GridLayer {
|
|
|
116
125
|
constructor(url, options) {
|
|
117
126
|
super(options);
|
|
118
127
|
|
|
119
|
-
this._url = url;
|
|
120
|
-
|
|
121
128
|
options = Util.setOptions(this, options);
|
|
122
129
|
|
|
123
|
-
// Set required OpenStreetMap attribution if it hasn't been specified
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const osmHosts = ['tile.openstreetmap.org', 'tile.osm.org'];
|
|
127
|
-
if (osmHosts.some(host => urlHostname.endsWith(host))) {
|
|
128
|
-
if (options.attribution === null) {
|
|
129
|
-
options.attribution = `© <a href="https://www.openstreetmap.org/copyright">${I18n.translate('OpenStreetMap contributors')}</a>`;
|
|
130
|
-
}
|
|
131
|
-
if (tileUrl.protocol === 'http:') {
|
|
132
|
-
tileUrl.protocol = 'https:';
|
|
133
|
-
this._url = tileUrl.toString();
|
|
134
|
-
}
|
|
130
|
+
// Set required OpenStreetMap attribution if it hasn't been specified
|
|
131
|
+
if (isOSMUrl(url) && options.attribution === null) {
|
|
132
|
+
options.attribution = `© <a href="https://www.openstreetmap.org/copyright">${I18n.translate('OpenStreetMap contributors')}</a>`;
|
|
135
133
|
}
|
|
134
|
+
this._url = upgradeOSMUrl(url);
|
|
136
135
|
|
|
137
136
|
const {tileSize, zoomOffset, minZoom, maxZoom, minNativeZoom, maxNativeZoom} = this.options;
|
|
138
137
|
this._nonRetinaOptions = {tileSize, zoomOffset, minZoom, maxZoom, minNativeZoom, maxNativeZoom};
|
|
@@ -142,19 +141,18 @@ export class TileLayer extends GridLayer {
|
|
|
142
141
|
this.options.subdomains = this.options.subdomains.split('');
|
|
143
142
|
}
|
|
144
143
|
|
|
145
|
-
this.on('tileunload', this._onTileRemove);
|
|
146
|
-
|
|
147
144
|
this.callInitHooks(TileLayer);
|
|
148
145
|
}
|
|
149
146
|
|
|
150
147
|
// Detects retina displays (if `detectRetina` is set), adjusting tileSize and zoom levels.
|
|
151
148
|
_applyRetina() {
|
|
152
149
|
Object.assign(this.options, this._nonRetinaOptions);
|
|
153
|
-
this._retina =
|
|
150
|
+
this._retina = window.devicePixelRatio > 1;
|
|
154
151
|
|
|
155
152
|
if (this.options.detectRetina && this._retina && this.options.maxZoom > 0) {
|
|
156
153
|
|
|
157
|
-
|
|
154
|
+
const tileSize = this.options.tileSize;
|
|
155
|
+
this.options.tileSize = tileSize instanceof Point ? tileSize.divideBy(2).floor() : Math.floor(tileSize / 2);
|
|
158
156
|
|
|
159
157
|
if (!this.options.zoomReverse) {
|
|
160
158
|
this.options.zoomOffset++;
|
|
@@ -193,7 +191,7 @@ export class TileLayer extends GridLayer {
|
|
|
193
191
|
|
|
194
192
|
// Loads the tiles for the new resolution, see the map's `pixelratiochange` event.
|
|
195
193
|
_onPixelRatioChange() {
|
|
196
|
-
if (
|
|
194
|
+
if ((window.devicePixelRatio > 1) === this._retina) { return; }
|
|
197
195
|
const map = this._map;
|
|
198
196
|
this._applyRetina();
|
|
199
197
|
if (this.options.detectRetina) {
|
|
@@ -216,6 +214,8 @@ export class TileLayer extends GridLayer {
|
|
|
216
214
|
* @returns {this}
|
|
217
215
|
*/
|
|
218
216
|
setUrl(url, noRedraw) {
|
|
217
|
+
url = upgradeOSMUrl(url);
|
|
218
|
+
|
|
219
219
|
if (this._url === url && noRedraw === undefined) {
|
|
220
220
|
noRedraw = true;
|
|
221
221
|
}
|
|
@@ -319,7 +319,7 @@ export class TileLayer extends GridLayer {
|
|
|
319
319
|
getTileUrl(coords) {
|
|
320
320
|
const data = Object.create(this.options);
|
|
321
321
|
Object.assign(data, {
|
|
322
|
-
r:
|
|
322
|
+
r: window.devicePixelRatio > 1 ? '@2x' : '',
|
|
323
323
|
s: this._getSubdomain(coords),
|
|
324
324
|
x: coords.x,
|
|
325
325
|
y: coords.y,
|
|
@@ -345,17 +345,15 @@ export class TileLayer extends GridLayer {
|
|
|
345
345
|
}
|
|
346
346
|
|
|
347
347
|
_tileOnError(done, tile, e) {
|
|
348
|
-
const errorUrl = this.options.errorTileUrl
|
|
349
|
-
|
|
348
|
+
const errorUrl = this.options.errorTileUrl,
|
|
349
|
+
src = tile.getAttribute('src');
|
|
350
|
+
// removed tiles get an empty src to cancel their request, which fires error too
|
|
351
|
+
if (errorUrl && src !== errorUrl && (src || tile.isConnected)) {
|
|
350
352
|
tile.src = errorUrl;
|
|
351
353
|
}
|
|
352
354
|
done(e, tile);
|
|
353
355
|
}
|
|
354
356
|
|
|
355
|
-
_onTileRemove(e) {
|
|
356
|
-
e.tile.onload = null;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
357
|
_getZoomForUrl() {
|
|
360
358
|
let zoom = this._tileZoom;
|
|
361
359
|
const maxZoom = this.options.maxZoom,
|
|
@@ -370,8 +368,8 @@ export class TileLayer extends GridLayer {
|
|
|
370
368
|
}
|
|
371
369
|
|
|
372
370
|
_getSubdomain(tilePoint) {
|
|
373
|
-
const
|
|
374
|
-
return
|
|
371
|
+
const {subdomains} = this.options;
|
|
372
|
+
return subdomains?.[Math.abs(tilePoint.x + tilePoint.y) % subdomains.length];
|
|
375
373
|
}
|
|
376
374
|
|
|
377
375
|
// stops loading all tiles in the background layer
|
|
@@ -381,9 +379,6 @@ export class TileLayer extends GridLayer {
|
|
|
381
379
|
if (this._tiles[i].coords.z !== this._tileZoom) {
|
|
382
380
|
tile = this._tiles[i].el;
|
|
383
381
|
|
|
384
|
-
tile.onload = Util.falseFn;
|
|
385
|
-
tile.onerror = Util.falseFn;
|
|
386
|
-
|
|
387
382
|
if (this._abortTileFetch(tile) || !tile.complete) {
|
|
388
383
|
tile.setAttribute('src', '');
|
|
389
384
|
const coords = this._tiles[i].coords;
|