@mapcomponents/react-maplibre 0.1.30 → 0.1.33
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 +10 -1
- package/coverage/clover.xml +50 -50
- package/coverage/coverage-final.json +15 -15
- package/coverage/lcov-report/index.html +17 -17
- package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.js.html +1 -1
- package/coverage/lcov-report/src/components/MapLibreMap/index.html +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.js.html +11 -11
- package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +11 -11
- package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.js.html +1 -1
- package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.js.html +4 -4
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.js.html +4 -4
- package/coverage/lcov-report/src/components/MlFollowGps/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGPXViewer/MlGPXViewer.js.html +4 -4
- package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +8 -8
- package/coverage/lcov-report/src/components/MlGPXViewer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.js.html +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js.html +2 -2
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayer/MlLayer.js.html +2 -2
- package/coverage/lcov-report/src/components/MlLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.js.html +4 -4
- package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.js.html +3 -3
- package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +1 -1
- package/coverage/lcov-report/src/components/MlMarker/MlMarker.js.html +1 -1
- package/coverage/lcov-report/src/components/MlMarker/index.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.js.html +6 -6
- package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.js.html +7 -7
- package/coverage/lcov-report/src/components/MlNavigationTools/index.html +11 -11
- package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +3 -3
- package/coverage/lcov-report/src/components/MlOsmLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +1 -1
- package/coverage/lcov-report/src/components/MlScaleReference/index.html +1 -1
- package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +1 -1
- package/coverage/lcov-report/src/components/MlShareMapState/index.html +1 -1
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +4 -4
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +1 -1
- package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +1 -1
- package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.js.html +2 -2
- package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +1 -1
- package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +1 -1
- package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.js.html +3 -3
- package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.js.html +5 -5
- package/coverage/lcov-report/src/components/MlWmsLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.js.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLoader/index.html +1 -1
- package/coverage/lcov-report/src/hooks/index.html +1 -1
- package/coverage/lcov-report/src/hooks/useMap.js.html +1 -1
- package/coverage/lcov-report/src/hooks/useMapState.js.html +1 -1
- package/coverage/lcov-report/src/hooks/useWms.js.html +1 -1
- package/coverage/lcov-report/src/i18n.js.html +1 -1
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/translations/english.js.html +1 -1
- package/coverage/lcov-report/src/translations/german.js.html +1 -1
- package/coverage/lcov-report/src/translations/index.html +1 -1
- package/coverage/lcov.info +47 -47
- package/dist/index.esm.js +1386 -1227
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -4
- package/public/thumbnails/MlCreatePdfButton.png +0 -0
- package/public/thumbnails/MlDeckGlTerrainLayer.png +0 -0
- package/public/thumbnails/MlFillExtrusionLayer.png +0 -0
- package/public/thumbnails/MlLaermkarte.png +0 -0
- package/public/thumbnails/MlLayerMagnify.png +0 -0
- package/public/thumbnails/MlLayerSwipe.png +0 -0
- package/public/thumbnails/MlMapDrawTools.png +0 -0
- package/public/thumbnails/MlThreeJsLayer.png +0 -0
- package/public/thumbnails/MlTransitionGeoJsonLayer.png +0 -0
- package/public/thumbnails/MlVectorTileLayer.png +0 -0
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.js +1 -1
- package/src/components/MlCreatePdfButton/MlCreatePdfButton.doc.de.md +1 -3
- package/src/components/MlCreatePdfButton/MlCreatePdfButton.doc.en.md +0 -2
- package/src/components/MlCreatePdfButton/MlCreatePdfButton.meta.json +1 -1
- package/src/components/MlFeatureEditor/MlFeatureEditor.doc.de.md +1 -3
- package/src/components/MlFeatureEditor/MlFeatureEditor.doc.en.md +1 -0
- package/src/components/MlFeatureEditor/MlFeatureEditor.meta.json +1 -1
- package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.doc.de.md +1 -3
- package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.doc.en.md +1 -0
- package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.meta.json +1 -1
- package/src/components/MlFollowGps/MlFollowGps.doc.de.md +1 -3
- package/src/components/MlFollowGps/MlFollowGps.doc.en.md +1 -0
- package/src/components/MlGPXViewer/MlGPXViewer.doc.de.md +1 -3
- package/src/components/MlGPXViewer/MlGPXViewer.doc.en.md +1 -0
- package/src/components/MlGPXViewer/MlGPXViewer.meta.json +1 -1
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.doc.de.md +1 -3
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.doc.en.md +1 -0
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.meta.json +1 -1
- package/src/components/MlLayerMagnify/MlLayerMagnify.doc.de.md +1 -3
- package/src/components/MlLayerMagnify/MlLayerMagnify.doc.en.md +1 -0
- package/src/components/MlLayerSwipe/MlLayerSwipe.doc.de.md +1 -3
- package/src/components/MlLayerSwipe/MlLayerSwipe.doc.en.md +1 -0
- package/src/components/MlNavigationCompass/MlNavigationCompass.doc.de.md +1 -3
- package/src/components/MlNavigationCompass/MlNavigationCompass.doc.en.md +1 -0
- package/src/components/MlNavigationTools/MlNavigationTools.doc.de.md +1 -3
- package/src/components/MlNavigationTools/MlNavigationTools.doc.en.md +1 -0
- package/src/components/MlScaleReference/MlScaleReference.doc.de.md +1 -3
- package/src/components/MlScaleReference/MlScaleReference.doc.en.md +1 -0
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.doc.de.md +1 -4
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.doc.en.md +1 -0
- package/src/components/MlThreeJsLayer/MlThreeJsLayer.doc.de.md +1 -3
- package/src/components/MlThreeJsLayer/MlThreeJsLayer.doc.en.md +1 -0
- package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.js +1 -1
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.doc.de.md +1 -3
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.doc.en.md +1 -0
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.meta.json +1 -1
- package/src/components/MlWmsLoader/MlWmsLoader.doc.de.md +1 -3
- package/src/components/MlWmsLoader/MlWmsLoader.doc.en.md +1 -0
- package/src/components/MlWmsLoader/MlWmsLoader.meta.json +1 -1
- package/src/index.js +3 -0
package/dist/index.esm.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import React__default, { useRef, useContext, useEffect, useState, useCallback, useMemo, createElement } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { MapContext } from '@mapcomponents/react-core';
|
|
4
|
-
import maplibregl from '
|
|
4
|
+
import maplibregl, { Popup } from 'maplibre-gl';
|
|
5
5
|
import 'maplibre-gl/dist/maplibre-gl.css';
|
|
6
6
|
import { v4 } from 'uuid';
|
|
7
7
|
import Button from '@mui/material/Button';
|
|
8
8
|
import GpsFixedIcon from '@mui/icons-material/GpsFixed';
|
|
9
|
-
import { point, circle, lineArc, bbox, lineOffset, distance } from '@turf/turf';
|
|
10
|
-
import maplibregl$1, { Popup } from 'maplibre-gl';
|
|
9
|
+
import { point, circle, lineArc, bbox, lineOffset, distance, lineString as lineString$1, length, lineChunk, featureCollection } from '@turf/turf';
|
|
11
10
|
import jsPDF from 'jspdf';
|
|
12
11
|
import PrinterIcon from '@mui/icons-material/Print';
|
|
13
12
|
import ButtonGroup from '@mui/material/ButtonGroup';
|
|
@@ -31,206 +30,10 @@ import List from '@mui/material/List';
|
|
|
31
30
|
import ListItem from '@mui/material/ListItem';
|
|
32
31
|
import ListItemText from '@mui/material/ListItemText';
|
|
33
32
|
import { lineString, polygon } from '@turf/helpers';
|
|
33
|
+
import Paper from '@mui/material/Paper';
|
|
34
|
+
import WMSCapabilities from 'wms-capabilities';
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
var keys = Object.keys(object);
|
|
37
|
-
|
|
38
|
-
if (Object.getOwnPropertySymbols) {
|
|
39
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
40
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
41
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
42
|
-
})), keys.push.apply(keys, symbols);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return keys;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function _objectSpread2(target) {
|
|
49
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
50
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
51
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
52
|
-
_defineProperty(target, key, source[key]);
|
|
53
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
54
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return target;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function _typeof(obj) {
|
|
62
|
-
"@babel/helpers - typeof";
|
|
63
|
-
|
|
64
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
65
|
-
return typeof obj;
|
|
66
|
-
} : function (obj) {
|
|
67
|
-
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
68
|
-
}, _typeof(obj);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
72
|
-
try {
|
|
73
|
-
var info = gen[key](arg);
|
|
74
|
-
var value = info.value;
|
|
75
|
-
} catch (error) {
|
|
76
|
-
reject(error);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (info.done) {
|
|
81
|
-
resolve(value);
|
|
82
|
-
} else {
|
|
83
|
-
Promise.resolve(value).then(_next, _throw);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function _asyncToGenerator(fn) {
|
|
88
|
-
return function () {
|
|
89
|
-
var self = this,
|
|
90
|
-
args = arguments;
|
|
91
|
-
return new Promise(function (resolve, reject) {
|
|
92
|
-
var gen = fn.apply(self, args);
|
|
93
|
-
|
|
94
|
-
function _next(value) {
|
|
95
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function _throw(err) {
|
|
99
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
_next(undefined);
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function _defineProperty(obj, key, value) {
|
|
108
|
-
if (key in obj) {
|
|
109
|
-
Object.defineProperty(obj, key, {
|
|
110
|
-
value: value,
|
|
111
|
-
enumerable: true,
|
|
112
|
-
configurable: true,
|
|
113
|
-
writable: true
|
|
114
|
-
});
|
|
115
|
-
} else {
|
|
116
|
-
obj[key] = value;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return obj;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
123
|
-
if (source == null) return {};
|
|
124
|
-
var target = {};
|
|
125
|
-
var sourceKeys = Object.keys(source);
|
|
126
|
-
var key, i;
|
|
127
|
-
|
|
128
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
129
|
-
key = sourceKeys[i];
|
|
130
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
131
|
-
target[key] = source[key];
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return target;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function _objectWithoutProperties(source, excluded) {
|
|
138
|
-
if (source == null) return {};
|
|
139
|
-
|
|
140
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
141
|
-
|
|
142
|
-
var key, i;
|
|
143
|
-
|
|
144
|
-
if (Object.getOwnPropertySymbols) {
|
|
145
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
146
|
-
|
|
147
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
148
|
-
key = sourceSymbolKeys[i];
|
|
149
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
150
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
151
|
-
target[key] = source[key];
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return target;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function _slicedToArray(arr, i) {
|
|
159
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function _toConsumableArray(arr) {
|
|
163
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function _arrayWithoutHoles(arr) {
|
|
167
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function _arrayWithHoles(arr) {
|
|
171
|
-
if (Array.isArray(arr)) return arr;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
function _iterableToArray(iter) {
|
|
175
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function _iterableToArrayLimit(arr, i) {
|
|
179
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
180
|
-
|
|
181
|
-
if (_i == null) return;
|
|
182
|
-
var _arr = [];
|
|
183
|
-
var _n = true;
|
|
184
|
-
var _d = false;
|
|
185
|
-
|
|
186
|
-
var _s, _e;
|
|
187
|
-
|
|
188
|
-
try {
|
|
189
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
190
|
-
_arr.push(_s.value);
|
|
191
|
-
|
|
192
|
-
if (i && _arr.length === i) break;
|
|
193
|
-
}
|
|
194
|
-
} catch (err) {
|
|
195
|
-
_d = true;
|
|
196
|
-
_e = err;
|
|
197
|
-
} finally {
|
|
198
|
-
try {
|
|
199
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
200
|
-
} finally {
|
|
201
|
-
if (_d) throw _e;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return _arr;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
209
|
-
if (!o) return;
|
|
210
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
211
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
212
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
213
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
214
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function _arrayLikeToArray(arr, len) {
|
|
218
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
219
|
-
|
|
220
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
221
|
-
|
|
222
|
-
return arr2;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
function _nonIterableSpread() {
|
|
226
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
function _nonIterableRest() {
|
|
230
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
var _excluded = ["lng", "lat"];
|
|
36
|
+
// @ts-ignore: TS export Problem to be fixed upstream
|
|
234
37
|
/**
|
|
235
38
|
* Creates a MapLibre-gl-js instance and offers all of the native MapLibre functions and properties as well as additional functionality such as element registration & cleanup and more events.
|
|
236
39
|
*
|
|
@@ -239,11 +42,11 @@ var _excluded = ["lng", "lat"];
|
|
|
239
42
|
* @class
|
|
240
43
|
*/
|
|
241
44
|
|
|
242
|
-
|
|
45
|
+
const MapLibreGlWrapper = function (props) {
|
|
243
46
|
var _this = this;
|
|
244
47
|
|
|
245
48
|
// closure variable to safely point to the object context of the current MapLibreGlWrapper instance
|
|
246
|
-
|
|
49
|
+
let self = this; // element registration and cleanup on a component level is experimental
|
|
247
50
|
|
|
248
51
|
this.registeredElements = {}; // array of base layer ids, all layers that have been added by the style passed to the MapLibreGl coonstructor
|
|
249
52
|
|
|
@@ -267,7 +70,7 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
267
70
|
* @param {string} componentId
|
|
268
71
|
* @returns {undefined}
|
|
269
72
|
*/
|
|
270
|
-
on:
|
|
73
|
+
on: (eventName, handler, options, componentId) => {
|
|
271
74
|
if (!self.eventHandlers[eventName]) return;
|
|
272
75
|
|
|
273
76
|
if (typeof options === "string") {
|
|
@@ -276,10 +79,10 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
276
79
|
}
|
|
277
80
|
|
|
278
81
|
self.eventHandlers[eventName].push({
|
|
279
|
-
handler
|
|
280
|
-
options
|
|
82
|
+
handler,
|
|
83
|
+
options
|
|
281
84
|
});
|
|
282
|
-
|
|
85
|
+
let _arguments = [eventName, handler];
|
|
283
86
|
|
|
284
87
|
if (componentId && typeof componentId === "string") {
|
|
285
88
|
self.initRegisteredElements(componentId);
|
|
@@ -294,9 +97,9 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
294
97
|
* @param {function} handler
|
|
295
98
|
* @returns {undefined}
|
|
296
99
|
*/
|
|
297
|
-
off:
|
|
100
|
+
off: (eventName, handler) => {
|
|
298
101
|
if (!self.eventHandlers[eventName]) return;
|
|
299
|
-
self.eventHandlers[eventName] = self.eventHandlers[eventName].filter(
|
|
102
|
+
self.eventHandlers[eventName] = self.eventHandlers[eventName].filter(item => {
|
|
300
103
|
if (!Object.is(item.handler, handler)) {
|
|
301
104
|
return item;
|
|
302
105
|
}
|
|
@@ -312,10 +115,10 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
312
115
|
* @param {object} context
|
|
313
116
|
* @returns {undefined}
|
|
314
117
|
*/
|
|
315
|
-
fire:
|
|
118
|
+
fire: (eventName, context) => {
|
|
316
119
|
if (!self.eventHandlers[eventName]) return;
|
|
317
120
|
var scope = context || window;
|
|
318
|
-
|
|
121
|
+
let event = new Event(eventName);
|
|
319
122
|
event.data = self;
|
|
320
123
|
self.eventHandlers[eventName].forEach(function (item) {
|
|
321
124
|
item.handler.call(scope, event);
|
|
@@ -343,7 +146,7 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
343
146
|
* @param {string} layer
|
|
344
147
|
* @returns object
|
|
345
148
|
*/
|
|
346
|
-
buildLayerObject:
|
|
149
|
+
buildLayerObject: layer => {
|
|
347
150
|
//if (self.baseLayers.indexOf(layer.id) === -1) {
|
|
348
151
|
//let paint = {};
|
|
349
152
|
//let values = layer.paint?._values;
|
|
@@ -384,18 +187,16 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
384
187
|
*
|
|
385
188
|
* @returns array
|
|
386
189
|
*/
|
|
387
|
-
buildLayerObjects:
|
|
388
|
-
return self.style._order.map(
|
|
190
|
+
buildLayerObjects: () => {
|
|
191
|
+
return self.style._order.map(layerId => {
|
|
389
192
|
return self.wrapper.buildLayerObject(self.map.style._layers[layerId]);
|
|
390
|
-
}).filter(
|
|
391
|
-
return n;
|
|
392
|
-
});
|
|
193
|
+
}).filter(n => n);
|
|
393
194
|
},
|
|
394
195
|
|
|
395
196
|
/**
|
|
396
197
|
* Updates layer state info objects
|
|
397
198
|
*/
|
|
398
|
-
refreshLayerState:
|
|
199
|
+
refreshLayerState: () => {
|
|
399
200
|
self.wrapper.layerState = self.wrapper.buildLayerObjects();
|
|
400
201
|
|
|
401
202
|
if (JSON.stringify(self.wrapper.layerState) !== self.wrapper.layerStateString) {
|
|
@@ -418,24 +219,23 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
418
219
|
* Previous version of viewportStateString
|
|
419
220
|
*/
|
|
420
221
|
oldViewportStateString: "{}",
|
|
421
|
-
getViewport:
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
refreshViewport: function refreshViewport() {
|
|
222
|
+
getViewport: () => typeof self.map.getCenter === "function" ? {
|
|
223
|
+
center: (_ref => {
|
|
224
|
+
let {
|
|
225
|
+
lng,
|
|
226
|
+
lat,
|
|
227
|
+
...rest
|
|
228
|
+
} = _ref;
|
|
229
|
+
return {
|
|
230
|
+
lng,
|
|
231
|
+
lat
|
|
232
|
+
};
|
|
233
|
+
})(self.map.getCenter()),
|
|
234
|
+
zoom: self.map.getZoom(),
|
|
235
|
+
bearing: self.map.getBearing(),
|
|
236
|
+
pitch: self.map.getPitch()
|
|
237
|
+
} : {},
|
|
238
|
+
refreshViewport: () => {
|
|
439
239
|
self.wrapper.viewportState = self.wrapper.getViewport();
|
|
440
240
|
}
|
|
441
241
|
};
|
|
@@ -446,7 +246,7 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
446
246
|
* @param {boolean} force
|
|
447
247
|
*/
|
|
448
248
|
|
|
449
|
-
this.initRegisteredElements =
|
|
249
|
+
this.initRegisteredElements = (componentId, force) => {
|
|
450
250
|
if (typeof self.registeredElements[componentId] === "undefined" || force !== "undefined" && force) {
|
|
451
251
|
self.registeredElements[componentId] = {
|
|
452
252
|
layers: [],
|
|
@@ -468,7 +268,7 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
468
268
|
*/
|
|
469
269
|
|
|
470
270
|
|
|
471
|
-
this.addLayer =
|
|
271
|
+
this.addLayer = (layer, beforeId, componentId) => {
|
|
472
272
|
if (!self.map.style) {
|
|
473
273
|
return;
|
|
474
274
|
}
|
|
@@ -477,7 +277,7 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
477
277
|
self.initRegisteredElements(componentId);
|
|
478
278
|
self.registeredElements[componentId].layers.push(layer.id);
|
|
479
279
|
|
|
480
|
-
if (
|
|
280
|
+
if (typeof layer.source === "object") {
|
|
481
281
|
self.registeredElements[componentId].sources.push(layer.id);
|
|
482
282
|
}
|
|
483
283
|
}
|
|
@@ -495,7 +295,7 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
495
295
|
*/
|
|
496
296
|
|
|
497
297
|
|
|
498
|
-
this.addSource =
|
|
298
|
+
this.addSource = (sourceId, source, options, componentId) => {
|
|
499
299
|
if (!self.map.style) {
|
|
500
300
|
return;
|
|
501
301
|
}
|
|
@@ -522,7 +322,7 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
522
322
|
*/
|
|
523
323
|
|
|
524
324
|
|
|
525
|
-
this.addImage =
|
|
325
|
+
this.addImage = (id, image, ref, componentId) => {
|
|
526
326
|
if (!self.map.style) {
|
|
527
327
|
return;
|
|
528
328
|
}
|
|
@@ -549,14 +349,12 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
549
349
|
*/
|
|
550
350
|
|
|
551
351
|
|
|
552
|
-
this.on =
|
|
553
|
-
var _self$map;
|
|
554
|
-
|
|
352
|
+
this.on = (type, layerId, listener, componentId) => {
|
|
555
353
|
if (typeof listener === "string" && typeof layerId === "function") {
|
|
556
354
|
return self.on.call(self, type, undefined, layerId, listener);
|
|
557
355
|
}
|
|
558
356
|
|
|
559
|
-
|
|
357
|
+
let _arguments = [type, layerId, listener];
|
|
560
358
|
|
|
561
359
|
if (!layerId) {
|
|
562
360
|
_arguments = [type, listener];
|
|
@@ -567,7 +365,7 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
567
365
|
self.registeredElements[componentId].events.push(_arguments);
|
|
568
366
|
}
|
|
569
367
|
|
|
570
|
-
|
|
368
|
+
self.map.on(..._arguments);
|
|
571
369
|
};
|
|
572
370
|
/**
|
|
573
371
|
* Overrides MapLibre-gl-js addControl function providing an additional componentId parameter for the wrapper element registration.
|
|
@@ -578,7 +376,7 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
578
376
|
*/
|
|
579
377
|
|
|
580
378
|
|
|
581
|
-
this.addControl =
|
|
379
|
+
this.addControl = (control, position, componentId) => {
|
|
582
380
|
if (componentId && typeof componentId === "string") {
|
|
583
381
|
self.initRegisteredElements(componentId);
|
|
584
382
|
self.registeredElements[componentId].controls.push(control);
|
|
@@ -593,177 +391,144 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
593
391
|
*/
|
|
594
392
|
|
|
595
393
|
|
|
596
|
-
this.cleanup =
|
|
394
|
+
this.cleanup = componentId => {
|
|
597
395
|
if (self.map.style && typeof self.registeredElements[componentId] !== "undefined") {
|
|
598
396
|
// cleanup layers
|
|
599
|
-
self.registeredElements[componentId].layers.forEach(
|
|
397
|
+
self.registeredElements[componentId].layers.forEach(item => {
|
|
600
398
|
if (self.map.style.getLayer(item)) {
|
|
601
399
|
self.map.style.removeLayer(item);
|
|
602
400
|
}
|
|
603
401
|
}); // cleanup sources
|
|
604
402
|
|
|
605
|
-
self.registeredElements[componentId].sources.forEach(
|
|
403
|
+
self.registeredElements[componentId].sources.forEach(item => {
|
|
606
404
|
if (self.map.style.getSource(item)) {
|
|
607
405
|
self.map.style.removeSource(item);
|
|
608
406
|
}
|
|
609
407
|
}); // cleanup images
|
|
610
408
|
|
|
611
|
-
self.registeredElements[componentId].images.forEach(
|
|
409
|
+
self.registeredElements[componentId].images.forEach(item => {
|
|
612
410
|
if (self.map.hasImage(item)) {
|
|
613
411
|
self.map.style.removeImage(item);
|
|
614
412
|
}
|
|
615
413
|
}); // cleanup events
|
|
616
414
|
|
|
617
|
-
self.registeredElements[componentId].events.forEach(
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
(_self$map2 = self.map).off.apply(_self$map2, _toConsumableArray(item));
|
|
415
|
+
self.registeredElements[componentId].events.forEach(item => {
|
|
416
|
+
self.map.off(...item);
|
|
621
417
|
}); // cleanup controls
|
|
622
418
|
|
|
623
|
-
self.registeredElements[componentId].controls.forEach(
|
|
419
|
+
self.registeredElements[componentId].controls.forEach(item => {
|
|
624
420
|
self.map.removeControl(item);
|
|
625
421
|
}); // cleanup wrapper events
|
|
626
422
|
|
|
627
|
-
self.registeredElements[componentId].wrapperEvents.forEach(
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
(_self$wrapper = self.wrapper).off.apply(_self$wrapper, _toConsumableArray(item));
|
|
423
|
+
self.registeredElements[componentId].wrapperEvents.forEach(item => {
|
|
424
|
+
self.wrapper.off(...item);
|
|
631
425
|
});
|
|
632
426
|
self.initRegisteredElements(componentId, true);
|
|
633
427
|
}
|
|
634
428
|
}; // add style prop functions that require map._update to be called afterwards
|
|
635
429
|
|
|
636
430
|
|
|
637
|
-
|
|
638
|
-
updatingStyleFunctions.forEach(
|
|
639
|
-
|
|
431
|
+
let updatingStyleFunctions = ["moveLayer", "removeLayer", "removeSource", "setPaintProperty", "setLayoutProperty"];
|
|
432
|
+
updatingStyleFunctions.forEach(item => {
|
|
433
|
+
this[item] = function () {
|
|
640
434
|
if (self.map && _this.map.style && typeof self.map.style[item] === "function") {
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
(_self$map$style = self.map.style)[item].apply(_self$map$style, arguments);
|
|
435
|
+
self.map.style[item](...arguments);
|
|
644
436
|
}
|
|
645
437
|
|
|
646
438
|
return self.map._update ? self.map._update(true) : undefined;
|
|
647
439
|
};
|
|
648
440
|
}); // add style prop functions
|
|
649
441
|
|
|
650
|
-
|
|
651
|
-
styleFunctions.forEach(
|
|
652
|
-
|
|
442
|
+
let styleFunctions = ["getLayer", "getSource", "listImages", "getPaintProperty", "getLayoutProperty", "removeImage"];
|
|
443
|
+
styleFunctions.forEach(item => {
|
|
444
|
+
this[item] = function () {
|
|
653
445
|
if (self.map && self.map.style) {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
return (_self$map$style2 = self.map.style)[item].apply(_self$map$style2, arguments);
|
|
446
|
+
return self.map.style[item](...arguments);
|
|
657
447
|
}
|
|
658
448
|
|
|
659
449
|
return false;
|
|
660
450
|
};
|
|
661
451
|
});
|
|
662
452
|
|
|
663
|
-
this.addNativeMaplibreFunctionsAndProps =
|
|
453
|
+
this.addNativeMaplibreFunctionsAndProps = () => {
|
|
664
454
|
// add MapLibre-gl functions
|
|
665
|
-
Object.getOwnPropertyNames(Object.getPrototypeOf(
|
|
666
|
-
if (typeof
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
return (_self$map3 = self.map)[item].apply(_self$map3, arguments);
|
|
455
|
+
Object.getOwnPropertyNames(Object.getPrototypeOf(this.map)).forEach(item => {
|
|
456
|
+
if (typeof this[item] === "undefined") {
|
|
457
|
+
this[item] = function () {
|
|
458
|
+
return self.map[item](...arguments);
|
|
671
459
|
};
|
|
672
460
|
}
|
|
673
461
|
}); // add MapLibre-gl properties
|
|
674
462
|
|
|
675
|
-
Object.keys(
|
|
676
|
-
if (typeof
|
|
677
|
-
|
|
463
|
+
Object.keys(this.map).forEach(item => {
|
|
464
|
+
if (typeof this[item] === "undefined") {
|
|
465
|
+
this[item] = self.map[item];
|
|
678
466
|
}
|
|
679
467
|
});
|
|
680
468
|
}; // add functions that are missing on the MapLibre instances prototype
|
|
681
469
|
|
|
682
470
|
|
|
683
|
-
|
|
684
|
-
missingFunctions.forEach(
|
|
685
|
-
|
|
471
|
+
let missingFunctions = ["getZoom", "setZoom", "getCenter", "setCenter", "getBearing", "setBearing", "getPitch", "setPitch", "jumpTo", "flyTo", "panTo", "panBy", "panBy", "zoomTo", "zoomIn", "zoomOut", "getPadding", "setPadding", "rotateTo", "resetNorth", "resetNorthPitch", "snapToNorth", "cameraForBounds", "fitBounds", "fitScreenCoordinates", "getFreeCameraOptions", "setFreeCameraOptions", "easeTo", "stop"];
|
|
472
|
+
missingFunctions.forEach(item => {
|
|
473
|
+
this[item] = function () {
|
|
686
474
|
if (typeof self.map[item] === "function") {
|
|
687
|
-
var _self$map$item;
|
|
688
|
-
|
|
689
475
|
for (var _len = arguments.length, props = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
690
476
|
props[_key] = arguments[_key];
|
|
691
477
|
}
|
|
692
478
|
|
|
693
|
-
return
|
|
479
|
+
return self.map[item].call(self.map, ...props);
|
|
694
480
|
}
|
|
695
481
|
|
|
696
482
|
return undefined;
|
|
697
483
|
};
|
|
698
484
|
}); // initialize the MapLibre-gl instance
|
|
699
485
|
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
return fetch(props.mapOptions.style).then(function (response) {
|
|
713
|
-
if (response.ok) {
|
|
714
|
-
return response.json();
|
|
715
|
-
} else {
|
|
716
|
-
throw new Error("error loading map style.json");
|
|
717
|
-
}
|
|
718
|
-
}).then(function (styleJson) {
|
|
719
|
-
styleJson.layers.forEach(function (item) {
|
|
720
|
-
self.baseLayers.push(item.id);
|
|
721
|
-
|
|
722
|
-
if (!self.firstSymbolLayer && item.type === "symbol") {
|
|
723
|
-
self.firstSymbolLayer = item.id;
|
|
724
|
-
}
|
|
725
|
-
});
|
|
726
|
-
self.styleJson = styleJson;
|
|
727
|
-
props.mapOptions.style = styleJson;
|
|
728
|
-
}).catch(function (error) {
|
|
729
|
-
console.log(error);
|
|
730
|
-
});
|
|
731
|
-
|
|
732
|
-
case 3:
|
|
733
|
-
self.map = new maplibregl.Map(props.mapOptions);
|
|
734
|
-
self.addNativeMaplibreFunctionsAndProps();
|
|
735
|
-
self.wrapper.refreshViewport();
|
|
736
|
-
self.wrapper.fire("viewportchange");
|
|
737
|
-
self.map.on("load", function () {
|
|
738
|
-
self.addNativeMaplibreFunctionsAndProps();
|
|
739
|
-
});
|
|
740
|
-
self.map.on("move", function () {
|
|
741
|
-
self.wrapper.viewportState = self.wrapper.getViewport();
|
|
742
|
-
self.wrapper.fire("viewportchange");
|
|
743
|
-
});
|
|
744
|
-
self.map.on("idle", function () {
|
|
745
|
-
self.wrapper.refreshLayerState();
|
|
746
|
-
});
|
|
747
|
-
self.map.on("data", function () {
|
|
748
|
-
self.wrapper.refreshLayerState();
|
|
749
|
-
});
|
|
750
|
-
|
|
751
|
-
if (typeof props.onReady === "function") {
|
|
752
|
-
props.onReady(self.map, self);
|
|
753
|
-
}
|
|
486
|
+
let initializeMapLibre = async () => {
|
|
487
|
+
// if mapOptions style URL is given and if it is not a mapbox URL fetch the json and initialize the mapbox object
|
|
488
|
+
if (typeof props.mapOptions.style === "string" && props.mapOptions.style.indexOf("mapbox://") === -1) {
|
|
489
|
+
await fetch(props.mapOptions.style).then(response => {
|
|
490
|
+
if (response.ok) {
|
|
491
|
+
return response.json();
|
|
492
|
+
} else {
|
|
493
|
+
throw new Error("error loading map style.json");
|
|
494
|
+
}
|
|
495
|
+
}).then(styleJson => {
|
|
496
|
+
styleJson.layers.forEach(item => {
|
|
497
|
+
self.baseLayers.push(item.id);
|
|
754
498
|
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
return _context.stop();
|
|
499
|
+
if (!self.firstSymbolLayer && item.type === "symbol") {
|
|
500
|
+
self.firstSymbolLayer = item.id;
|
|
758
501
|
}
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
|
|
502
|
+
});
|
|
503
|
+
self.styleJson = styleJson;
|
|
504
|
+
props.mapOptions.style = styleJson;
|
|
505
|
+
}).catch(error => {
|
|
506
|
+
console.log(error);
|
|
507
|
+
});
|
|
508
|
+
}
|
|
762
509
|
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
510
|
+
self.map = new maplibregl.Map(props.mapOptions);
|
|
511
|
+
self.addNativeMaplibreFunctionsAndProps();
|
|
512
|
+
self.wrapper.refreshViewport();
|
|
513
|
+
self.wrapper.fire("viewportchange");
|
|
514
|
+
self.map.on("load", () => {
|
|
515
|
+
self.addNativeMaplibreFunctionsAndProps();
|
|
516
|
+
});
|
|
517
|
+
self.map.on("move", () => {
|
|
518
|
+
self.wrapper.viewportState = self.wrapper.getViewport();
|
|
519
|
+
self.wrapper.fire("viewportchange");
|
|
520
|
+
});
|
|
521
|
+
self.map.on("idle", () => {
|
|
522
|
+
self.wrapper.refreshLayerState();
|
|
523
|
+
});
|
|
524
|
+
self.map.on("data", () => {
|
|
525
|
+
self.wrapper.refreshLayerState();
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
if (typeof props.onReady === "function") {
|
|
529
|
+
props.onReady(self.map, self);
|
|
530
|
+
}
|
|
531
|
+
};
|
|
767
532
|
|
|
768
533
|
initializeMapLibre();
|
|
769
534
|
};
|
|
@@ -779,17 +544,17 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
779
544
|
* @component
|
|
780
545
|
*/
|
|
781
546
|
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
useEffect(
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
return
|
|
547
|
+
const MapLibreMap = props => {
|
|
548
|
+
const map = useRef(null);
|
|
549
|
+
const mapContainer = useRef(null);
|
|
550
|
+
const mapContext = useContext(MapContext);
|
|
551
|
+
const mapContextRef = useRef(mapContext);
|
|
552
|
+
const mapIdRef = useRef(props.mapId);
|
|
553
|
+
const mapOptions = props.options;
|
|
554
|
+
useEffect(() => {
|
|
555
|
+
let mapId = mapIdRef.current;
|
|
556
|
+
let _mapContext = mapContextRef.current;
|
|
557
|
+
return () => {
|
|
793
558
|
var _map$current, _map$current$remove;
|
|
794
559
|
|
|
795
560
|
_mapContext.removeMap(mapId);
|
|
@@ -798,14 +563,15 @@ var MapLibreMap = function MapLibreMap(props) {
|
|
|
798
563
|
map.current = null;
|
|
799
564
|
};
|
|
800
565
|
}, []);
|
|
801
|
-
useEffect(
|
|
566
|
+
useEffect(() => {
|
|
802
567
|
if (mapContainer.current) {
|
|
803
568
|
map.current = new MapLibreGlWrapper({
|
|
804
|
-
mapOptions:
|
|
805
|
-
container: mapContainer.current
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
569
|
+
mapOptions: {
|
|
570
|
+
container: mapContainer.current,
|
|
571
|
+
...mapOptions
|
|
572
|
+
},
|
|
573
|
+
onReady: (map, wrapper) => {
|
|
574
|
+
map.once("load", () => {
|
|
809
575
|
if (props.mapId) {
|
|
810
576
|
mapContext.registerMap(props.mapId, wrapper);
|
|
811
577
|
} else {
|
|
@@ -856,25 +622,15 @@ MapLibreMap.propTypes = {
|
|
|
856
622
|
|
|
857
623
|
function useMapState(props) {
|
|
858
624
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
var viewportRef = useRef(undefined);
|
|
869
|
-
|
|
870
|
-
var _useState3 = useState(undefined),
|
|
871
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
872
|
-
layers = _useState4[0],
|
|
873
|
-
setLayers = _useState4[1];
|
|
874
|
-
|
|
875
|
-
var layersRef = useRef(undefined); //const mapRef = useRef(props.map);
|
|
876
|
-
|
|
877
|
-
var componentId = useRef(v4());
|
|
625
|
+
const mapContext = useContext(MapContext);
|
|
626
|
+
const initializedRef = useRef(false);
|
|
627
|
+
const mapRef = useRef(undefined);
|
|
628
|
+
const [viewport, setViewport] = useState(undefined);
|
|
629
|
+
const viewportRef = useRef(undefined);
|
|
630
|
+
const [layers, setLayers] = useState(undefined);
|
|
631
|
+
const layersRef = useRef(undefined); //const mapRef = useRef(props.map);
|
|
632
|
+
|
|
633
|
+
const componentId = useRef(v4());
|
|
878
634
|
/**
|
|
879
635
|
* returns the element if it matches the defined filter criteria
|
|
880
636
|
* to be used as filter function on the layers array
|
|
@@ -882,7 +638,7 @@ function useMapState(props) {
|
|
|
882
638
|
* @param {object} layer
|
|
883
639
|
*/
|
|
884
640
|
|
|
885
|
-
|
|
641
|
+
const layerIdFilter = useCallback(layer => {
|
|
886
642
|
var _props$filter, _props$filter2;
|
|
887
643
|
|
|
888
644
|
if (!(props !== null && props !== void 0 && (_props$filter = props.filter) !== null && _props$filter !== void 0 && _props$filter.includeBaseLayers) && layer.baseLayer) {
|
|
@@ -899,19 +655,19 @@ function useMapState(props) {
|
|
|
899
655
|
|
|
900
656
|
return true;
|
|
901
657
|
}, [props.filter]);
|
|
902
|
-
|
|
903
|
-
|
|
658
|
+
const refreshLayerState = useCallback(() => {
|
|
659
|
+
let _layerState = mapRef.current.wrapper.layerState.filter(layerIdFilter);
|
|
904
660
|
|
|
905
|
-
|
|
661
|
+
let _layerStateString = JSON.stringify(_layerState);
|
|
906
662
|
|
|
907
663
|
if (layersRef.current !== _layerStateString) {
|
|
908
664
|
layersRef.current = _layerStateString;
|
|
909
665
|
setLayers(_layerState);
|
|
910
666
|
}
|
|
911
667
|
}, [layerIdFilter]);
|
|
912
|
-
useEffect(
|
|
913
|
-
|
|
914
|
-
return
|
|
668
|
+
useEffect(() => {
|
|
669
|
+
let _componentId = componentId.current;
|
|
670
|
+
return () => {
|
|
915
671
|
// cleanup all event listeners
|
|
916
672
|
if (mapRef.current) {
|
|
917
673
|
mapRef.current.cleanup(_componentId);
|
|
@@ -921,7 +677,7 @@ function useMapState(props) {
|
|
|
921
677
|
initializedRef.current = false;
|
|
922
678
|
};
|
|
923
679
|
}, []);
|
|
924
|
-
useEffect(
|
|
680
|
+
useEffect(() => {
|
|
925
681
|
var _props$watch, _props$watch2;
|
|
926
682
|
|
|
927
683
|
if (!mapContext.mapExists(props.mapId) || initializedRef.current) return; // the MapLibre-gl instance (mapContext.getMap(props.mapId)) is accessible here
|
|
@@ -933,7 +689,7 @@ function useMapState(props) {
|
|
|
933
689
|
if (props !== null && props !== void 0 && (_props$watch = props.watch) !== null && _props$watch !== void 0 && _props$watch.viewport) {
|
|
934
690
|
setViewport(mapRef.current.wrapper.viewportState); // register viewportchange event handler
|
|
935
691
|
|
|
936
|
-
mapRef.current.wrapper.on("viewportchange",
|
|
692
|
+
mapRef.current.wrapper.on("viewportchange", () => {
|
|
937
693
|
var _mapRef$current;
|
|
938
694
|
|
|
939
695
|
if (viewportRef.current !== ((_mapRef$current = mapRef.current) === null || _mapRef$current === void 0 ? void 0 : _mapRef$current.wrapper.viewportStateString)) {
|
|
@@ -956,8 +712,8 @@ function useMapState(props) {
|
|
|
956
712
|
}
|
|
957
713
|
}, [mapContext.mapIds, mapContext, props.mapId, refreshLayerState, props]);
|
|
958
714
|
return {
|
|
959
|
-
layers
|
|
960
|
-
viewport
|
|
715
|
+
layers,
|
|
716
|
+
viewport
|
|
961
717
|
};
|
|
962
718
|
}
|
|
963
719
|
|
|
@@ -1001,8 +757,8 @@ useMapState.propTypes = {
|
|
|
1001
757
|
|
|
1002
758
|
function useMap(props) {
|
|
1003
759
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
1004
|
-
|
|
1005
|
-
|
|
760
|
+
const mapContext = useContext(MapContext);
|
|
761
|
+
const mapState = useMapState({
|
|
1006
762
|
mapId: props.mapId,
|
|
1007
763
|
watch: {
|
|
1008
764
|
viewport: false,
|
|
@@ -1013,18 +769,13 @@ function useMap(props) {
|
|
|
1013
769
|
includeBaseLayers: true
|
|
1014
770
|
}
|
|
1015
771
|
});
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
setMapIsReady = _useState2[1];
|
|
1024
|
-
|
|
1025
|
-
useEffect(function () {
|
|
1026
|
-
var _componentId = componentId.current;
|
|
1027
|
-
return function () {
|
|
772
|
+
const initializedRef = useRef(false);
|
|
773
|
+
const mapRef = useRef(undefined);
|
|
774
|
+
const componentId = useRef(v4());
|
|
775
|
+
const [mapIsReady, setMapIsReady] = useState(false);
|
|
776
|
+
useEffect(() => {
|
|
777
|
+
let _componentId = componentId.current;
|
|
778
|
+
return () => {
|
|
1028
779
|
if (mapRef.current) {
|
|
1029
780
|
mapRef.current.cleanup(_componentId);
|
|
1030
781
|
mapRef.current = undefined;
|
|
@@ -1034,15 +785,15 @@ function useMap(props) {
|
|
|
1034
785
|
setMapIsReady(false);
|
|
1035
786
|
};
|
|
1036
787
|
}, []);
|
|
1037
|
-
useEffect(
|
|
788
|
+
useEffect(() => {
|
|
1038
789
|
if (!mapContext.mapExists(props.mapId) || initializedRef.current) return; // check if waitForLayer (string, layer id of the layer this hook is supposed to wait for)
|
|
1039
790
|
// exists as layer in the MapLibre instance
|
|
1040
791
|
|
|
1041
792
|
if (props.waitForLayer) {
|
|
1042
793
|
var _mapState$layers;
|
|
1043
794
|
|
|
1044
|
-
|
|
1045
|
-
mapState === null || mapState === void 0 ? void 0 : (_mapState$layers = mapState.layers) === null || _mapState$layers === void 0 ? void 0 : _mapState$layers.forEach(
|
|
795
|
+
let layerFound = false;
|
|
796
|
+
mapState === null || mapState === void 0 ? void 0 : (_mapState$layers = mapState.layers) === null || _mapState$layers === void 0 ? void 0 : _mapState$layers.forEach(layer => {
|
|
1046
797
|
if (layer.id === props.waitForLayer) {
|
|
1047
798
|
layerFound = true;
|
|
1048
799
|
}
|
|
@@ -1061,7 +812,7 @@ function useMap(props) {
|
|
|
1061
812
|
}, [mapContext.mapIds, mapState.layers, mapContext, props.waitForLayer, props.mapId]);
|
|
1062
813
|
return {
|
|
1063
814
|
map: mapRef.current,
|
|
1064
|
-
mapIsReady
|
|
815
|
+
mapIsReady,
|
|
1065
816
|
componentId: componentId.current,
|
|
1066
817
|
layers: mapState.layers
|
|
1067
818
|
};
|
|
@@ -1076,13 +827,13 @@ function useMap(props) {
|
|
|
1076
827
|
* @component
|
|
1077
828
|
*/
|
|
1078
829
|
|
|
1079
|
-
|
|
1080
|
-
|
|
830
|
+
const MlComponentTemplate = props => {
|
|
831
|
+
const mapHook = useMap({
|
|
1081
832
|
mapId: props.mapId,
|
|
1082
833
|
waitForLayer: props.insertBeforeLayer
|
|
1083
834
|
});
|
|
1084
|
-
|
|
1085
|
-
useEffect(
|
|
835
|
+
const initializedRef = useRef(false);
|
|
836
|
+
useEffect(() => {
|
|
1086
837
|
if (!mapHook.mapIsReady || initializedRef.current) return; // the MapLibre-gl instance (mapHook.map) is accessible here
|
|
1087
838
|
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
1088
839
|
|
|
@@ -1108,21 +859,16 @@ MlComponentTemplate.propTypes = {
|
|
|
1108
859
|
* @Component
|
|
1109
860
|
*/
|
|
1110
861
|
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
var initializedRef = useRef(false);
|
|
1122
|
-
var layerId = useRef(props.layerId || "MlFillExtrusionLayer-" + v4());
|
|
1123
|
-
useEffect(function () {
|
|
1124
|
-
var _componentId = componentId.current;
|
|
1125
|
-
return function () {
|
|
862
|
+
const MlFillExtrusionLayer = props => {
|
|
863
|
+
const mapContext = useContext(MapContext);
|
|
864
|
+
const mapRef = useRef(null);
|
|
865
|
+
const [showLayer, setShowLayer] = useState(true);
|
|
866
|
+
const componentId = useRef((props.idPrefix ? props.idPrefix : "MlFillExtrusionLayer-") + v4());
|
|
867
|
+
const initializedRef = useRef(false);
|
|
868
|
+
const layerId = useRef(props.layerId || "MlFillExtrusionLayer-" + v4());
|
|
869
|
+
useEffect(() => {
|
|
870
|
+
let _componentId = componentId.current;
|
|
871
|
+
return () => {
|
|
1126
872
|
if (mapRef.current) {
|
|
1127
873
|
mapRef.current.cleanup(_componentId);
|
|
1128
874
|
mapRef.current = undefined;
|
|
@@ -1131,13 +877,13 @@ var MlFillExtrusionLayer = function MlFillExtrusionLayer(props) {
|
|
|
1131
877
|
initializedRef.current = false;
|
|
1132
878
|
};
|
|
1133
879
|
}, []);
|
|
1134
|
-
useEffect(
|
|
880
|
+
useEffect(() => {
|
|
1135
881
|
if (!mapContext.mapExists(props.mapId) || initializedRef.current) return; // the MapLibre-gl instance (mapContext.getMap(props.mapId)) is accessible here
|
|
1136
882
|
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
1137
883
|
|
|
1138
884
|
initializedRef.current = true;
|
|
1139
885
|
mapRef.current = mapContext.getMap(props.mapId);
|
|
1140
|
-
|
|
886
|
+
let lastLabelLayerId = undefined;
|
|
1141
887
|
|
|
1142
888
|
if (mapContext.map.getLayer("waterway-name")) {
|
|
1143
889
|
lastLabelLayerId = "waterway-name";
|
|
@@ -1153,10 +899,11 @@ var MlFillExtrusionLayer = function MlFillExtrusionLayer(props) {
|
|
|
1153
899
|
source: props.sourceId || "openmaptiles",
|
|
1154
900
|
"source-layer": props.sourceLayer || "building",
|
|
1155
901
|
minzoom: props.minZoom || 14,
|
|
1156
|
-
paint:
|
|
902
|
+
paint: { ...props.paint
|
|
903
|
+
}
|
|
1157
904
|
}, props.insertBeforeLayer || lastLabelLayerId, componentId.current);
|
|
1158
905
|
}, [mapContext, props.insertBeforeLayer, props.mapId, props.minZoom, props.paint, props.sourceId, props.sourceLayer]);
|
|
1159
|
-
useEffect(
|
|
906
|
+
useEffect(() => {
|
|
1160
907
|
if (!initializedRef.current) return; // toggle layer visibility by changing the layout object's visibility property
|
|
1161
908
|
|
|
1162
909
|
mapRef.current.setLayoutProperty(layerId.current, "visibility", showLayer ? "visible" : "none");
|
|
@@ -1164,9 +911,7 @@ var MlFillExtrusionLayer = function MlFillExtrusionLayer(props) {
|
|
|
1164
911
|
return /*#__PURE__*/React__default.createElement(Button, {
|
|
1165
912
|
color: "primary",
|
|
1166
913
|
variant: showLayer ? "contained" : "outlined",
|
|
1167
|
-
onClick:
|
|
1168
|
-
return setShowLayer(!showLayer);
|
|
1169
|
-
}
|
|
914
|
+
onClick: () => setShowLayer(!showLayer)
|
|
1170
915
|
}, "Composite");
|
|
1171
916
|
};
|
|
1172
917
|
|
|
@@ -1235,7 +980,7 @@ MlFillExtrusionLayer.propTypes = {
|
|
|
1235
980
|
insertBeforeLayer: PropTypes.string
|
|
1236
981
|
};
|
|
1237
982
|
|
|
1238
|
-
|
|
983
|
+
const getDefaultPaintPropsByType = (type, defaultPaintOverrides) => {
|
|
1239
984
|
switch (type) {
|
|
1240
985
|
case "fill":
|
|
1241
986
|
if (defaultPaintOverrides !== null && defaultPaintOverrides !== void 0 && defaultPaintOverrides.fill) {
|
|
@@ -1270,7 +1015,7 @@ var getDefaultPaintPropsByType = function getDefaultPaintPropsByType(type, defau
|
|
|
1270
1015
|
}
|
|
1271
1016
|
};
|
|
1272
1017
|
|
|
1273
|
-
|
|
1018
|
+
const mapGeometryTypesToLayerTypes = {
|
|
1274
1019
|
Position: "circle",
|
|
1275
1020
|
Point: "circle",
|
|
1276
1021
|
MultiPoint: "circle",
|
|
@@ -1281,7 +1026,7 @@ var mapGeometryTypesToLayerTypes = {
|
|
|
1281
1026
|
GeometryCollection: "circle"
|
|
1282
1027
|
};
|
|
1283
1028
|
|
|
1284
|
-
|
|
1029
|
+
const getDefaulLayerTypeByGeometry = geojson => {
|
|
1285
1030
|
if ((geojson === null || geojson === void 0 ? void 0 : geojson.type) === "Feature") {
|
|
1286
1031
|
var _geojson$geometry;
|
|
1287
1032
|
|
|
@@ -1297,48 +1042,48 @@ var getDefaulLayerTypeByGeometry = function getDefaulLayerTypeByGeometry(geojson
|
|
|
1297
1042
|
}
|
|
1298
1043
|
};
|
|
1299
1044
|
|
|
1300
|
-
|
|
1045
|
+
const legalLayerTypes = ["circle", "fill", "line"];
|
|
1301
1046
|
/**
|
|
1302
1047
|
* Adds source and layer of types "line", "fill" or "circle" to display GeoJSON data on the map.
|
|
1303
1048
|
*
|
|
1304
1049
|
* @component
|
|
1305
1050
|
*/
|
|
1306
1051
|
|
|
1307
|
-
|
|
1052
|
+
const MlGeoJsonLayer = props => {
|
|
1308
1053
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
1309
|
-
|
|
1054
|
+
const mapHook = useMap({
|
|
1310
1055
|
mapId: props.mapId,
|
|
1311
1056
|
waitForLayer: props.insertBeforeLayer
|
|
1312
1057
|
});
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
useEffect(
|
|
1058
|
+
const initializedRef = useRef(false);
|
|
1059
|
+
const layerId = useRef(props.layerId || "MlGeoJsonLayer-" + mapHook.componentId);
|
|
1060
|
+
const layerTypeRef = useRef(undefined);
|
|
1061
|
+
useEffect(() => {
|
|
1317
1062
|
if (!mapHook.map || !initializedRef.current) return;
|
|
1318
1063
|
|
|
1319
1064
|
for (var key in props.layout) {
|
|
1320
1065
|
mapHook.map.setLayoutProperty(layerId.current, key, props.layout[key]);
|
|
1321
1066
|
}
|
|
1322
1067
|
}, [props.layout, mapHook.map, props.mapId]);
|
|
1323
|
-
useEffect(
|
|
1068
|
+
useEffect(() => {
|
|
1324
1069
|
if (!mapHook.map || !initializedRef.current) return;
|
|
1325
1070
|
|
|
1326
|
-
|
|
1071
|
+
let _paint = props.paint || getDefaultPaintPropsByType(layerTypeRef.current, props.defaultPaintOverrides);
|
|
1327
1072
|
|
|
1328
1073
|
for (var key in _paint) {
|
|
1329
1074
|
mapHook.map.setPaintProperty(layerId.current, key, _paint[key]);
|
|
1330
1075
|
}
|
|
1331
1076
|
}, [props.paint, mapHook.map, props.mapId, props.defaultPaintOverrides]);
|
|
1332
|
-
useEffect(
|
|
1077
|
+
useEffect(() => {
|
|
1333
1078
|
var _mapHook$map;
|
|
1334
1079
|
|
|
1335
1080
|
if (!(mapHook !== null && mapHook !== void 0 && (_mapHook$map = mapHook.map) !== null && _mapHook$map !== void 0 && _mapHook$map.getSource(layerId.current)) || !initializedRef.current) return;
|
|
1336
1081
|
mapHook.map.getSource(layerId.current).setData(props.geojson);
|
|
1337
1082
|
}, [props.geojson, mapHook.map, props.type]);
|
|
1338
|
-
|
|
1339
|
-
|
|
1083
|
+
const createLayer = useCallback(() => {
|
|
1084
|
+
let geojson = props.geojson;
|
|
1340
1085
|
layerTypeRef.current = props.type || getDefaulLayerTypeByGeometry(props.geojson);
|
|
1341
|
-
mapHook.map.addLayer(
|
|
1086
|
+
mapHook.map.addLayer({
|
|
1342
1087
|
id: layerId.current,
|
|
1343
1088
|
source: {
|
|
1344
1089
|
type: "geojson",
|
|
@@ -1346,8 +1091,9 @@ var MlGeoJsonLayer = function MlGeoJsonLayer(props) {
|
|
|
1346
1091
|
},
|
|
1347
1092
|
type: layerTypeRef.current,
|
|
1348
1093
|
paint: props.paint || getDefaultPaintPropsByType(layerTypeRef.current, props.defaultPaintOverrides),
|
|
1349
|
-
layout: props.layout || {}
|
|
1350
|
-
|
|
1094
|
+
layout: props.layout || {},
|
|
1095
|
+
...props.options
|
|
1096
|
+
}, props.insertBeforeLayer, mapHook.componentId);
|
|
1351
1097
|
|
|
1352
1098
|
if (typeof props.onHover !== "undefined") {
|
|
1353
1099
|
mapHook.map.on("mousemove", layerId.current, props.onHover, mapHook.componentId);
|
|
@@ -1361,7 +1107,7 @@ var MlGeoJsonLayer = function MlGeoJsonLayer(props) {
|
|
|
1361
1107
|
mapHook.map.on("mouseleave", layerId.current, props.onLeave, mapHook.componentId);
|
|
1362
1108
|
}
|
|
1363
1109
|
}, [mapHook, props]);
|
|
1364
|
-
useEffect(
|
|
1110
|
+
useEffect(() => {
|
|
1365
1111
|
if (!mapHook.map || !props.geojson) return;
|
|
1366
1112
|
|
|
1367
1113
|
if (initializedRef.current && legalLayerTypes.indexOf(props.type) !== -1 && layerTypeRef.current && props.type !== layerTypeRef.current) {
|
|
@@ -1460,38 +1206,17 @@ MlGeoJsonLayer.propTypes = {
|
|
|
1460
1206
|
* @component
|
|
1461
1207
|
*/
|
|
1462
1208
|
|
|
1463
|
-
|
|
1464
|
-
|
|
1209
|
+
const MlFollowGps = props => {
|
|
1210
|
+
const mapHook = useMap({
|
|
1465
1211
|
mapId: props.mapId,
|
|
1466
1212
|
waitForLayer: props.insertBeforeLayer
|
|
1467
1213
|
});
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
var _useState3 = useState(undefined),
|
|
1475
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
1476
|
-
userLocationGeoJson = _useState4[0],
|
|
1477
|
-
setUserLocationGeoJson = _useState4[1];
|
|
1478
|
-
|
|
1479
|
-
var _useState5 = useState(false),
|
|
1480
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
1481
|
-
locationAccessDenied = _useState6[0],
|
|
1482
|
-
setLocationAccessDenied = _useState6[1];
|
|
1483
|
-
|
|
1484
|
-
var _useState7 = useState(),
|
|
1485
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
1486
|
-
accuracyGeoJson = _useState8[0],
|
|
1487
|
-
setAccuracyGeoJson = _useState8[1];
|
|
1488
|
-
|
|
1489
|
-
var _useState9 = useState(0),
|
|
1490
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
1491
|
-
deviceOrientation = _useState10[0],
|
|
1492
|
-
setDeviceOrientation = _useState10[1];
|
|
1493
|
-
|
|
1494
|
-
var getLocationSuccess = useCallback(function (pos) {
|
|
1214
|
+
const [isFollowed, setIsFollowed] = useState(false);
|
|
1215
|
+
const [userLocationGeoJson, setUserLocationGeoJson] = useState(undefined);
|
|
1216
|
+
const [locationAccessDenied, setLocationAccessDenied] = useState(false);
|
|
1217
|
+
const [accuracyGeoJson, setAccuracyGeoJson] = useState();
|
|
1218
|
+
const [deviceOrientation, setDeviceOrientation] = useState(0);
|
|
1219
|
+
const getLocationSuccess = useCallback(pos => {
|
|
1495
1220
|
if (!mapHook.map) return;
|
|
1496
1221
|
mapHook.map.flyTo({
|
|
1497
1222
|
center: [pos.coords.longitude, pos.coords.latitude],
|
|
@@ -1500,54 +1225,54 @@ var MlFollowGps = function MlFollowGps(props) {
|
|
|
1500
1225
|
curve: 1
|
|
1501
1226
|
});
|
|
1502
1227
|
if (!props.showUserLocation) return;
|
|
1503
|
-
|
|
1228
|
+
const geoJsonPoint = point([pos.coords.longitude, pos.coords.latitude]);
|
|
1504
1229
|
setUserLocationGeoJson(geoJsonPoint);
|
|
1505
1230
|
setAccuracyGeoJson(circle(geoJsonPoint, pos.coords.accuracy / 1000));
|
|
1506
1231
|
}, [mapHook.map, props]);
|
|
1507
1232
|
|
|
1508
|
-
|
|
1233
|
+
const getLocationError = err => {
|
|
1509
1234
|
console.log("Access of user location denied");
|
|
1510
1235
|
setLocationAccessDenied(true);
|
|
1511
1236
|
};
|
|
1512
1237
|
|
|
1513
|
-
|
|
1238
|
+
const orientationCone = useMemo(() => {
|
|
1514
1239
|
if (!userLocationGeoJson) {
|
|
1515
1240
|
return undefined;
|
|
1516
1241
|
}
|
|
1517
1242
|
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1243
|
+
let radius = 0.02;
|
|
1244
|
+
let bearing1 = deviceOrientation - 15;
|
|
1245
|
+
let bearing2 = deviceOrientation + 15;
|
|
1246
|
+
const options = {
|
|
1522
1247
|
steps: 65
|
|
1523
1248
|
};
|
|
1524
|
-
|
|
1525
|
-
|
|
1249
|
+
let arc = lineArc(userLocationGeoJson, radius, bearing1, bearing2, options);
|
|
1250
|
+
let copy = arc;
|
|
1526
1251
|
copy.geometry.coordinates.push(userLocationGeoJson.geometry.coordinates);
|
|
1527
1252
|
copy.geometry.coordinates.slice(0, 0, userLocationGeoJson.geometry.coordinates);
|
|
1528
1253
|
return copy;
|
|
1529
1254
|
}, [deviceOrientation, userLocationGeoJson]);
|
|
1530
1255
|
|
|
1531
|
-
|
|
1256
|
+
const handleOrientation = event => {
|
|
1532
1257
|
setDeviceOrientation(-event.alpha);
|
|
1533
1258
|
};
|
|
1534
1259
|
|
|
1535
|
-
useEffect(
|
|
1260
|
+
useEffect(() => {
|
|
1536
1261
|
if (isFollowed) {
|
|
1537
|
-
|
|
1262
|
+
let _handleOrientation = handleOrientation;
|
|
1538
1263
|
window.addEventListener('deviceorientation', _handleOrientation);
|
|
1539
|
-
return
|
|
1264
|
+
return () => {
|
|
1540
1265
|
window.removeEventListener('deviceorientation', _handleOrientation);
|
|
1541
1266
|
};
|
|
1542
1267
|
}
|
|
1543
1268
|
}, [isFollowed]);
|
|
1544
|
-
useEffect(
|
|
1269
|
+
useEffect(() => {
|
|
1545
1270
|
if (!mapHook.map) return;
|
|
1546
1271
|
|
|
1547
1272
|
if (isFollowed) {
|
|
1548
|
-
|
|
1273
|
+
let _watchId = navigator.geolocation.watchPosition(getLocationSuccess, getLocationError);
|
|
1549
1274
|
|
|
1550
|
-
return
|
|
1275
|
+
return () => {
|
|
1551
1276
|
navigator.geolocation.clearWatch(_watchId);
|
|
1552
1277
|
};
|
|
1553
1278
|
}
|
|
@@ -1555,10 +1280,11 @@ var MlFollowGps = function MlFollowGps(props) {
|
|
|
1555
1280
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, isFollowed && userLocationGeoJson && /*#__PURE__*/React__default.createElement(MlGeoJsonLayer, {
|
|
1556
1281
|
geojson: accuracyGeoJson,
|
|
1557
1282
|
type: "fill",
|
|
1558
|
-
paint:
|
|
1283
|
+
paint: {
|
|
1559
1284
|
"fill-color": "#cbd300",
|
|
1560
|
-
"fill-opacity": 0.3
|
|
1561
|
-
|
|
1285
|
+
"fill-opacity": 0.3,
|
|
1286
|
+
...props.accuracyPaint
|
|
1287
|
+
},
|
|
1562
1288
|
insertBeforeLayer: props.insertBeforeLayer
|
|
1563
1289
|
}), isFollowed && orientationCone && /*#__PURE__*/React__default.createElement(MlGeoJsonLayer, {
|
|
1564
1290
|
geojson: orientationCone,
|
|
@@ -1572,20 +1298,22 @@ var MlFollowGps = function MlFollowGps(props) {
|
|
|
1572
1298
|
}), isFollowed && userLocationGeoJson && /*#__PURE__*/React__default.createElement(MlGeoJsonLayer, {
|
|
1573
1299
|
geojson: userLocationGeoJson,
|
|
1574
1300
|
type: "circle",
|
|
1575
|
-
paint:
|
|
1301
|
+
paint: {
|
|
1576
1302
|
"circle-color": "#009ee0",
|
|
1577
1303
|
"circle-radius": 5,
|
|
1578
1304
|
"circle-stroke-color": "#fafaff",
|
|
1579
|
-
"circle-stroke-width": 1
|
|
1580
|
-
|
|
1305
|
+
"circle-stroke-width": 1,
|
|
1306
|
+
...props.circlePaint
|
|
1307
|
+
},
|
|
1581
1308
|
insertBeforeLayer: props.insertBeforeLayer
|
|
1582
1309
|
}), /*#__PURE__*/React__default.createElement(Button, {
|
|
1583
|
-
sx:
|
|
1310
|
+
sx: {
|
|
1584
1311
|
zIndex: 1002,
|
|
1585
|
-
color: isFollowed ? props.onColor : props.offColor
|
|
1586
|
-
|
|
1312
|
+
color: isFollowed ? props.onColor : props.offColor,
|
|
1313
|
+
...props.style
|
|
1314
|
+
},
|
|
1587
1315
|
disabled: locationAccessDenied,
|
|
1588
|
-
onClick:
|
|
1316
|
+
onClick: () => {
|
|
1589
1317
|
setIsFollowed(!isFollowed);
|
|
1590
1318
|
}
|
|
1591
1319
|
}, " ", /*#__PURE__*/React__default.createElement(GpsFixedIcon, {
|
|
@@ -1670,7 +1398,7 @@ MlFollowGps.propTypes = {
|
|
|
1670
1398
|
showOrientation: PropTypes.bool
|
|
1671
1399
|
};
|
|
1672
1400
|
|
|
1673
|
-
|
|
1401
|
+
const nmMap = {
|
|
1674
1402
|
street: ["footway", "street", "road", "street_name", "residential", "path", "pedestrian", "road_reference", "road_reference_intl", "square", "place"],
|
|
1675
1403
|
number: ["house_number", "street_number"],
|
|
1676
1404
|
place: ["city", "village", "hamlet", "locality", "croft", "neighbourhood", "suburb", "city_district", "district", "quarter", "borough", "city_block", "residential", "commercial", "industrial", "houses", "subdivision", "allotments", "postal_city", "town", "municipality", "local_administrative_area"],
|
|
@@ -1678,11 +1406,11 @@ var nmMap = {
|
|
|
1678
1406
|
state: ["state", "province", "state_code"]
|
|
1679
1407
|
};
|
|
1680
1408
|
|
|
1681
|
-
|
|
1682
|
-
|
|
1409
|
+
const nmConverter = nmAddress => {
|
|
1410
|
+
const addressArr = [];
|
|
1683
1411
|
|
|
1684
|
-
for (
|
|
1685
|
-
nmMap[key].some(
|
|
1412
|
+
for (let key in nmMap) {
|
|
1413
|
+
nmMap[key].some(element => {
|
|
1686
1414
|
if (nmAddress.hasOwnProperty(element)) {
|
|
1687
1415
|
addressArr.push(nmAddress[element]);
|
|
1688
1416
|
return true;
|
|
@@ -1695,28 +1423,28 @@ var nmConverter = function nmConverter(nmAddress) {
|
|
|
1695
1423
|
return addressArr.join(", ");
|
|
1696
1424
|
};
|
|
1697
1425
|
|
|
1698
|
-
|
|
1699
|
-
|
|
1426
|
+
const toPixels = length => {
|
|
1427
|
+
let conversionFactor = 96;
|
|
1700
1428
|
conversionFactor /= 25.4;
|
|
1701
1429
|
return conversionFactor * length + "px";
|
|
1702
1430
|
};
|
|
1703
1431
|
|
|
1704
|
-
|
|
1432
|
+
const createPdf = (map, locationValue, setLoading) => {
|
|
1705
1433
|
setLoading(true);
|
|
1706
|
-
|
|
1707
|
-
|
|
1434
|
+
const width = 210;
|
|
1435
|
+
const height = 297; // Calculate pixel ratio
|
|
1708
1436
|
|
|
1709
|
-
|
|
1437
|
+
const actualPixelRatio = window.devicePixelRatio; // Create map container
|
|
1710
1438
|
|
|
1711
|
-
|
|
1439
|
+
const hidden = document.createElement("div");
|
|
1712
1440
|
hidden.className = "hidden-map";
|
|
1713
1441
|
document.body.appendChild(hidden);
|
|
1714
|
-
|
|
1442
|
+
const container = document.createElement("div");
|
|
1715
1443
|
container.style.width = toPixels(width);
|
|
1716
1444
|
container.style.height = toPixels(height);
|
|
1717
1445
|
hidden.appendChild(container); //Render map
|
|
1718
1446
|
|
|
1719
|
-
var renderMap = new maplibregl
|
|
1447
|
+
var renderMap = new maplibregl.Map({
|
|
1720
1448
|
container: container,
|
|
1721
1449
|
center: map.getCenter(),
|
|
1722
1450
|
zoom: map.getZoom(),
|
|
@@ -1727,21 +1455,17 @@ var createPdf = function createPdf(map, locationValue, setLoading) {
|
|
|
1727
1455
|
fadeDuration: 0,
|
|
1728
1456
|
attributionControl: false
|
|
1729
1457
|
});
|
|
1730
|
-
|
|
1458
|
+
let style = map.getStyle();
|
|
1731
1459
|
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
Object.keys(src).forEach(
|
|
1460
|
+
for (let name in style.sources) {
|
|
1461
|
+
let src = style.sources[name];
|
|
1462
|
+
Object.keys(src).forEach(key => {
|
|
1735
1463
|
//delete properties if value is undefined.
|
|
1736
1464
|
// for instance, raster-dem might has undefined value in "url" and "bounds"
|
|
1737
1465
|
if (!src[key]) {
|
|
1738
1466
|
delete src[key];
|
|
1739
1467
|
}
|
|
1740
1468
|
});
|
|
1741
|
-
};
|
|
1742
|
-
|
|
1743
|
-
for (var name in style.sources) {
|
|
1744
|
-
_loop(name);
|
|
1745
1469
|
}
|
|
1746
1470
|
|
|
1747
1471
|
renderMap.setStyle(style);
|
|
@@ -1749,32 +1473,32 @@ var createPdf = function createPdf(map, locationValue, setLoading) {
|
|
|
1749
1473
|
var _hidden$parentNode;
|
|
1750
1474
|
|
|
1751
1475
|
// TO DO: It is still under development
|
|
1752
|
-
|
|
1476
|
+
const pdf = new jsPDF({
|
|
1753
1477
|
orientation: "p",
|
|
1754
1478
|
unit: "mm",
|
|
1755
1479
|
compress: true
|
|
1756
1480
|
});
|
|
1757
1481
|
Object.defineProperty(window, "devicePixelRatio", {
|
|
1758
|
-
get: function
|
|
1482
|
+
get: function () {
|
|
1759
1483
|
return 300 / 96;
|
|
1760
1484
|
}
|
|
1761
1485
|
});
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1486
|
+
const offsetX = 2.5;
|
|
1487
|
+
const offsetY = 2.5;
|
|
1488
|
+
const marginTop = 3;
|
|
1489
|
+
const marginBottom = 3;
|
|
1490
|
+
const innerMargin = 2;
|
|
1491
|
+
const logo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKgAAACxCAMAAABnTAbVAAAC8VBMVEUAAAD/AACAAACqAFW/AECZMzOqK1W2JEm/IECqHD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Uj0LyUCqpbDbvdzwaTocWQUqqaB7stYr1MaJNQRDV3wG7v8DdrJGjU7SBVXA+7fcELPgyFZh2+oL/+sJmjjOd9HAYdWuXQzxWwWS+e92EodJEWeagQA5tNJ7khFHrdUk65cNgsh8wOhX4991GmFewVVs7nHTAiYil9tYO9Uuruh1F3n2GTONjr6dEwrnMevfrBXrEwwzGvig3GomXrvoP1HkQLJ6WV8II30OJ1XO0huQu/AwN3k5Vh+B1wpP3EIfhdCE2fhv+X/wF/AO+L9vuzfwAAAABJRU5ErkJggg==";
|
|
1492
|
+
const textBuffer = 1;
|
|
1493
|
+
const lineHeight = 3.25;
|
|
1494
|
+
const text = locationValue ? nmConverter(locationValue.address) : "";
|
|
1495
|
+
const textChunksSeperator = text.split(",");
|
|
1496
|
+
const textChunks = [];
|
|
1773
1497
|
|
|
1774
1498
|
if (textChunks.length) {
|
|
1775
|
-
textChunksSeperator.forEach(
|
|
1776
|
-
|
|
1777
|
-
textChunks.push
|
|
1499
|
+
textChunksSeperator.forEach(chunk => {
|
|
1500
|
+
const limitChunks = chunk.match(/.{1,34}/g);
|
|
1501
|
+
textChunks.push(...limitChunks);
|
|
1778
1502
|
});
|
|
1779
1503
|
} //Render map image
|
|
1780
1504
|
|
|
@@ -1788,7 +1512,7 @@ var createPdf = function createPdf(map, locationValue, setLoading) {
|
|
|
1788
1512
|
pdf.text("Datenquelle: © OpenStreetMap-Mitwirkende", 140, pdf.internal.pageSize.height - 3); //Render infobox
|
|
1789
1513
|
|
|
1790
1514
|
pdf.setFillColor("white");
|
|
1791
|
-
|
|
1515
|
+
const infoBoxSize = textChunks.length * lineHeight + marginTop + marginBottom + lineHeight * 2 + innerMargin * 2 + textBuffer;
|
|
1792
1516
|
pdf.rect(offsetX, 2, 66.5, infoBoxSize, "F");
|
|
1793
1517
|
pdf.setFontSize(10);
|
|
1794
1518
|
pdf.text("Karten PDF:", 6, offsetY + marginTop); //Render inner infobox
|
|
@@ -1796,7 +1520,7 @@ var createPdf = function createPdf(map, locationValue, setLoading) {
|
|
|
1796
1520
|
pdf.rect(6, 7, 60, textChunks.length * lineHeight + innerMargin * 2 + textBuffer);
|
|
1797
1521
|
pdf.setFontSize(10); //Write out address
|
|
1798
1522
|
|
|
1799
|
-
textChunks.forEach(
|
|
1523
|
+
textChunks.forEach((text, i) => {
|
|
1800
1524
|
pdf.text(text.trim(), 8, 10 + i * 3.5 + innerMargin);
|
|
1801
1525
|
}); //Add WG Logo
|
|
1802
1526
|
|
|
@@ -1815,7 +1539,7 @@ var createPdf = function createPdf(map, locationValue, setLoading) {
|
|
|
1815
1539
|
renderMap.remove();
|
|
1816
1540
|
(_hidden$parentNode = hidden.parentNode) === null || _hidden$parentNode === void 0 ? void 0 : _hidden$parentNode.removeChild(hidden);
|
|
1817
1541
|
Object.defineProperty(window, "devicePixelRatio", {
|
|
1818
|
-
get: function
|
|
1542
|
+
get: function () {
|
|
1819
1543
|
return actualPixelRatio;
|
|
1820
1544
|
}
|
|
1821
1545
|
});
|
|
@@ -1829,11 +1553,11 @@ var createPdf = function createPdf(map, locationValue, setLoading) {
|
|
|
1829
1553
|
* @component
|
|
1830
1554
|
*/
|
|
1831
1555
|
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
useEffect(
|
|
1556
|
+
const MlCreatePdfButton = props => {
|
|
1557
|
+
const mapContext = useContext(MapContext);
|
|
1558
|
+
const initializedRef = useRef(false);
|
|
1559
|
+
const mapRef = useRef(undefined);
|
|
1560
|
+
useEffect(() => {
|
|
1837
1561
|
if (!mapContext.mapExists(props.mapId) || initializedRef.current) return;
|
|
1838
1562
|
initializedRef.current = true;
|
|
1839
1563
|
mapRef.current = mapContext.getMap(props.mapId);
|
|
@@ -1841,8 +1565,8 @@ var MlCreatePdfButton = function MlCreatePdfButton(props) {
|
|
|
1841
1565
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Button, {
|
|
1842
1566
|
color: "primary",
|
|
1843
1567
|
variant: "contained",
|
|
1844
|
-
onClick:
|
|
1845
|
-
createPdf(mapRef.current, null,
|
|
1568
|
+
onClick: () => {
|
|
1569
|
+
createPdf(mapRef.current, null, () => {});
|
|
1846
1570
|
}
|
|
1847
1571
|
}, /*#__PURE__*/React__default.createElement(PrinterIcon, null)));
|
|
1848
1572
|
};
|
|
@@ -1857,15 +1581,15 @@ MlCreatePdfButton.propTypes = {
|
|
|
1857
1581
|
mapId: PropTypes.string
|
|
1858
1582
|
};
|
|
1859
1583
|
|
|
1860
|
-
|
|
1861
|
-
|
|
1584
|
+
const MlImageMarkerLayer = props => {
|
|
1585
|
+
const mapHook = useMap({
|
|
1862
1586
|
mapId: props.mapId,
|
|
1863
1587
|
waitForLayer: props.insertBeforeLayer
|
|
1864
1588
|
});
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
useEffect(
|
|
1589
|
+
const layerInitializedRef = useRef(false);
|
|
1590
|
+
const imageIdRef = useRef(props.imageId || "img_" + new Date().getTime());
|
|
1591
|
+
const layerId = useRef(props.layerId || "MlImageMarkerLayer-" + mapHook.componentId);
|
|
1592
|
+
useEffect(() => {
|
|
1869
1593
|
if (!mapHook.mapIsReady || mapHook.map && !mapHook.map.getLayer(layerId.current) || !props.options) return; // the MapLibre-gl instance (mapContext.map) is accessible here
|
|
1870
1594
|
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
1871
1595
|
|
|
@@ -1883,16 +1607,16 @@ var MlImageMarkerLayer = function MlImageMarkerLayer(props) {
|
|
|
1883
1607
|
}
|
|
1884
1608
|
}
|
|
1885
1609
|
}, [props.options, layerId.current, props.mapId]);
|
|
1886
|
-
|
|
1887
|
-
|
|
1610
|
+
const addLayer = useCallback(() => {
|
|
1611
|
+
let tmpOptions = {
|
|
1888
1612
|
id: layerId.current,
|
|
1889
|
-
layout: {}
|
|
1890
|
-
|
|
1891
|
-
|
|
1613
|
+
layout: {},
|
|
1614
|
+
...props.options
|
|
1615
|
+
};
|
|
1892
1616
|
tmpOptions.layout["icon-image"] = imageIdRef.current;
|
|
1893
1617
|
mapHook.map.addLayer(tmpOptions, props.insertBeforeLayer, mapHook.componentId);
|
|
1894
1618
|
}, [props, mapHook.mapIsReady, mapHook.map]);
|
|
1895
|
-
useEffect(
|
|
1619
|
+
useEffect(() => {
|
|
1896
1620
|
if (!props.options || !mapHook.mapIsReady || layerInitializedRef.current) return;
|
|
1897
1621
|
layerInitializedRef.current = true;
|
|
1898
1622
|
|
|
@@ -1905,7 +1629,7 @@ var MlImageMarkerLayer = function MlImageMarkerLayer(props) {
|
|
|
1905
1629
|
|
|
1906
1630
|
addLayer();
|
|
1907
1631
|
}, [mapHook.mapIsReady, mapHook.map, addLayer, props]);
|
|
1908
|
-
useEffect(
|
|
1632
|
+
useEffect(() => {
|
|
1909
1633
|
if (!mapHook.mapIsReady || mapHook.map && !mapHook.map.getLayer(layerId.current) || !props.options) {
|
|
1910
1634
|
return;
|
|
1911
1635
|
}
|
|
@@ -1969,7 +1693,7 @@ function SvgNeedle(props) {
|
|
|
1969
1693
|
|
|
1970
1694
|
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
1971
1695
|
|
|
1972
|
-
|
|
1696
|
+
const NeedleButton = _styled("div", process.env.NODE_ENV === "production" ? {
|
|
1973
1697
|
target: "e12lzm5x2"
|
|
1974
1698
|
} : {
|
|
1975
1699
|
target: "e12lzm5x2",
|
|
@@ -1984,7 +1708,7 @@ var NeedleButton = _styled("div", process.env.NODE_ENV === "production" ? {
|
|
|
1984
1708
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
1985
1709
|
});
|
|
1986
1710
|
|
|
1987
|
-
|
|
1711
|
+
const NeedleContainer = _styled("div", process.env.NODE_ENV === "production" ? {
|
|
1988
1712
|
target: "e12lzm5x1"
|
|
1989
1713
|
} : {
|
|
1990
1714
|
target: "e12lzm5x1",
|
|
@@ -1999,7 +1723,7 @@ var NeedleContainer = _styled("div", process.env.NODE_ENV === "production" ? {
|
|
|
1999
1723
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
2000
1724
|
});
|
|
2001
1725
|
|
|
2002
|
-
|
|
1726
|
+
const RotateButton = _styled("div", process.env.NODE_ENV === "production" ? {
|
|
2003
1727
|
target: "e12lzm5x0"
|
|
2004
1728
|
} : {
|
|
2005
1729
|
target: "e12lzm5x0",
|
|
@@ -2022,21 +1746,16 @@ var RotateButton = _styled("div", process.env.NODE_ENV === "production" ? {
|
|
|
2022
1746
|
*/
|
|
2023
1747
|
|
|
2024
1748
|
|
|
2025
|
-
|
|
2026
|
-
|
|
1749
|
+
const MlNavigationCompass = props => {
|
|
1750
|
+
const mapHook = useMap({
|
|
2027
1751
|
mapId: props.mapId,
|
|
2028
1752
|
waitForLayer: props.insertBeforeLayer
|
|
2029
1753
|
});
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
2033
|
-
bearing = _useState2[0],
|
|
2034
|
-
setBearing = _useState2[1];
|
|
2035
|
-
|
|
2036
|
-
useEffect(function () {
|
|
1754
|
+
const [bearing, setBearing] = useState(0);
|
|
1755
|
+
useEffect(() => {
|
|
2037
1756
|
if (!mapHook.map) return;
|
|
2038
1757
|
|
|
2039
|
-
|
|
1758
|
+
let _updateBearing = () => {
|
|
2040
1759
|
setBearing(Math.round(mapHook.map.getBearing()));
|
|
2041
1760
|
};
|
|
2042
1761
|
|
|
@@ -2044,18 +1763,19 @@ var MlNavigationCompass = function MlNavigationCompass(props) {
|
|
|
2044
1763
|
|
|
2045
1764
|
_updateBearing();
|
|
2046
1765
|
|
|
2047
|
-
return
|
|
1766
|
+
return () => {
|
|
2048
1767
|
mapHook.map.off("rotate", _updateBearing);
|
|
2049
1768
|
};
|
|
2050
1769
|
}, [mapHook.map, props.mapId]);
|
|
2051
1770
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
|
|
2052
|
-
className: /*#__PURE__*/css(
|
|
1771
|
+
className: /*#__PURE__*/css({
|
|
2053
1772
|
zIndex: 1000,
|
|
2054
1773
|
top: 0,
|
|
2055
|
-
position: "absolute"
|
|
2056
|
-
|
|
1774
|
+
position: "absolute",
|
|
1775
|
+
...props.style
|
|
1776
|
+
}, process.env.NODE_ENV === "production" ? "" : ";label:MlNavigationCompass;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIk1sTmF2aWdhdGlvbkNvbXBhc3MuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBNkdtQiIsImZpbGUiOiJNbE5hdmlnYXRpb25Db21wYXNzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlYWN0LCB7IHVzZVN0YXRlLCB1c2VFZmZlY3QgfSBmcm9tIFwicmVhY3RcIjtcbmltcG9ydCBQcm9wVHlwZXMgZnJvbSBcInByb3AtdHlwZXNcIjtcblxuaW1wb3J0IHsgUmVhY3RDb21wb25lbnQgYXMgUm90YXRlUmlnaHRJY29uIH0gZnJvbSBcIi4vYXNzZXRzL3JvdGF0ZV9yaWdodC5zdmdcIjtcbmltcG9ydCB7IFJlYWN0Q29tcG9uZW50IGFzIFJvdGF0ZUxlZnRJY29uIH0gZnJvbSBcIi4vYXNzZXRzL3JvdGF0ZV9sZWZ0LnN2Z1wiO1xuaW1wb3J0IHsgUmVhY3RDb21wb25lbnQgYXMgTmVlZGxlSWNvbiB9IGZyb20gXCIuL2Fzc2V0cy9uZWVkbGUuc3ZnXCI7XG5cbmltcG9ydCBzdHlsZWQgZnJvbSBcIkBlbW90aW9uL3N0eWxlZFwiO1xuaW1wb3J0IHsgY3NzIH0gZnJvbSBcIkBlbW90aW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ICAgICAgICAgICBib3JkZXI6IFwiMTBweCBzb2xpZCAjYmNiY2JjXCIsXG4gICAgICAgICAgICBiYWNrZ3JvdW5kQ29sb3I6IFwiIzcxNzE3MVwiLFxuICAgICAgICAgICAgYmFja2dyb3VuZDogXCJyYWRpYWwtZ3JhZGllbnQoIzcxNzE3MSwgIzQxNDE0MSlcIixcbiAgICAgICAgICAgIGhlaWdodDogXCIyMDBweFwiLFxuICAgICAgICAgICAgd2lkdGg6IFwiMjAwcHhcIixcbiAgICAgICAgICAgIGJvcmRlclJhZGl1czogXCI1MCVcIixcbiAgICAgICAgICAgIGRpc3BsYXk6IFwiZmxleFwiLFxuICAgICAgICAgICAganVzdGlmeUNvbnRlbnQ6IFwiY2VudGVyXCIsXG4gICAgICAgICAgICB0cmFuc2Zvcm06IFwic2NhbGUoMC4yKSB0cmFuc2xhdGVYKC00NDhweCkgdHJhbnNsYXRlWSgtNDQ4cHgpXCIsXG4gICAgICAgICAgICAuLi5wcm9wcy5iYWNrZ3JvdW5kU3R5bGUsXG4gICAgICAgICAgfSl9XG4gICAgICAgID5cbiAgICAgICAgICA8Um90YXRlQnV0dG9uIGNsYXNzTmFtZT17Y3NzKHsgLi4ucHJvcHMucm90YXRlUmlnaHRTdHlsZSB9KX0+XG4gICAgICAgICAgICA8Um90YXRlUmlnaHRJY29uXG4gICAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgICBsZXQgYmVhcmluZyA9IE1hdGgucm91bmQobWFwSG9vay5tYXA/LmdldEJlYXJpbmcoKSk7XG4gICAgICAgICAgICAgICAgbGV0IHJlc3QgPSBNYXRoLnJvdW5kKGJlYXJpbmcgJSA5MCk7XG4gICAgICAgICAgICAgICAgaWYgKGJlYXJpbmcgPiAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTAgLSByZXN0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAocmVzdCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgcmVzdCA9IDkwO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBtYXBIb29rLm1hcD8uc2V0QmVhcmluZyhNYXRoLnJvdW5kKGJlYXJpbmcgKyBNYXRoLmFicyhyZXN0KSkpO1xuICAgICAgICAgICAgICB9fVxuICAgICAgICAgICAgPjwvUm90YXRlUmlnaHRJY29uPlxuICAgICAgICAgIDwvUm90YXRlQnV0dG9uPlxuICAgICAgICAgIDxOZWVkbGVCdXR0b25cbiAgICAgICAgICAgIGNsYXNzTmFtZT17Y3NzKHsgLi4ucHJvcHMubmVlZGxlU3R5bGUgfSl9XG4gICAgICAgICAgICBvbkNsaWNrPXsoKSA9PiB7XG4gICAgICAgICAgICAgIG1hcEhvb2subWFwPy5zZXRCZWFyaW5nKDApO1xuICAgICAgICAgICAgfX1cbiAgICAgICAgICA+XG4gICAgICAgICAgICA8TmVlZGxlQ29udGFpbmVyXG4gICAgICAgICAgICAgIHN0eWxlPXt7XG4gICAgICAgICAgICAgICAgdHJhbnNmb3JtOiBcInJvdGF0ZShcIiArIGJlYXJpbmcgKyBcImRlZylcIixcbiAgICAgICAgICAgICAgfX1cbiAgICAgICAgICAgID5cbiAgICAgICAgICAgICAgPE5lZWRsZUljb24gLz5cbiAgICAgICAgICAgIDwvTmVlZGxlQ29udGFpbmVyPlxuICAgICAgICAgIDwvTmVlZGxlQnV0dG9uPlxuICAgICAgICAgIDxSb3RhdGVCdXR0b24gY2xhc3NOYW1lPXtjc3MoeyAuLi5wcm9wcy5yb3RhdGVMZWZ0U3R5bGUgfSl9PlxuICAgICAgICAgICAgPFJvdGF0ZUxlZnRJY29uXG4gICAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgICBsZXQgYmVhcmluZyA9IE1hdGgucm91bmQobWFwSG9vay5tYXA/LmdldEJlYXJpbmcoKSk7XG4gICAgICAgICAgICAgICAgbGV0IHJlc3QgPSBNYXRoLnJvdW5kK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gLyoqXG4gICAqIFN0eWxlIG9iamVjdCB0byBhZGp1c3QgY3NzIGRlZmluaXRpb25zIG9mIHRoZSByb3RhdGUgcmlnaHQgYnV0dG9uLlxuICAgKi9cbiAgcm90YXRlUmlnaHRTdHlsZTogUHJvcFR5cGVzLm9iamVjdCxcbiAgLyoqXG4gICAqIFN0eWxlIG9iamVjdCB0byBhZGp1c3QgY3NzIGRlZmluaXRpb25zIG9mIHRoZSByb3RhdGUgbGVmdCBidXR0b24uXG4gICAqL1xuICByb3RhdGVMZWZ0U3R5bGU6IFByb3BUeXBlcy5vYmplY3QsXG59O1xuXG5leHBvcnQgZGVmYXVsdCBNbE5hdmlnYXRpb25Db21wYXNzO1xuIl19 */")
|
|
2057
1777
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
2058
|
-
className: /*#__PURE__*/css(
|
|
1778
|
+
className: /*#__PURE__*/css({
|
|
2059
1779
|
position: "absolute",
|
|
2060
1780
|
border: "10px solid #bcbcbc",
|
|
2061
1781
|
backgroundColor: "#717171",
|
|
@@ -2065,16 +1785,18 @@ var MlNavigationCompass = function MlNavigationCompass(props) {
|
|
|
2065
1785
|
borderRadius: "50%",
|
|
2066
1786
|
display: "flex",
|
|
2067
1787
|
justifyContent: "center",
|
|
2068
|
-
transform: "scale(0.2) translateX(-448px) translateY(-448px)"
|
|
2069
|
-
|
|
1788
|
+
transform: "scale(0.2) translateX(-448px) translateY(-448px)",
|
|
1789
|
+
...props.backgroundStyle
|
|
1790
|
+
}, process.env.NODE_ENV === "production" ? "" : ";label:MlNavigationCompass;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIk1sTmF2aWdhdGlvbkNvbXBhc3MuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBcUhxQiIsImZpbGUiOiJNbE5hdmlnYXRpb25Db21wYXNzLmpzIiwic291cmNlc0NvbnRlbnQiOlsi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mcsIG1hcEhvb2suY29tcG9uZW50SWQpO1xuICAgIF91cGRhdGVCZWFyaW5nKCk7XG5cbiAgICByZXR1cm4gKCkgPT4ge1xuICAgICAgbWFwSG9vay5tYXAub2ZmKFwicm90YXRlXCIsIF91cGRhdGVCZWFyaW5nKTtcbiAgICB9O1xuICB9LCBbbWFwSG9vay5tYXAsIHByb3BzLm1hcElkXSk7XG5cbiAgcmV0dXJuIChcbiAgICA8PlxuICAgICAgPGRpdlxuICAgICAgICBjbGFzc05hbWU9e2Nzcyh7XG4gICAgICAgICAgekluZGV4OiAxMDAwLFxuICAgICAgICAgIHRvcDogMCxcbiAgICAgICAgICBwb3NpdGlvbjogXCJhYnNvbHV0ZVwiLFxuICAgICAgICAgIC4uLnByb3BzLnN0eWxlLFxuICAgICAgICB9KX1cbiAgICAgID5cbiAgICAgICAgPGRpdlxuICAgICAgICAgIGNsYXNzTmFtZT17Y3NzKHtcbiAgICAgICAgICAgIHBvc2l0aW9uOiBcImFic29sdXRlXCIsXG4gICAgICAgICAgICBib3JkZXI6IFwiMTBweCBzb2xpZCAjYmNiY2JjXCIsXG4gICAgICAgICAgICBiYWNrZ3JvdW5kQ29sb3I6IFwiIzcxNzE3MVwiLFxuICAgICAgICAgICAgYmFja2dyb3VuZDogXCJyYWRpYWwtZ3JhZGllbnQoIzcxNzE3MSwgIzQxNDE0MSlcIixcbiAgICAgICAgICAgIGhlaWdodDogXCIyMDBweFwiLFxuICAgICAgICAgICAgd2lkdGg6IFwiMjAwcHhcIixcbiAgICAgICAgICAgIGJvcmRlclJhZGl1czogXCI1MCVcIixcbiAgICAgICAgICAgIGRpc3BsYXk6IFwiZmxleFwiLFxuICAgICAgICAgICAganVzdGlmeUNvbnRlbnQ6IFwiY2VudGVyXCIsXG4gICAgICAgICAgICB0cmFuc2Zvcm06IFwic2NhbGUoMC4yKSB0cmFuc2xhdGVYKC00NDhweCkgdHJhbnNsYXRlWSgtNDQ4cHgpXCIsXG4gICAgICAgICAgICAuLi5wcm9wcy5iYWNrZ3JvdW5kU3R5bGUsXG4gICAgICAgICAgfSl9XG4gICAgICAgID5cbiAgICAgICAgICA8Um90YXRlQnV0dG9uIGNsYXNzTmFtZT17Y3NzKHsgLi4ucHJvcHMucm90YXRlUmlnaHRTdHlsZSB9KX0+XG4gICAgICAgICAgICA8Um90YXRlUmlnaHRJY29uXG4gICAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgICBsZXQgYmVhcmluZyA9IE1hdGgucm91bmQobWFwSG9vay5tYXA/LmdldEJlYXJpbmcoKSk7XG4gICAgICAgICAgICAgICAgbGV0IHJlc3QgPSBNYXRoLnJvdW5kKGJlYXJpbmcgJSA5MCk7XG4gICAgICAgICAgICAgICAgaWYgKGJlYXJpbmcgPiAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTAgLSByZXN0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAocmVzdCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgcmVzdCA9IDkwO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBtYXBIb29rLm1hcD8uc2V0QmVhcmluZyhNYXRoLnJvdW5kKGJlYXJpbmcgKyBNYXRoLmFicyhyZXN0KSkpO1xuICAgICAgICAgICAgICB9fVxuICAgICAgICAgICAgPjwvUm90YXRlUmlnaHRJY29uPlxuICAgICAgICAgIDwvUm90YXRlQnV0dG9uPlxuICAgICAgICAgIDxOZWVkbGVCdXR0b25cbiAgICAgICAgICAgIGNsYXNzTmFtZT17Y3NzKHsgLi4ucHJvcHMubmVlZGxlU3R5bGUgfSl9XG4gICAgICAgICAgICBvbkNsaWNrPXsoKSA9PiB7XG4gICAgICAgICAgICAgIG1hcEhvb2subWFwPy5zZXRCZWFyaW5nKDApO1xuICAgICAgICAgICAgfX1cbiAgICAgICAgICA+XG4gICAgICAgICAgICA8TmVlZGxlQ29udGFpbmVyXG4gICAgICAgICAgICAgIHN0eWxlPXt7XG4gICAgICAgICAgICAgICAgdHJhbnNmb3JtOiBcInJvdGF0ZShcIiArIGJlYXJpbmcgKyBcImRlZylcIixcbiAgICAgICAgICAgICAgfX1cbiAgICAgICAgICAgID5cbiAgICAgICAgICAgICAgPE5lZWRsZUljb24gLz5cbiAgICAgICAgICAgIDwvTmVlZGxlQ29udGFpbmVyPlxuICAgICAgICAgIDwvTmVlZGxlQnV0dG9uPlxuICAgICAgICAgIDxSb3RhdGVCdXR0b24gY2xhc3NOYW1lPXtjc3MoeyAuLi5wcm9wcy5yb3RhdGVMZWZ0U3R5bGUgfSl9PlxuICAgICAgICAgICAgPFJvdGF0ZUxlZnRJY29uXG4gICAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgICBsZXQgYmVhcmluZyA9IE1hdGgucm91bmQobWFwSG9vay5tYXA/LmdldEJlYXJpbmcoKSk7XG4gICAgICAgICAgICAgICAgbGV0IHJlc3QgPSBNYXRoLnJvdW5kKGJlYXJpbmcgJSA5MCk7XG4gICAgICAgICAgICAgICAgaWYgKGJlYXJpbmcgPCAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTAgKyByZXN0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAocmVzdCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgcmVzdCA9IDkwO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBtYXBIb29rLm1hcD8uc2V0QmVhcmluZyhNYXRoLnJvdW5kKGJlYXJpbmcgLSBNYXRoLmFicyhyZXN0KSkpO1xuICAgICAgICAgICAgICB9fVxuICAgICAgICAgICAgPjwvUm90YXRlTGVmdEljb24+XG4gICAgICAgICAgPC9Sb3RhdGVCdXR0b24+XG4gICAgICAgIDwvZGl2PlxuICAgICAgPC9kaXY+XG4gICAgPC8+XG4gICk7XG59O1xuXG5NbE5hdmlnYXRpb25Db21wYXNzLnByb3BUeXBlcyA9IHtcbiAgLyoqXG4gICAqIENvbXBvbmVudCBpZCBwcmVmaXhcbiAgICovXG4gIGlkUHJlZml4OiBQcm9wVHlwZXMuc3RyaW5nLFxuICAvKipcbiAgICogU3R5bGUgb2JqZWN0IHRvIGFkanVzdCBjc3MgZGVmaW5pdGlvbnMgb2YgdGhlIGNvbXBvbmVudC5cbiAgICovXG4gIHN0eWxlOiBQcm9wVHlwZXMub2JqZWN0LFxuICAvKipcbiAgICogU3R5bGUgb2JqZWN0IHRvIGFkanVzdCBjc3MgZGVmaW5pdGlvbnMgb2YgdGhlIGJhY2tncm91bmQuXG4gICAqL1xuICBiYWNrZ3JvdW5kU3R5bGU6IFByb3BUeXBlcy5vYmplY3QsXG4gIC8qKlxuICAgKiBTdHlsZSBvYmplY3QgdG8gYWRqdXN0IGNzcyBkZWZpbml0aW9ucyBvZiB0aGUgY29tcGFzcyBuZWVkbGUuXG4gICAqL1xuICBuZWVkbGVTdHlsZTogUHJvcFR5cGVzLm9iamVjdCxcbiAgLyoqXG4gICAqIFN0eWxlIG9iamVjdCB0byBhZGp1c3QgY3NzIGRlZmluaXRpb25zIG9mIHRoZSByb3RhdGUgcmlnaHQgYnV0dG9uLlxuICAgKi9cbiAgcm90YXRlUmlnaHRTdHlsZTogUHJvcFR5cGVzLm9iamVjdCxcbiAgLyoqXG4gICAqIFN0eWxlIG9iamVjdCB0byBhZGp1c3QgY3NzIGRlZmluaXRpb25zIG9mIHRoZSByb3RhdGUgbGVmdCBidXR0b24uXG4gICAqL1xuICByb3RhdGVMZWZ0U3R5bGU6IFByb3BUeXBlcy5vYmplY3QsXG59O1xuXG5leHBvcnQgZGVmYXVsdCBNbE5hdmlnYXRpb25Db21wYXNzO1xuIl19 */")
|
|
2070
1791
|
}, /*#__PURE__*/React__default.createElement(RotateButton, {
|
|
2071
|
-
className: /*#__PURE__*/css(
|
|
1792
|
+
className: /*#__PURE__*/css({ ...props.rotateRightStyle
|
|
1793
|
+
}, process.env.NODE_ENV === "production" ? "" : ";label:MlNavigationCompass;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIk1sTmF2aWdhdGlvbkNvbXBhc3MuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBbUltQyIsImZpbGUiOiJNbE5hdmlnYXRpb25Db21wYXNzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlYWN0LCB7IHVzZVN0YXRlLCB1c2VFZmZlY3QgfSBmcm9tIFwicmVhY3RcIjtcbmltcG9ydCBQcm9wVHlwZXMgZnJvbSBcInByb3AtdHlwZXNcIjtcblxuaW1wb3J0IHsgUmVhY3RDb21wb25lbnQgYXMgUm90YXRlUmlnaHRJY29uIH0gZnJvbSBcIi4vYXNzZXRzL3JvdGF0ZV9yaWdodC5zdmdcIjtcbmltcG9ydCB7IFJlYWN0Q29tcG9uZW50IGFzIFJvdGF0ZUxlZnRJY29uIH0gZnJvbSBcIi4vYXNzZXRzL3JvdGF0ZV9sZWZ0LnN2Z1wiO1xuaW1wb3J0IHsgUmVhY3RDb21wb25lbnQgYXMgTmVlZGxlSWNvbiB9IGZyb20gXCIuL2Fzc2V0cy9uZWVkbGUuc3ZnXCI7XG5cbmltcG9ydCBzdHlsZWQgZnJvbSBcIkBlbW90aW9uL3N0eWxlZFwiO1xuaW1wb3J0IHsgY3NzIH0gZnJvbSBcIkBlbW90aW9uL2Nzc1wiO1xuaW1wb3J0IHVzZU1hcCBmcm9tIFwiLi4vLi4vaG9va3MvdXNlTWFwXCI7XG5cbmNvbnN0IE5lZWRsZUJ1dHRvbiA9IHN0eWxlZC5kaXZgXG4gIHdpZHRoOiA0MCU7XG4gIGRpc3BsYXk6IGZsZXg7XG4gIGFsaWduLWl0ZW1zOiBjZW50ZXI7XG5cbiAgJjpob3ZlciB7XG4gICAgY3Vyc29yOiBwb2ludGVyO1xuICB9XG4gIHBhdGgge1xuICA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FZmZlY3QoKCkgPT4ge1xuICAgIGlmICghbWFwSG9vay5tYXApIHJldHVybjtcblxuICAgIGxldCBfdXBkYXRlQmVhcmluZyA9ICgpID0+IHtcbiAgICAgIHNldEJlYXJpbmcoTWF0aC5yb3VuZChtYXBIb29rLm1hcC5nZXRCZWFyaW5nKCkpKTtcbiAgICB9O1xuXG4gICAgbWFwSG9vay5tYXAub24oXCJyb3RhdGVcIiwgX3VwZGF0ZUJlYXJpbmcsIG1hcEhvb2suY29tcG9uZW50SWQpO1xuICAgIF91cGRhdGVCZWFyaW5nKCk7XG5cbiAgICByZXR1cm4gKCkgPT4ge1xuICAgICAgbWFwSG9vay5tYXAub2ZmKFwicm90YXRlXCIsIF91cGRhdGVCZWFyaW5nKTtcbiAgICB9O1xuICB9LCBbbWFwSG9vay5tYXAsIHByb3BzLm1hcElkXSk7XG5cbiAgcmV0dXJuIChcbiAgICA8PlxuICAgICAgPGRpdlxuICAgICAgICBjbGFzc05hbWU9e2Nzcyh7XG4gICAgICAgICAgekluZGV4OiAxMDAwLFxuICAgICAgICAgIHRvcDogMCxcbiAgICAgICAgICBwb3NpdGlvbjogXCJhYnNvbHV0ZVwiLFxuICAgICAgICAgIC4uLnByb3BzLnN0eWxlLFxuICAgICAgICB9KX1cbiAgICAgID5cbiAgICAgICAgPGRpdlxuICAgICAgICAgIGNsYXNzTmFtZT17Y3NzKHtcbiAgICAgICAgICAgIHBvc2l0aW9uOiBcImFic29sdXRlXCIsXG4gICAgICAgICAgICBib3JkZXI6IFwiMTBweCBzb2xpZCAjYmNiY2JjXCIsXG4gICAgICAgICAgICBiYWNrZ3JvdW5kQ29sb3I6IFwiIzcxNzE3MVwiLFxuICAgICAgICAgICAgYmFja2dyb3VuZDogXCJyYWRpYWwtZ3JhZGllbnQoIzcxNzE3MSwgIzQxNDE0MSlcIixcbiAgICAgICAgICAgIGhlaWdodDogXCIyMDBweFwiLFxuICAgICAgICAgICAgd2lkdGg6IFwiMjAwcHhcIixcbiAgICAgICAgICAgIGJvcmRlclJhZGl1czogXCI1MCVcIixcbiAgICAgICAgICAgIGRpc3BsYXk6IFwiZmxleFwiLFxuICAgICAgICAgICAganVzdGlmeUNvbnRlbnQ6IFwiY2VudGVyXCIsXG4gICAgICAgICAgICB0cmFuc2Zvcm06IFwic2NhbGUoMC4yKSB0cmFuc2xhdGVYKC00NDhweCkgdHJhbnNsYXRlWSgtNDQ4cHgpXCIsXG4gICAgICAgICAgICAuLi5wcm9wcy5iYWNrZ3JvdW5kU3R5bGUsXG4gICAgICAgICAgfSl9XG4gICAgICAgID5cbiAgICAgICAgICA8Um90YXRlQnV0dG9uIGNsYXNzTmFtZT17Y3NzKHsgLi4ucHJvcHMucm90YXRlUmlnaHRTdHlsZSB9KX0+XG4gICAgICAgICAgICA8Um90YXRlUmlnaHRJY29uXG4gICAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgICBsZXQgYmVhcmluZyA9IE1hdGgucm91bmQobWFwSG9vay5tYXA/LmdldEJlYXJpbmcoKSk7XG4gICAgICAgICAgICAgICAgbGV0IHJlc3QgPSBNYXRoLnJvdW5kKGJlYXJpbmcgJSA5MCk7XG4gICAgICAgICAgICAgICAgaWYgKGJlYXJpbmcgPiAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTAgLSByZXN0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAocmVzdCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgcmVzdCA9IDkwO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBtYXBIb29rLm1hcD8uc2V0QmVhcmluZyhNYXRoLnJvdW5kKGJlYXJpbmcgKyBNYXRoLmFicyhyZXN0KSkpO1xuICAgICAgICAgICAgICB9fVxuICAgICAgICAgICAgPjwvUm90YXRlUmlnaHRJY29uPlxuICAgICAgICAgIDwvUm90YXRlQnV0dG9uPlxuICAgICAgICAgIDxOZWVkbGVCdXR0b25cbiAgICAgICAgICAgIGNsYXNzTmFtZT17Y3NzKHsgLi4ucHJvcHMubmVlZGxlU3R5bGUgfSl9XG4gICAgICAgICAgICBvbkNsaWNrPXsoKSA9PiB7XG4gICAgICAgICAgICAgIG1hcEhvb2subWFwPy5zZXRCZWFyaW5nKDApO1xuICAgICAgICAgICAgfX1cbiAgICAgICAgICA+XG4gICAgICAgICAgICA8TmVlZGxlQ29udGFpbmVyXG4gICAgICAgICAgICAgIHN0eWxlPXt7XG4gICAgICAgICAgICAgICAgdHJhbnNmb3JtOiBcInJvdGF0ZShcIiArIGJlYXJpbmcgKyBcImRlZylcIixcbiAgICAgICAgICAgICAgfX1cbiAgICAgICAgICAgID5cbiAgICAgICAgICAgICAgPE5lZWRsZUljb24gLz5cbiAgICAgICAgICAgIDwvTmVlZGxlQ29udGFpbmVyPlxuICAgICAgICAgIDwvTmVlZGxlQnV0dG9uPlxuICAgICAgICAgIDxSb3RhdGVCdXR0b24gY2xhc3NOYW1lPXtjc3MoeyAuLi5wcm9wcy5yb3RhdGVMZWZ0U3R5bGUgfSl9PlxuICAgICAgICAgICAgPFJvdGF0ZUxlZnRJY29uXG4gICAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgICBsZXQgYmVhcmluZyA9IE1hdGgucm91bmQobWFwSG9vay5tYXA/LmdldEJlYXJpbmcoKSk7XG4gICAgICAgICAgICAgICAgbGV0IHJlc3QgPSBNYXRoLnJvdW5kKGJlYXJpbmcgJSA5MCk7XG4gICAgICAgICAgICAgICAgaWYgKGJlYXJpbmcgPCAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTAgKyByZXN0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAocmVzdCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgcmVzdCA9IDkwO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBtYXBIb29rLm1hcD8uc2V0QmVhcmlu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b3RhdGVMZWZ0U3R5bGU6IFByb3BUeXBlcy5vYmplY3QsXG59O1xuXG5leHBvcnQgZGVmYXVsdCBNbE5hdmlnYXRpb25Db21wYXNzO1xuIl19 */")
|
|
2072
1794
|
}, /*#__PURE__*/React__default.createElement(SvgRotateRight, {
|
|
2073
|
-
onClick:
|
|
1795
|
+
onClick: () => {
|
|
2074
1796
|
var _mapHook$map, _mapHook$map2;
|
|
2075
1797
|
|
|
2076
|
-
|
|
2077
|
-
|
|
1798
|
+
let bearing = Math.round((_mapHook$map = mapHook.map) === null || _mapHook$map === void 0 ? void 0 : _mapHook$map.getBearing());
|
|
1799
|
+
let rest = Math.round(bearing % 90);
|
|
2078
1800
|
|
|
2079
1801
|
if (bearing > 0) {
|
|
2080
1802
|
rest = 90 - rest;
|
|
@@ -2087,8 +1809,9 @@ var MlNavigationCompass = function MlNavigationCompass(props) {
|
|
|
2087
1809
|
(_mapHook$map2 = mapHook.map) === null || _mapHook$map2 === void 0 ? void 0 : _mapHook$map2.setBearing(Math.round(bearing + Math.abs(rest)));
|
|
2088
1810
|
}
|
|
2089
1811
|
})), /*#__PURE__*/React__default.createElement(NeedleButton, {
|
|
2090
|
-
className: /*#__PURE__*/css(
|
|
2091
|
-
|
|
1812
|
+
className: /*#__PURE__*/css({ ...props.needleStyle
|
|
1813
|
+
}, process.env.NODE_ENV === "production" ? "" : ";label:MlNavigationCompass;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIk1sTmF2aWdhdGlvbkNvbXBhc3MuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBbUp1QiIsImZpbGUiOiJNbE5hdmlnYXRpb25Db21wYXNzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlYWN0LCB7IHVzZVN0YXRlLCB1c2VFZmZlY3QgfSBmcm9tIFwicmVhY3RcIjtcbmltcG9ydCBQcm9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1xuICAgICAgbWFwSG9vay5tYXAub2ZmKFwicm90YXRlXCIsIF91cGRhdGVCZWFyaW5nKTtcbiAgICB9O1xuICB9LCBbbWFwSG9vay5tYXAsIHByb3BzLm1hcElkXSk7XG5cbiAgcmV0dXJuIChcbiAgICA8PlxuICAgICAgPGRpdlxuICAgICAgICBjbGFzc05hbWU9e2Nzcyh7XG4gICAgICAgICAgekluZGV4OiAxMDAwLFxuICAgICAgICAgIHRvcDogMCxcbiAgICAgICAgICBwb3NpdGlvbjogXCJhYnNvbHV0ZVwiLFxuICAgICAgICAgIC4uLnByb3BzLnN0eWxlLFxuICAgICAgICB9KX1cbiAgICAgID5cbiAgICAgICAgPGRpdlxuICAgICAgICAgIGNsYXNzTmFtZT17Y3NzKHtcbiAgICAgICAgICAgIHBvc2l0aW9uOiBcImFic29sdXRlXCIsXG4gICAgICAgICAgICBib3JkZXI6IFwiMTBweCBzb2xpZCAjYmNiY2JjXCIsXG4gICAgICAgICAgICBiYWNrZ3JvdW5kQ29sb3I6IFwiIzcxNzE3MVwiLFxuICAgICAgICAgICAgYmFja2dyb3VuZDogXCJyYWRpYWwtZ3JhZGllbnQoIzcxNzE3MSwgIzQxNDE0MSlcIixcbiAgICAgICAgICAgIGhlaWdodDogXCIyMDBweFwiLFxuICAgICAgICAgICAgd2lkdGg6IFwiMjAwcHhcIixcbiAgICAgICAgICAgIGJvcmRlclJhZGl1czogXCI1MCVcIixcbiAgICAgICAgICAgIGRpc3BsYXk6IFwiZmxleFwiLFxuICAgICAgICAgICAganVzdGlmeUNvbnRlbnQ6IFwiY2VudGVyXCIsXG4gICAgICAgICAgICB0cmFuc2Zvcm06IFwic2NhbGUoMC4yKSB0cmFuc2xhdGVYKC00NDhweCkgdHJhbnNsYXRlWSgtNDQ4cHgpXCIsXG4gICAgICAgICAgICAuLi5wcm9wcy5iYWNrZ3JvdW5kU3R5bGUsXG4gICAgICAgICAgfSl9XG4gICAgICAgID5cbiAgICAgICAgICA8Um90YXRlQnV0dG9uIGNsYXNzTmFtZT17Y3NzKHsgLi4ucHJvcHMucm90YXRlUmlnaHRTdHlsZSB9KX0+XG4gICAgICAgICAgICA8Um90YXRlUmlnaHRJY29uXG4gICAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgICBsZXQgYmVhcmluZyA9IE1hdGgucm91bmQobWFwSG9vay5tYXA/LmdldEJlYXJpbmcoKSk7XG4gICAgICAgICAgICAgICAgbGV0IHJlc3QgPSBNYXRoLnJvdW5kKGJlYXJpbmcgJSA5MCk7XG4gICAgICAgICAgICAgICAgaWYgKGJlYXJpbmcgPiAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTAgLSByZXN0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAocmVzdCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgcmVzdCA9IDkwO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBtYXBIb29rLm1hcD8uc2V0QmVhcmluZyhNYXRoLnJvdW5kKGJlYXJpbmcgKyBNYXRoLmFicyhyZXN0KSkpO1xuICAgICAgICAgICAgICB9fVxuICAgICAgICAgICAgPjwvUm90YXRlUmlnaHRJY29uPlxuICAgICAgICAgIDwvUm90YXRlQnV0dG9uPlxuICAgICAgICAgIDxOZWVkbGVCdXR0b25cbiAgICAgICAgICAgIGNsYXNzTmFtZT17Y3NzKHsgLi4ucHJvcHMubmVlZGxlU3R5bGUgfSl9XG4gICAgICAgICAgICBvbkNsaWNrPXsoKSA9PiB7XG4gICAgICAgICAgICAgIG1hcEhvb2subWFwPy5zZXRCZWFyaW5nKDApO1xuICAgICAgICAgICAgfX1cbiAgICAgICAgICA+XG4gICAgICAgICAgICA8TmVlZGxlQ29udGFpbmVyXG4gICAgICAgICAgICAgIHN0eWxlPXt7XG4gICAgICAgICAgICAgICAgdHJhbnNmb3JtOiBcInJvdGF0ZShcIiArIGJlYXJpbmcgKyBcImRlZylcIixcbiAgICAgICAgICAgICAgfX1cbiAgICAgICAgICAgID5cbiAgICAgICAgICAgICAgPE5lZWRsZUljb24gLz5cbiAgICAgICAgICAgIDwvTmVlZGxlQ29udGFpbmVyPlxuICAgICAgICAgIDwvTmVlZGxlQnV0dG9uPlxuICAgICAgICAgIDxSb3RhdGVCdXR0b24gY2xhc3NOYW1lPXtjc3MoeyAuLi5wcm9wcy5yb3RhdGVMZWZ0U3R5bGUgfSl9PlxuICAgICAgICAgICAgPFJvdGF0ZUxlZnRJY29uXG4gICAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgICBsZXQgYmVhcmluZyA9IE1hdGgucm91bmQobWFwSG9vay5tYXA/LmdldEJlYXJpbmcoKSk7XG4gICAgICAgICAgICAgICAgbGV0IHJlc3QgPSBNYXRoLnJvdW5kKGJlYXJpbmcgJSA5MCk7XG4gICAgICAgICAgICAgICAgaWYgKGJlYXJpbmcgPCAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTAgKyByZXN0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAocmVzdCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgcmVzdCA9IDkwO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBtYXBIb29rLm1hcD8uc2V0QmVhcmluZyhNYXRoLnJvdW5kKGJlYXJpbmcgLSBNYXRoLmFicyhyZXN0KSkpO1xuICAgICAgICAgICAgICB9fVxuICAgICAgICAgICAgPjwvUm90YXRlTGVmdEljb24+XG4gICAgICAgICAgPC9Sb3RhdGVCdXR0b24+XG4gICAgICAgIDwvZGl2PlxuICAgICAgPC9kaXY+XG4gICAgPC8+XG4gICk7XG59O1xuXG5NbE5hdmlnYXRpb25Db21wYXNzLnByb3BUeXBlcyA9IHtcbiAgLyoqXG4gICAqIENvbXBvbmVudCBpZCBwcmVmaXhcbiAgICovXG4gIGlkUHJlZml4OiBQcm9wVHlwZXMuc3RyaW5nLFxuICAvKipcbiAgICogU3R5bGUgb2JqZWN0IHRvIGFkanVzdCBjc3MgZGVmaW5pdGlvbnMgb2YgdGhlIGNvbXBvbmVudC5cbiAgICovXG4gIHN0eWxlOiBQcm9wVHlwZXMub2JqZWN0LFxuICAvKipcbiAgICogU3R5bGUgb2JqZWN0IHRvIGFkanVzdCBjc3MgZGVmaW5pdGlvbnMgb2YgdGhlIGJhY2tncm91bmQuXG4gICAqL1xuICBiYWNrZ3JvdW5kU3R5bGU6IFByb3BUeXBlcy5vYmplY3QsXG4gIC8qKlxuICAgKiBTdHlsZSBvYmplY3QgdG8gYWRqdXN0IGNzcyBkZWZpbml0aW9ucyBvZiB0aGUgY29tcGFzcyBuZWVkbGUuXG4gICAqL1xuICBuZWVkbGVTdHlsZTogUHJvcFR5cGVzLm9iamVjdCxcbiAgLyoqXG4gICAqIFN0eWxlIG9iamVjdCB0byBhZGp1c3QgY3NzIGRlZmluaXRpb25zIG9mIHRoZSByb3RhdGUgcmlnaHQgYnV0dG9uLlxuICAgKi9cbiAgcm90YXRlUmlnaHRTdHlsZTogUHJvcFR5cGVzLm9iamVjdCxcbiAgLyoqXG4gICAqIFN0eWxlIG9iamVjdCB0byBhZGp1c3QgY3NzIGRlZmluaXRpb25zIG9mIHRoZSByb3RhdGUgbGVmdCBidXR0b24uXG4gICAqL1xuICByb3RhdGVMZWZ0U3R5bGU6IFByb3BUeXBlcy5vYmplY3QsXG59O1xuXG5leHBvcnQgZGVmYXVsdCBNbE5hdmlnYXRpb25Db21wYXNzO1xuIl19 */"),
|
|
1814
|
+
onClick: () => {
|
|
2092
1815
|
var _mapHook$map3;
|
|
2093
1816
|
|
|
2094
1817
|
(_mapHook$map3 = mapHook.map) === null || _mapHook$map3 === void 0 ? void 0 : _mapHook$map3.setBearing(0);
|
|
@@ -2098,13 +1821,14 @@ var MlNavigationCompass = function MlNavigationCompass(props) {
|
|
|
2098
1821
|
transform: "rotate(" + bearing + "deg)"
|
|
2099
1822
|
}
|
|
2100
1823
|
}, /*#__PURE__*/React__default.createElement(SvgNeedle, null))), /*#__PURE__*/React__default.createElement(RotateButton, {
|
|
2101
|
-
className: /*#__PURE__*/css(
|
|
1824
|
+
className: /*#__PURE__*/css({ ...props.rotateLeftStyle
|
|
1825
|
+
}, process.env.NODE_ENV === "production" ? "" : ";label:MlNavigationCompass;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIk1sTmF2aWdhdGlvbkNvbXBhc3MuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBZ0ttQyIsImZpbGUiOiJNbE5hdmlnYXRpb25Db21wYXNzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlYWN0LCB7IHVzZVN0YXRlLCB1c2VFZmZlY3QgfSBmcm9tIFwicmVhY3RcIjtcbmltcG9ydCBQcm9wVHlwZXMgZnJvbSBcInByb3AtdHlwZXNcIjtcblxuaW1wb3J0IHsgUmVhY3RDb21wb25lbnQgYXMgUm90YXRlUmlnaHRJY29uIH0gZnJvbSBcIi4vYXNzZXRzL3JvdGF0ZV9yaWdodC5zdmdcIjtcbmltcG9ydCB7IFJlYWN0Q29tcG9uZW50IGFzIFJvdGF0ZUxlZnRJY29uIH0gZnJvbSBcIi4vYXNzZXRzL3JvdGF0ZV9sZWZ0LnN2Z1wiO1xuaW1wb3J0IHsgUmVhY3RDb21wb25lbnQgYXMgTmVlZGxlSWNvbiB9IGZyb20gXCIuL2Fzc2V0cy9uZWVkbGUuc3ZnXCI7XG5cbmltcG9ydCBzdHlsZWQgZnJvbSBcIkBlbW90aW9uL3N0eWxlZFwiO1xuaW1wb3J0IHsgY3NzIH0gZnJvbSBcIkBlbW90aW9uL2Nzc1wiO1xuaW1wb3J0IHVzZU1hcCBmcm9tIFwiLi4vLi4vaG9va3MvdXNlTWFwXCI7XG5cbmNvbnN0IE5lZWRsZUJ1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NzE3MVwiLFxuICAgICAgICAgICAgYmFja2dyb3VuZDogXCJyYWRpYWwtZ3JhZGllbnQoIzcxNzE3MSwgIzQxNDE0MSlcIixcbiAgICAgICAgICAgIGhlaWdodDogXCIyMDBweFwiLFxuICAgICAgICAgICAgd2lkdGg6IFwiMjAwcHhcIixcbiAgICAgICAgICAgIGJvcmRlclJhZGl1czogXCI1MCVcIixcbiAgICAgICAgICAgIGRpc3BsYXk6IFwiZmxleFwiLFxuICAgICAgICAgICAganVzdGlmeUNvbnRlbnQ6IFwiY2VudGVyXCIsXG4gICAgICAgICAgICB0cmFuc2Zvcm06IFwic2NhbGUoMC4yKSB0cmFuc2xhdGVYKC00NDhweCkgdHJhbnNsYXRlWSgtNDQ4cHgpXCIsXG4gICAgICAgICAgICAuLi5wcm9wcy5iYWNrZ3JvdW5kU3R5bGUsXG4gICAgICAgICAgfSl9XG4gICAgICAgID5cbiAgICAgICAgICA8Um90YXRlQnV0dG9uIGNsYXNzTmFtZT17Y3NzKHsgLi4ucHJvcHMucm90YXRlUmlnaHRTdHlsZSB9KX0+XG4gICAgICAgICAgICA8Um90YXRlUmlnaHRJY29uXG4gICAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgICBsZXQgYmVhcmluZyA9IE1hdGgucm91bmQobWFwSG9vay5tYXA/LmdldEJlYXJpbmcoKSk7XG4gICAgICAgICAgICAgICAgbGV0IHJlc3QgPSBNYXRoLnJvdW5kKGJlYXJpbmcgJSA5MCk7XG4gICAgICAgICAgICAgICAgaWYgKGJlYXJpbmcgPiAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTAgLSByZXN0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAocmVzdCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgcmVzdCA9IDkwO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBtYXBIb29rLm1hcD8uc2V0QmVhcmluZyhNYXRoLnJvdW5kKGJlYXJpbmcgKyBNYXRoLmFicyhyZXN0KSkpO1xuICAgICAgICAgICAgICB9fVxuICAgICAgICAgICAgPjwvUm90YXRlUmlnaHRJY29uPlxuICAgICAgICAgIDwvUm90YXRlQnV0dG9uPlxuICAgICAgICAgIDxOZWVkbGVCdXR0b25cbiAgICAgICAgICAgIGNsYXNzTmFtZT17Y3NzKHsgLi4ucHJvcHMubmVlZGxlU3R5bGUgfSl9XG4gICAgICAgICAgICBvbkNsaWNrPXsoKSA9PiB7XG4gICAgICAgICAgICAgIG1hcEhvb2subWFwPy5zZXRCZWFyaW5nKDApO1xuICAgICAgICAgICAgfX1cbiAgICAgICAgICA+XG4gICAgICAgICAgICA8TmVlZGxlQ29udGFpbmVyXG4gICAgICAgICAgICAgIHN0eWxlPXt7XG4gICAgICAgICAgICAgICAgdHJhbnNmb3JtOiBcInJvdGF0ZShcIiArIGJlYXJpbmcgKyBcImRlZylcIixcbiAgICAgICAgICAgICAgfX1cbiAgICAgICAgICAgID5cbiAgICAgICAgICAgICAgPE5lZWRsZUljb24gLz5cbiAgICAgICAgICAgIDwvTmVlZGxlQ29udGFpbmVyPlxuICAgICAgICAgIDwvTmVlZGxlQnV0dG9uPlxuICAgICAgICAgIDxSb3RhdGVCdXR0b24gY2xhc3NOYW1lPXtjc3MoeyAuLi5wcm9wcy5yb3RhdGVMZWZ0U3R5bGUgfSl9PlxuICAgICAgICAgICAgPFJvdGF0ZUxlZnRJY29uXG4gICAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgICBsZXQgYmVhcmluZyA9IE1hdGgucm91bmQobWFwSG9vay5tYXA/LmdldEJlYXJpbmcoKSk7XG4gICAgICAgICAgICAgICAgbGV0IHJlc3QgPSBNYXRoLnJvdW5kKGJlYXJpbmcgJSA5MCk7XG4gICAgICAgICAgICAgICAgaWYgKGJlYXJpbmcgPCAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTAg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LlxuICAgKi9cbiAgcm90YXRlUmlnaHRTdHlsZTogUHJvcFR5cGVzLm9iamVjdCxcbiAgLyoqXG4gICAqIFN0eWxlIG9iamVjdCB0byBhZGp1c3QgY3NzIGRlZmluaXRpb25zIG9mIHRoZSByb3RhdGUgbGVmdCBidXR0b24uXG4gICAqL1xuICByb3RhdGVMZWZ0U3R5bGU6IFByb3BUeXBlcy5vYmplY3QsXG59O1xuXG5leHBvcnQgZGVmYXVsdCBNbE5hdmlnYXRpb25Db21wYXNzO1xuIl19 */")
|
|
2102
1826
|
}, /*#__PURE__*/React__default.createElement(SvgRotateLeft, {
|
|
2103
|
-
onClick:
|
|
1827
|
+
onClick: () => {
|
|
2104
1828
|
var _mapHook$map4, _mapHook$map5;
|
|
2105
1829
|
|
|
2106
|
-
|
|
2107
|
-
|
|
1830
|
+
let bearing = Math.round((_mapHook$map4 = mapHook.map) === null || _mapHook$map4 === void 0 ? void 0 : _mapHook$map4.getBearing());
|
|
1831
|
+
let rest = Math.round(bearing % 90);
|
|
2108
1832
|
|
|
2109
1833
|
if (bearing < 0) {
|
|
2110
1834
|
rest = 90 + rest;
|
|
@@ -2151,26 +1875,15 @@ MlNavigationCompass.propTypes = {
|
|
|
2151
1875
|
rotateLeftStyle: PropTypes.object
|
|
2152
1876
|
};
|
|
2153
1877
|
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
var MlNavigationTools = function MlNavigationTools(props) {
|
|
2157
|
-
var mapHook = useMap({
|
|
1878
|
+
const MlNavigationTools = props => {
|
|
1879
|
+
const mapHook = useMap({
|
|
2158
1880
|
mapId: props.mapId,
|
|
2159
1881
|
waitForLayer: props.insertBeforeLayer
|
|
2160
1882
|
});
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
setPitch = _useState2[1];
|
|
2166
|
-
|
|
2167
|
-
var _useState3 = useState(false),
|
|
2168
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
2169
|
-
locationAccessDenied = _useState4[0],
|
|
2170
|
-
setLocationAccessDenied = _useState4[1];
|
|
2171
|
-
|
|
2172
|
-
var mediaIsMobile = useMediaQuery("(max-width:900px)");
|
|
2173
|
-
var buttonStyle = {
|
|
1883
|
+
const [pitch, setPitch] = useState(0);
|
|
1884
|
+
const [locationAccessDenied, setLocationAccessDenied] = useState(false);
|
|
1885
|
+
const mediaIsMobile = useMediaQuery("(max-width:900px)");
|
|
1886
|
+
const buttonStyle = {
|
|
2174
1887
|
minWidth: "20px",
|
|
2175
1888
|
minHeight: "20px",
|
|
2176
1889
|
width: mediaIsMobile ? "50px" : "30px",
|
|
@@ -2186,15 +1899,15 @@ var MlNavigationTools = function MlNavigationTools(props) {
|
|
|
2186
1899
|
},
|
|
2187
1900
|
color: "#ececec"
|
|
2188
1901
|
};
|
|
2189
|
-
useEffect(
|
|
1902
|
+
useEffect(() => {
|
|
2190
1903
|
if (!mapHook.map) return;
|
|
2191
|
-
mapHook.map.on("pitchend",
|
|
1904
|
+
mapHook.map.on("pitchend", () => {
|
|
2192
1905
|
setPitch(mapHook.map.getPitch());
|
|
2193
1906
|
});
|
|
2194
1907
|
setPitch(mapHook.map.getPitch());
|
|
2195
1908
|
}, [mapHook.map, props.mapId]);
|
|
2196
1909
|
|
|
2197
|
-
|
|
1910
|
+
const zoomIn = () => {
|
|
2198
1911
|
if (!mapHook.map) return;
|
|
2199
1912
|
|
|
2200
1913
|
if (mapHook.map.transform._zoom + 0.5 <= mapHook.map.transform._maxZoom) {
|
|
@@ -2204,7 +1917,7 @@ var MlNavigationTools = function MlNavigationTools(props) {
|
|
|
2204
1917
|
}
|
|
2205
1918
|
};
|
|
2206
1919
|
|
|
2207
|
-
|
|
1920
|
+
const zoomOut = () => {
|
|
2208
1921
|
if (!mapHook.map) return;
|
|
2209
1922
|
|
|
2210
1923
|
if (mapHook.map.transform._zoom - 0.5 >= mapHook.map.transform._minZoom) {
|
|
@@ -2214,9 +1927,9 @@ var MlNavigationTools = function MlNavigationTools(props) {
|
|
|
2214
1927
|
}
|
|
2215
1928
|
};
|
|
2216
1929
|
|
|
2217
|
-
|
|
1930
|
+
const adjustPitch = () => {
|
|
2218
1931
|
if (!mapHook.map) return;
|
|
2219
|
-
|
|
1932
|
+
let targetPitch = 60;
|
|
2220
1933
|
|
|
2221
1934
|
if (mapHook.map.getPitch() !== 0) {
|
|
2222
1935
|
targetPitch = 0;
|
|
@@ -2227,15 +1940,15 @@ var MlNavigationTools = function MlNavigationTools(props) {
|
|
|
2227
1940
|
});
|
|
2228
1941
|
};
|
|
2229
1942
|
|
|
2230
|
-
|
|
1943
|
+
const moveToCurrentLocation = () => {
|
|
2231
1944
|
navigator.geolocation.getCurrentPosition(getLocationSuccess, getLocationError);
|
|
2232
1945
|
};
|
|
2233
1946
|
|
|
2234
|
-
|
|
1947
|
+
const getLocationSuccess = location => {
|
|
2235
1948
|
mapHook.map.setCenter([location.coords.longitude, location.coords.latitude]);
|
|
2236
1949
|
};
|
|
2237
1950
|
|
|
2238
|
-
|
|
1951
|
+
const getLocationError = () => {
|
|
2239
1952
|
console.log("Access of user location denied");
|
|
2240
1953
|
setLocationAccessDenied(true);
|
|
2241
1954
|
};
|
|
@@ -2261,9 +1974,9 @@ var MlNavigationTools = function MlNavigationTools(props) {
|
|
|
2261
1974
|
boxShadow: "0px 0px 18px rgba(0,0,0,.5)"
|
|
2262
1975
|
}
|
|
2263
1976
|
}), /*#__PURE__*/React__default.createElement(Button, {
|
|
2264
|
-
sx:
|
|
1977
|
+
sx: { ...buttonStyle,
|
|
2265
1978
|
fontWeight: 600
|
|
2266
|
-
}
|
|
1979
|
+
},
|
|
2267
1980
|
onClick: adjustPitch
|
|
2268
1981
|
}, pitch ? "2D" : "3D"), /*#__PURE__*/React__default.createElement(Button, {
|
|
2269
1982
|
sx: buttonStyle,
|
|
@@ -2274,12 +1987,14 @@ var MlNavigationTools = function MlNavigationTools(props) {
|
|
|
2274
1987
|
fontSize: mediaIsMobile ? "1.5em" : "1.2em"
|
|
2275
1988
|
}
|
|
2276
1989
|
})), /*#__PURE__*/React__default.createElement(MlFollowGps, {
|
|
2277
|
-
style:
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
1990
|
+
style: { ...(_ref => {
|
|
1991
|
+
let {
|
|
1992
|
+
color,
|
|
1993
|
+
...rest
|
|
1994
|
+
} = _ref;
|
|
1995
|
+
return rest;
|
|
1996
|
+
})(buttonStyle)
|
|
1997
|
+
}
|
|
2283
1998
|
}), /*#__PURE__*/React__default.createElement(ButtonGroup, {
|
|
2284
1999
|
orientation: "vertical",
|
|
2285
2000
|
sx: {
|
|
@@ -2295,18 +2010,18 @@ var MlNavigationTools = function MlNavigationTools(props) {
|
|
|
2295
2010
|
}
|
|
2296
2011
|
}
|
|
2297
2012
|
}, /*#__PURE__*/React__default.createElement(Button, {
|
|
2298
|
-
sx:
|
|
2013
|
+
sx: { ...buttonStyle,
|
|
2299
2014
|
color: "#ececec"
|
|
2300
|
-
}
|
|
2015
|
+
},
|
|
2301
2016
|
onClick: zoomIn
|
|
2302
2017
|
}, /*#__PURE__*/React__default.createElement(ControlPointIcon, {
|
|
2303
2018
|
sx: {
|
|
2304
2019
|
fontSize: mediaIsMobile ? "1.5em" : "1.2em"
|
|
2305
2020
|
}
|
|
2306
2021
|
})), /*#__PURE__*/React__default.createElement(Button, {
|
|
2307
|
-
sx:
|
|
2022
|
+
sx: { ...buttonStyle,
|
|
2308
2023
|
color: "#ececec"
|
|
2309
|
-
}
|
|
2024
|
+
},
|
|
2310
2025
|
onClick: zoomOut
|
|
2311
2026
|
}, /*#__PURE__*/React__default.createElement(RemoveCircleOutlineIcon, {
|
|
2312
2027
|
sx: {
|
|
@@ -2315,10 +2030,10 @@ var MlNavigationTools = function MlNavigationTools(props) {
|
|
|
2315
2030
|
}))));
|
|
2316
2031
|
};
|
|
2317
2032
|
|
|
2318
|
-
|
|
2033
|
+
const MlLayer = props => {
|
|
2319
2034
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
2320
|
-
|
|
2321
|
-
|
|
2035
|
+
const mapContext = useContext(MapContext);
|
|
2036
|
+
const mapState = useMapState({
|
|
2322
2037
|
mapId: props.mapId,
|
|
2323
2038
|
watch: {
|
|
2324
2039
|
viewport: false,
|
|
@@ -2326,29 +2041,29 @@ var MlLayer = function MlLayer(props) {
|
|
|
2326
2041
|
sources: false
|
|
2327
2042
|
}
|
|
2328
2043
|
});
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
useEffect(
|
|
2336
|
-
|
|
2337
|
-
return
|
|
2044
|
+
const layerInitializedRef = useRef(false);
|
|
2045
|
+
const mapRef = useRef(null);
|
|
2046
|
+
const componentId = useRef((props.layerId ? props.layerId : "MlLayer-") + v4());
|
|
2047
|
+
const layerId = useRef(props.layerId || componentId.current);
|
|
2048
|
+
const layerPaintConfRef = useRef(undefined);
|
|
2049
|
+
const layerLayoutConfRef = useRef(undefined);
|
|
2050
|
+
useEffect(() => {
|
|
2051
|
+
let _componentId = componentId.current;
|
|
2052
|
+
return () => {
|
|
2338
2053
|
if (mapRef.current) {
|
|
2339
2054
|
mapRef.current.cleanup(_componentId);
|
|
2340
2055
|
mapRef.current = null;
|
|
2341
2056
|
}
|
|
2342
2057
|
};
|
|
2343
2058
|
}, []);
|
|
2344
|
-
useEffect(
|
|
2059
|
+
useEffect(() => {
|
|
2345
2060
|
var _mapContext$getMap, _mapContext$getMap$ge;
|
|
2346
2061
|
|
|
2347
2062
|
if (!mapContext.mapExists(props.mapId) || !((_mapContext$getMap = mapContext.getMap(props.mapId)) !== null && _mapContext$getMap !== void 0 && (_mapContext$getMap$ge = _mapContext$getMap.getLayer) !== null && _mapContext$getMap$ge !== void 0 && _mapContext$getMap$ge.call(_mapContext$getMap, layerId)) || !layerInitializedRef.current || !props.options) return; // the MapLibre-gl instance (mapContext.map) is accessible here
|
|
2348
2063
|
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
2349
2064
|
|
|
2350
2065
|
var key;
|
|
2351
|
-
|
|
2066
|
+
let layoutString = JSON.stringify(props.options.layout);
|
|
2352
2067
|
|
|
2353
2068
|
if (props.options.layout && layoutString !== layerLayoutConfRef.current) {
|
|
2354
2069
|
for (key in props.options.layout) {
|
|
@@ -2358,7 +2073,7 @@ var MlLayer = function MlLayer(props) {
|
|
|
2358
2073
|
layerLayoutConfRef.current = layoutString;
|
|
2359
2074
|
}
|
|
2360
2075
|
|
|
2361
|
-
|
|
2076
|
+
let paintString = JSON.stringify(props.options.paint);
|
|
2362
2077
|
|
|
2363
2078
|
if (props.options.paint && paintString === layerPaintConfRef.current) {
|
|
2364
2079
|
for (key in props.options.paint) {
|
|
@@ -2366,7 +2081,7 @@ var MlLayer = function MlLayer(props) {
|
|
|
2366
2081
|
}
|
|
2367
2082
|
}
|
|
2368
2083
|
}, [props.options, layerId, mapContext, props]);
|
|
2369
|
-
useEffect(
|
|
2084
|
+
useEffect(() => {
|
|
2370
2085
|
if (!mapContext.mapExists(props.mapId) || layerInitializedRef.current) return; // the MapLibre-gl instance (mapContext.map) is accessible here
|
|
2371
2086
|
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
2372
2087
|
//check if insertBeforeLayer exists
|
|
@@ -2374,8 +2089,8 @@ var MlLayer = function MlLayer(props) {
|
|
|
2374
2089
|
if (props.insertBeforeLayer) {
|
|
2375
2090
|
var _mapState$layers;
|
|
2376
2091
|
|
|
2377
|
-
|
|
2378
|
-
mapState === null || mapState === void 0 ? void 0 : (_mapState$layers = mapState.layers) === null || _mapState$layers === void 0 ? void 0 : _mapState$layers.forEach(
|
|
2092
|
+
let layerFound = false;
|
|
2093
|
+
mapState === null || mapState === void 0 ? void 0 : (_mapState$layers = mapState.layers) === null || _mapState$layers === void 0 ? void 0 : _mapState$layers.forEach(layer => {
|
|
2379
2094
|
if (layer.id === props.insertBeforeLayer) {
|
|
2380
2095
|
layerFound = true;
|
|
2381
2096
|
}
|
|
@@ -2392,13 +2107,14 @@ var MlLayer = function MlLayer(props) {
|
|
|
2392
2107
|
var _props$options, _props$options2;
|
|
2393
2108
|
|
|
2394
2109
|
layerInitializedRef.current = true;
|
|
2395
|
-
mapRef.current.addLayer(
|
|
2110
|
+
mapRef.current.addLayer({
|
|
2396
2111
|
id: layerId.current,
|
|
2397
2112
|
type: "background",
|
|
2398
2113
|
paint: {
|
|
2399
2114
|
"background-color": "rgba(0,0,0,0)"
|
|
2400
|
-
}
|
|
2401
|
-
|
|
2115
|
+
},
|
|
2116
|
+
...props.options
|
|
2117
|
+
}, props.insertBeforeLayer, componentId.current);
|
|
2402
2118
|
layerPaintConfRef.current = JSON.stringify((_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.paint);
|
|
2403
2119
|
layerLayoutConfRef.current = JSON.stringify((_props$options2 = props.options) === null || _props$options2 === void 0 ? void 0 : _props$options2.layout);
|
|
2404
2120
|
}
|
|
@@ -2413,25 +2129,27 @@ var MlLayer = function MlLayer(props) {
|
|
|
2413
2129
|
* @component
|
|
2414
2130
|
*/
|
|
2415
2131
|
|
|
2416
|
-
|
|
2417
|
-
|
|
2132
|
+
const MlOsmLayer = props => {
|
|
2133
|
+
const mapHook = useMap({
|
|
2418
2134
|
mapId: props.mapId,
|
|
2419
2135
|
waitForLayer: props.insertBeforeLayer
|
|
2420
2136
|
});
|
|
2421
|
-
|
|
2422
|
-
useEffect(
|
|
2137
|
+
const layerId = useRef(props.layerId || "MlOsmLayer-" + mapHook.componentId);
|
|
2138
|
+
useEffect(() => {
|
|
2423
2139
|
if (!mapHook.map) return;
|
|
2424
|
-
mapHook.map.addSource(layerId.current,
|
|
2140
|
+
mapHook.map.addSource(layerId.current, {
|
|
2425
2141
|
type: "raster",
|
|
2426
|
-
tileSize: 256
|
|
2427
|
-
|
|
2428
|
-
mapHook.
|
|
2142
|
+
tileSize: 256,
|
|
2143
|
+
...props.sourceOptions
|
|
2144
|
+
}, mapHook.componentId);
|
|
2145
|
+
mapHook.map.addLayer({
|
|
2429
2146
|
id: layerId.current,
|
|
2430
2147
|
type: "raster",
|
|
2431
2148
|
source: layerId.current,
|
|
2432
2149
|
minzoom: 0,
|
|
2433
|
-
maxzoom: 22
|
|
2434
|
-
|
|
2150
|
+
maxzoom: 22,
|
|
2151
|
+
...props.layerOptions
|
|
2152
|
+
}, props.insertBeforeLayer, mapHook.componentId);
|
|
2435
2153
|
}, [props, mapHook.map]);
|
|
2436
2154
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
|
|
2437
2155
|
};
|
|
@@ -2472,32 +2190,33 @@ MlOsmLayer.propTypes = {
|
|
|
2472
2190
|
* @component
|
|
2473
2191
|
*/
|
|
2474
2192
|
|
|
2475
|
-
|
|
2476
|
-
|
|
2193
|
+
const MlVectorTileLayer = props => {
|
|
2194
|
+
const mapHook = useMap({
|
|
2477
2195
|
mapId: props.mapId,
|
|
2478
2196
|
waitForLayer: props.insertBeforeLayer
|
|
2479
2197
|
});
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
useEffect(
|
|
2198
|
+
const layerIdsRef = useRef({});
|
|
2199
|
+
const layerId = useRef(props.layerId || "MlVectorTileLayer-" + mapHook.componentId);
|
|
2200
|
+
const layerPaintConfsRef = useRef({});
|
|
2201
|
+
const layerLayoutConfsRef = useRef({});
|
|
2202
|
+
const initializedRef = useRef(false);
|
|
2203
|
+
useEffect(() => {
|
|
2486
2204
|
if (!mapHook.map || initializedRef.current) return;
|
|
2487
2205
|
initializedRef.current = true; // Add the new layer to the openlayers instance once it is available
|
|
2488
2206
|
|
|
2489
|
-
mapHook.map.addSource(layerId.current,
|
|
2207
|
+
mapHook.map.addSource(layerId.current, {
|
|
2490
2208
|
type: "vector",
|
|
2491
2209
|
tiles: [props.url],
|
|
2492
2210
|
tileSize: 512,
|
|
2493
|
-
attribution: ""
|
|
2494
|
-
|
|
2211
|
+
attribution: "",
|
|
2212
|
+
...props.sourceOptions
|
|
2213
|
+
}, mapHook.componentId);
|
|
2495
2214
|
|
|
2496
|
-
for (
|
|
2497
|
-
|
|
2215
|
+
for (let key in props.layers) {
|
|
2216
|
+
let _layerId = layerId.current + "_" + key;
|
|
2498
2217
|
|
|
2499
2218
|
layerIdsRef.current[key] = _layerId;
|
|
2500
|
-
mapHook.map.addLayer(
|
|
2219
|
+
mapHook.map.addLayer({
|
|
2501
2220
|
id: _layerId,
|
|
2502
2221
|
source: layerId.current,
|
|
2503
2222
|
type: "line",
|
|
@@ -2508,32 +2227,33 @@ var MlVectorTileLayer = function MlVectorTileLayer(props) {
|
|
|
2508
2227
|
"line-opacity": 0.5,
|
|
2509
2228
|
"line-color": "rgb(80, 80, 80)",
|
|
2510
2229
|
"line-width": 2
|
|
2511
|
-
}
|
|
2512
|
-
|
|
2230
|
+
},
|
|
2231
|
+
...props.layers[key]
|
|
2232
|
+
}, props.insertBeforeLayer, mapHook.componentId);
|
|
2513
2233
|
layerPaintConfsRef.current[key] = JSON.stringify(props.layers[key].paint);
|
|
2514
2234
|
layerLayoutConfsRef.current[key] = JSON.stringify(props.layers[key].layout);
|
|
2515
2235
|
}
|
|
2516
2236
|
}, [mapHook.map, props]);
|
|
2517
|
-
useEffect(
|
|
2237
|
+
useEffect(() => {
|
|
2518
2238
|
if (!mapHook.map || !initializedRef.current) return; // initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
2519
2239
|
|
|
2520
2240
|
for (var key in props.layers) {
|
|
2521
2241
|
if (mapHook.map.getLayer(layerIdsRef.current[key])) {
|
|
2522
2242
|
// update changed paint property
|
|
2523
|
-
|
|
2243
|
+
let layerPaintConfString = JSON.stringify(props.layers[key].paint);
|
|
2524
2244
|
|
|
2525
2245
|
if (layerPaintConfString !== layerPaintConfsRef.current[key]) {
|
|
2526
|
-
for (
|
|
2246
|
+
for (let paintKey in props.layers[key].paint) {
|
|
2527
2247
|
mapHook.map.setPaintProperty(layerIdsRef.current[key], paintKey, props.layers[key].paint[paintKey]);
|
|
2528
2248
|
}
|
|
2529
2249
|
}
|
|
2530
2250
|
|
|
2531
2251
|
layerPaintConfsRef.current[key] = layerPaintConfString; // update changed layout property
|
|
2532
2252
|
|
|
2533
|
-
|
|
2253
|
+
let layerLayoutConfString = JSON.stringify(props.layers[key].layout);
|
|
2534
2254
|
|
|
2535
2255
|
if (layerLayoutConfString !== layerLayoutConfsRef.current[key]) {
|
|
2536
|
-
for (
|
|
2256
|
+
for (let layoutKey in props.layers[key].layout) {
|
|
2537
2257
|
mapHook.map.setLayoutProperty(layerIdsRef.current[key], layoutKey, props.layers[key].layout[layoutKey]);
|
|
2538
2258
|
}
|
|
2539
2259
|
}
|
|
@@ -2567,7 +2287,7 @@ MlVectorTileLayer.propTypes = {
|
|
|
2567
2287
|
url: PropTypes.string
|
|
2568
2288
|
};
|
|
2569
2289
|
|
|
2570
|
-
|
|
2290
|
+
const defaultProps = {
|
|
2571
2291
|
visible: true,
|
|
2572
2292
|
urlParameters: {
|
|
2573
2293
|
bbox: "{bbox-epsg-3857}",
|
|
@@ -2607,52 +2327,56 @@ var defaultProps = {
|
|
|
2607
2327
|
* @component
|
|
2608
2328
|
*/
|
|
2609
2329
|
|
|
2610
|
-
|
|
2611
|
-
|
|
2330
|
+
const MlWmsLayer = props => {
|
|
2331
|
+
const mapHook = useMap({
|
|
2612
2332
|
mapId: props.mapId,
|
|
2613
2333
|
waitForLayer: props.insertBeforeLayer
|
|
2614
2334
|
});
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
useEffect(
|
|
2335
|
+
const initializedRef = useRef(false);
|
|
2336
|
+
const layerId = useRef(props.layerId || "MlWmsLayer-" + mapHook.componentId);
|
|
2337
|
+
useEffect(() => {
|
|
2618
2338
|
var _propsUrlParams2;
|
|
2619
2339
|
|
|
2620
2340
|
if (!mapHook.map || initializedRef.current) return;
|
|
2621
2341
|
initializedRef.current = true;
|
|
2622
2342
|
|
|
2623
|
-
|
|
2343
|
+
let _propsUrlParams;
|
|
2624
2344
|
|
|
2625
|
-
|
|
2345
|
+
let _wmsUrl = props.url;
|
|
2626
2346
|
|
|
2627
2347
|
if (props.url.indexOf("?") !== -1) {
|
|
2628
2348
|
_propsUrlParams = props.url.split("?");
|
|
2629
2349
|
_wmsUrl = _propsUrlParams[0];
|
|
2630
2350
|
}
|
|
2631
2351
|
|
|
2632
|
-
|
|
2633
|
-
|
|
2352
|
+
let _urlParamsFromUrl = new URLSearchParams((_propsUrlParams2 = _propsUrlParams) === null || _propsUrlParams2 === void 0 ? void 0 : _propsUrlParams2[1]); // first spread in default props manually to enable overriding a single parameter without replacing the whole default urlParameters object
|
|
2634
2353
|
|
|
2635
|
-
var urlParamsObj = _objectSpread2(_objectSpread2(_objectSpread2({}, defaultProps.urlParameters), Object.fromEntries(_urlParamsFromUrl)), props.urlParameters);
|
|
2636
2354
|
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2355
|
+
let urlParamsObj = { ...defaultProps.urlParameters,
|
|
2356
|
+
...Object.fromEntries(_urlParamsFromUrl),
|
|
2357
|
+
...props.urlParameters
|
|
2358
|
+
};
|
|
2359
|
+
let urlParams = new URLSearchParams(urlParamsObj);
|
|
2360
|
+
let urlParamsStr = decodeURIComponent(urlParams.toString()) + "".replace(/%2F/g, "/").replace(/%3A/g, ":");
|
|
2361
|
+
mapHook.map.addSource(layerId.current, {
|
|
2640
2362
|
type: "raster",
|
|
2641
2363
|
tiles: [_wmsUrl + "?" + urlParamsStr],
|
|
2642
2364
|
tileSize: urlParamsObj.width,
|
|
2643
|
-
attribution: props.attribution
|
|
2644
|
-
|
|
2645
|
-
mapHook.
|
|
2365
|
+
attribution: props.attribution,
|
|
2366
|
+
...props.sourceOptions
|
|
2367
|
+
}, mapHook.componentId);
|
|
2368
|
+
mapHook.map.addLayer({
|
|
2646
2369
|
id: layerId.current,
|
|
2647
2370
|
type: "raster",
|
|
2648
|
-
source: layerId.current
|
|
2649
|
-
|
|
2371
|
+
source: layerId.current,
|
|
2372
|
+
...props.layerOptions
|
|
2373
|
+
}, props.insertBeforeLayer, mapHook.componentId);
|
|
2650
2374
|
|
|
2651
2375
|
if (!props.visible) {
|
|
2652
2376
|
mapHook.map.setLayoutProperty(layerId.current, "visibility", "none");
|
|
2653
2377
|
}
|
|
2654
2378
|
}, [mapHook, props]);
|
|
2655
|
-
useEffect(
|
|
2379
|
+
useEffect(() => {
|
|
2656
2380
|
if (!mapHook.map || !initializedRef.current) return; // toggle layer visibility by changing the layout object's visibility property
|
|
2657
2381
|
|
|
2658
2382
|
if (props.visible) {
|
|
@@ -2664,7 +2388,8 @@ var MlWmsLayer = function MlWmsLayer(props) {
|
|
|
2664
2388
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
|
|
2665
2389
|
};
|
|
2666
2390
|
|
|
2667
|
-
MlWmsLayer.defaultProps =
|
|
2391
|
+
MlWmsLayer.defaultProps = { ...defaultProps
|
|
2392
|
+
};
|
|
2668
2393
|
MlWmsLayer.propTypes = {
|
|
2669
2394
|
/**
|
|
2670
2395
|
* WMS URL
|
|
@@ -2718,7 +2443,7 @@ MlWmsLayer.propTypes = {
|
|
|
2718
2443
|
visible: PropTypes.bool
|
|
2719
2444
|
};
|
|
2720
2445
|
|
|
2721
|
-
|
|
2446
|
+
const classes = {
|
|
2722
2447
|
CONTROL_BASE: 'mapboxgl-ctrl',
|
|
2723
2448
|
CONTROL_PREFIX: 'mapboxgl-ctrl-',
|
|
2724
2449
|
CONTROL_BUTTON: 'mapbox-gl-draw_ctrl-draw-btn',
|
|
@@ -2733,19 +2458,23 @@ var classes = {
|
|
|
2733
2458
|
ACTIVE_BUTTON: 'active',
|
|
2734
2459
|
BOX_SELECT: 'mapbox-gl-draw_boxselect'
|
|
2735
2460
|
};
|
|
2736
|
-
|
|
2461
|
+
const sources = {
|
|
2462
|
+
HOT: 'mapbox-gl-draw-hot',
|
|
2463
|
+
COLD: 'mapbox-gl-draw-cold'
|
|
2464
|
+
};
|
|
2465
|
+
const cursors = {
|
|
2737
2466
|
ADD: 'add',
|
|
2738
2467
|
MOVE: 'move',
|
|
2739
2468
|
DRAG: 'drag',
|
|
2740
2469
|
POINTER: 'pointer',
|
|
2741
2470
|
NONE: 'none'
|
|
2742
2471
|
};
|
|
2743
|
-
|
|
2472
|
+
const types = {
|
|
2744
2473
|
POLYGON: 'polygon',
|
|
2745
2474
|
LINE: 'line_string',
|
|
2746
2475
|
POINT: 'point'
|
|
2747
2476
|
};
|
|
2748
|
-
|
|
2477
|
+
const geojsonTypes = {
|
|
2749
2478
|
FEATURE: 'Feature',
|
|
2750
2479
|
POLYGON: 'Polygon',
|
|
2751
2480
|
LINE_STRING: 'LineString',
|
|
@@ -2756,7 +2485,15 @@ var geojsonTypes = {
|
|
|
2756
2485
|
MULTI_LINE_STRING: 'MultiLineString',
|
|
2757
2486
|
MULTI_POLYGON: 'MultiPolygon'
|
|
2758
2487
|
};
|
|
2759
|
-
|
|
2488
|
+
const modes = {
|
|
2489
|
+
DRAW_LINE_STRING: 'draw_line_string',
|
|
2490
|
+
DRAW_POLYGON: 'draw_polygon',
|
|
2491
|
+
DRAW_POINT: 'draw_point',
|
|
2492
|
+
SIMPLE_SELECT: 'simple_select',
|
|
2493
|
+
DIRECT_SELECT: 'direct_select',
|
|
2494
|
+
STATIC: 'static'
|
|
2495
|
+
};
|
|
2496
|
+
const events = {
|
|
2760
2497
|
CREATE: 'draw.create',
|
|
2761
2498
|
DELETE: 'draw.delete',
|
|
2762
2499
|
UPDATE: 'draw.update',
|
|
@@ -2767,29 +2504,51 @@ var events = {
|
|
|
2767
2504
|
COMBINE_FEATURES: 'draw.combine',
|
|
2768
2505
|
UNCOMBINE_FEATURES: 'draw.uncombine'
|
|
2769
2506
|
};
|
|
2770
|
-
|
|
2507
|
+
const updateActions = {
|
|
2771
2508
|
MOVE: 'move',
|
|
2772
2509
|
CHANGE_COORDINATES: 'change_coordinates'
|
|
2773
2510
|
};
|
|
2774
|
-
|
|
2511
|
+
const meta = {
|
|
2775
2512
|
FEATURE: 'feature',
|
|
2776
2513
|
MIDPOINT: 'midpoint',
|
|
2777
2514
|
VERTEX: 'vertex'
|
|
2778
2515
|
};
|
|
2779
|
-
|
|
2516
|
+
const activeStates = {
|
|
2780
2517
|
ACTIVE: 'true',
|
|
2781
2518
|
INACTIVE: 'false'
|
|
2782
2519
|
};
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2520
|
+
const interactions = ['scrollZoom', 'boxZoom', 'dragRotate', 'dragPan', 'keyboard', 'doubleClickZoom', 'touchZoomRotate'];
|
|
2521
|
+
const LAT_MIN = -90;
|
|
2522
|
+
const LAT_RENDERED_MIN = -85;
|
|
2523
|
+
const LAT_MAX = 90;
|
|
2524
|
+
const LAT_RENDERED_MAX = 85;
|
|
2525
|
+
const LNG_MIN = -270;
|
|
2526
|
+
const LNG_MAX = 270;
|
|
2527
|
+
|
|
2528
|
+
var Constants = /*#__PURE__*/Object.freeze({
|
|
2529
|
+
__proto__: null,
|
|
2530
|
+
classes: classes,
|
|
2531
|
+
sources: sources,
|
|
2532
|
+
cursors: cursors,
|
|
2533
|
+
types: types,
|
|
2534
|
+
geojsonTypes: geojsonTypes,
|
|
2535
|
+
modes: modes,
|
|
2536
|
+
events: events,
|
|
2537
|
+
updateActions: updateActions,
|
|
2538
|
+
meta: meta,
|
|
2539
|
+
activeStates: activeStates,
|
|
2540
|
+
interactions: interactions,
|
|
2541
|
+
LAT_MIN: LAT_MIN,
|
|
2542
|
+
LAT_RENDERED_MIN: LAT_RENDERED_MIN,
|
|
2543
|
+
LAT_MAX: LAT_MAX,
|
|
2544
|
+
LAT_RENDERED_MAX: LAT_RENDERED_MAX,
|
|
2545
|
+
LNG_MIN: LNG_MIN,
|
|
2546
|
+
LNG_MAX: LNG_MAX
|
|
2547
|
+
});
|
|
2789
2548
|
|
|
2790
2549
|
function isOfMetaType(type) {
|
|
2791
2550
|
return function (e) {
|
|
2792
|
-
|
|
2551
|
+
const featureTarget = e.featureTarget;
|
|
2793
2552
|
if (!featureTarget) return false;
|
|
2794
2553
|
if (!featureTarget.properties) return false;
|
|
2795
2554
|
return featureTarget.properties.meta === type;
|
|
@@ -2819,7 +2578,7 @@ function isFeature(e) {
|
|
|
2819
2578
|
return e.featureTarget.properties.meta === meta.FEATURE;
|
|
2820
2579
|
}
|
|
2821
2580
|
function isVertex(e) {
|
|
2822
|
-
|
|
2581
|
+
const featureTarget = e.featureTarget;
|
|
2823
2582
|
if (!featureTarget) return false;
|
|
2824
2583
|
if (!featureTarget.properties) return false;
|
|
2825
2584
|
return featureTarget.properties.meta === meta.VERTEX;
|
|
@@ -2835,9 +2594,9 @@ function isEnterKey(e) {
|
|
|
2835
2594
|
return e.keyCode === 13;
|
|
2836
2595
|
}
|
|
2837
2596
|
|
|
2838
|
-
|
|
2839
|
-
enable
|
|
2840
|
-
setTimeout(
|
|
2597
|
+
const doubleClickZoom = {
|
|
2598
|
+
enable(ctx) {
|
|
2599
|
+
setTimeout(() => {
|
|
2841
2600
|
// First check we've got a map and some context.
|
|
2842
2601
|
if (!ctx.map || !ctx.map.doubleClickZoom || !ctx._ctx || !ctx._ctx.store || !ctx._ctx.store.getInitialConfigValue) return; // Now check initial state wasn't false (we leave it disabled if so)
|
|
2843
2602
|
|
|
@@ -2845,13 +2604,15 @@ var doubleClickZoom = {
|
|
|
2845
2604
|
ctx.map.doubleClickZoom.enable();
|
|
2846
2605
|
}, 0);
|
|
2847
2606
|
},
|
|
2848
|
-
|
|
2849
|
-
|
|
2607
|
+
|
|
2608
|
+
disable(ctx) {
|
|
2609
|
+
setTimeout(() => {
|
|
2850
2610
|
if (!ctx.map || !ctx.map.doubleClickZoom) return; // Always disable here, as it's necessary in some cases.
|
|
2851
2611
|
|
|
2852
2612
|
ctx.map.doubleClickZoom.disable();
|
|
2853
2613
|
}, 0);
|
|
2854
2614
|
}
|
|
2615
|
+
|
|
2855
2616
|
};
|
|
2856
2617
|
|
|
2857
2618
|
function isEventAtCoordinates(event, coordinates) {
|
|
@@ -2871,7 +2632,7 @@ function isEventAtCoordinates(event, coordinates) {
|
|
|
2871
2632
|
* @return {GeoJSON} Point
|
|
2872
2633
|
*/
|
|
2873
2634
|
|
|
2874
|
-
|
|
2635
|
+
const create_vertex = function (parentId, coordinates, path, selected) {
|
|
2875
2636
|
return {
|
|
2876
2637
|
type: geojsonTypes.FEATURE,
|
|
2877
2638
|
properties: {
|
|
@@ -2882,16 +2643,16 @@ var create_vertex = function create_vertex(parentId, coordinates, path, selected
|
|
|
2882
2643
|
},
|
|
2883
2644
|
geometry: {
|
|
2884
2645
|
type: geojsonTypes.POINT,
|
|
2885
|
-
coordinates
|
|
2646
|
+
coordinates
|
|
2886
2647
|
}
|
|
2887
2648
|
};
|
|
2888
2649
|
};
|
|
2889
2650
|
|
|
2890
|
-
|
|
2651
|
+
const CustomPolygonMode = {};
|
|
2891
2652
|
|
|
2892
2653
|
CustomPolygonMode.onSetup = function () {
|
|
2893
2654
|
console.log("Change mode: custom polygon");
|
|
2894
|
-
|
|
2655
|
+
const polygon = this.newFeature({
|
|
2895
2656
|
type: geojsonTypes.FEATURE,
|
|
2896
2657
|
properties: {},
|
|
2897
2658
|
geometry: {
|
|
@@ -2910,7 +2671,7 @@ CustomPolygonMode.onSetup = function () {
|
|
|
2910
2671
|
trash: true
|
|
2911
2672
|
});
|
|
2912
2673
|
return {
|
|
2913
|
-
polygon
|
|
2674
|
+
polygon,
|
|
2914
2675
|
currentVertexPosition: 0
|
|
2915
2676
|
};
|
|
2916
2677
|
};
|
|
@@ -2993,13 +2754,13 @@ CustomPolygonMode.onStop = function (state) {
|
|
|
2993
2754
|
};
|
|
2994
2755
|
|
|
2995
2756
|
CustomPolygonMode.toDisplayFeatures = function (state, geojson, display) {
|
|
2996
|
-
|
|
2757
|
+
const isActivePolygon = geojson.properties.id === state.polygon.id;
|
|
2997
2758
|
geojson.properties.active = isActivePolygon ? activeStates.ACTIVE : activeStates.INACTIVE;
|
|
2998
2759
|
if (!isActivePolygon) return display(geojson); // Don't render a polygon until it has two positions
|
|
2999
2760
|
// (and a 3rd which is just the first repeated)
|
|
3000
2761
|
|
|
3001
2762
|
if (geojson.geometry.coordinates.length === 0) return;
|
|
3002
|
-
|
|
2763
|
+
const coordinateCount = geojson.geometry.coordinates[0].length; // 2 coordinates after selecting a draw type
|
|
3003
2764
|
// 3 after creating the first point
|
|
3004
2765
|
|
|
3005
2766
|
if (coordinateCount < 3) {
|
|
@@ -3012,14 +2773,14 @@ CustomPolygonMode.toDisplayFeatures = function (state, geojson, display) {
|
|
|
3012
2773
|
if (coordinateCount > 3) {
|
|
3013
2774
|
// Add a start position marker to the map, clicking on this will finish the feature
|
|
3014
2775
|
// This should only be shown when we're in a valid spot
|
|
3015
|
-
|
|
2776
|
+
const endPos = geojson.geometry.coordinates[0].length - 3;
|
|
3016
2777
|
display(create_vertex(state.polygon.id, geojson.geometry.coordinates[0][endPos], "0.".concat(endPos), false));
|
|
3017
2778
|
}
|
|
3018
2779
|
|
|
3019
2780
|
if (coordinateCount <= 4) {
|
|
3020
2781
|
// If we've only drawn two positions (plus the closer),
|
|
3021
2782
|
// make a LineString instead of a Polygon
|
|
3022
|
-
|
|
2783
|
+
const lineCoordinates = [[geojson.geometry.coordinates[0][0][0], geojson.geometry.coordinates[0][0][1]], [geojson.geometry.coordinates[0][1][0], geojson.geometry.coordinates[0][1][1]]]; // create an initial vertex so that we can track the first point on mobile devices
|
|
3023
2784
|
|
|
3024
2785
|
display({
|
|
3025
2786
|
type: geojsonTypes.FEATURE,
|
|
@@ -3056,20 +2817,20 @@ CustomPolygonMode.onTrash = function (state) {
|
|
|
3056
2817
|
*/
|
|
3057
2818
|
|
|
3058
2819
|
function mouseEventPoint(mouseEvent, container) {
|
|
3059
|
-
|
|
2820
|
+
const rect = container.getBoundingClientRect();
|
|
3060
2821
|
return new Point(mouseEvent.clientX - rect.left - (container.clientLeft || 0), mouseEvent.clientY - rect.top - (container.clientTop || 0));
|
|
3061
2822
|
}
|
|
3062
2823
|
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
2824
|
+
const create_midpoint = function (parent, startVertex, endVertex) {
|
|
2825
|
+
const startCoord = startVertex.geometry.coordinates;
|
|
2826
|
+
const endCoord = endVertex.geometry.coordinates; // If a coordinate exceeds the projection, we can't calculate a midpoint,
|
|
3066
2827
|
// so run away
|
|
3067
2828
|
|
|
3068
2829
|
if (startCoord[1] > LAT_RENDERED_MAX || startCoord[1] < LAT_RENDERED_MIN || endCoord[1] > LAT_RENDERED_MAX || endCoord[1] < LAT_RENDERED_MIN) {
|
|
3069
2830
|
return null;
|
|
3070
2831
|
}
|
|
3071
2832
|
|
|
3072
|
-
|
|
2833
|
+
const mid = {
|
|
3073
2834
|
lng: (startCoord[0] + endCoord[0]) / 2,
|
|
3074
2835
|
lat: (startCoord[1] + endCoord[1]) / 2
|
|
3075
2836
|
};
|
|
@@ -3077,7 +2838,7 @@ var create_midpoint = function create_midpoint(parent, startVertex, endVertex) {
|
|
|
3077
2838
|
type: geojsonTypes.FEATURE,
|
|
3078
2839
|
properties: {
|
|
3079
2840
|
meta: meta.MIDPOINT,
|
|
3080
|
-
parent
|
|
2841
|
+
parent,
|
|
3081
2842
|
lng: mid.lng,
|
|
3082
2843
|
lat: mid.lat,
|
|
3083
2844
|
coord_path: endVertex.properties.coord_path
|
|
@@ -3090,13 +2851,14 @@ var create_midpoint = function create_midpoint(parent, startVertex, endVertex) {
|
|
|
3090
2851
|
};
|
|
3091
2852
|
|
|
3092
2853
|
function createSupplementaryPoints(geojson) {
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
2854
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2855
|
+
let basePath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
2856
|
+
const {
|
|
2857
|
+
type,
|
|
2858
|
+
coordinates
|
|
2859
|
+
} = geojson.geometry;
|
|
2860
|
+
const featureId = geojson.properties && geojson.properties.id;
|
|
2861
|
+
let supplementaryPoints = [];
|
|
3100
2862
|
|
|
3101
2863
|
if (type === geojsonTypes.POINT) {
|
|
3102
2864
|
// For points, just create a vertex
|
|
@@ -3104,7 +2866,7 @@ function createSupplementaryPoints(geojson) {
|
|
|
3104
2866
|
} else if (type === geojsonTypes.POLYGON) {
|
|
3105
2867
|
// Cycle through a Polygon's rings and
|
|
3106
2868
|
// process each line
|
|
3107
|
-
coordinates.forEach(
|
|
2869
|
+
coordinates.forEach((line, lineIndex) => {
|
|
3108
2870
|
processLine(line, basePath !== null ? "".concat(basePath, ".").concat(lineIndex) : String(lineIndex));
|
|
3109
2871
|
});
|
|
3110
2872
|
} else if (type === geojsonTypes.LINE_STRING) {
|
|
@@ -3114,16 +2876,16 @@ function createSupplementaryPoints(geojson) {
|
|
|
3114
2876
|
}
|
|
3115
2877
|
|
|
3116
2878
|
function processLine(line, lineBasePath) {
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
line.forEach(
|
|
3120
|
-
|
|
3121
|
-
|
|
2879
|
+
let firstPointString = "";
|
|
2880
|
+
let lastVertex = null;
|
|
2881
|
+
line.forEach((point, pointIndex) => {
|
|
2882
|
+
const pointPath = lineBasePath !== undefined && lineBasePath !== null ? "".concat(lineBasePath, ".").concat(pointIndex) : String(pointIndex);
|
|
2883
|
+
const vertex = create_vertex(featureId, point, pointPath, isSelectedPath(pointPath)); // If we're creating midpoints, check if there was a
|
|
3122
2884
|
// vertex before this one. If so, add a midpoint
|
|
3123
2885
|
// between that vertex and this one.
|
|
3124
2886
|
|
|
3125
2887
|
if (options.midpoints && lastVertex) {
|
|
3126
|
-
|
|
2888
|
+
const midpoint = create_midpoint(featureId, lastVertex, vertex);
|
|
3127
2889
|
|
|
3128
2890
|
if (midpoint) {
|
|
3129
2891
|
supplementaryPoints.push(midpoint);
|
|
@@ -3134,7 +2896,7 @@ function createSupplementaryPoints(geojson) {
|
|
|
3134
2896
|
// point, we want to draw a midpoint before it but not another vertex on it
|
|
3135
2897
|
// (since we already a vertex there, from the first point).
|
|
3136
2898
|
|
|
3137
|
-
|
|
2899
|
+
const stringifiedPoint = JSON.stringify(point);
|
|
3138
2900
|
|
|
3139
2901
|
if (firstPointString !== stringifiedPoint) {
|
|
3140
2902
|
supplementaryPoints.push(vertex);
|
|
@@ -3155,9 +2917,9 @@ function createSupplementaryPoints(geojson) {
|
|
|
3155
2917
|
|
|
3156
2918
|
|
|
3157
2919
|
function processMultiGeometry() {
|
|
3158
|
-
|
|
3159
|
-
coordinates.forEach(
|
|
3160
|
-
|
|
2920
|
+
const subType = type.replace(geojsonTypes.MULTI_PREFIX, "");
|
|
2921
|
+
coordinates.forEach((subCoordinates, index) => {
|
|
2922
|
+
const subFeature = {
|
|
3161
2923
|
type: geojsonTypes.FEATURE,
|
|
3162
2924
|
properties: geojson.properties,
|
|
3163
2925
|
geometry: {
|
|
@@ -3178,7 +2940,7 @@ function StringSet(items) {
|
|
|
3178
2940
|
this._length = items ? items.length : 0;
|
|
3179
2941
|
if (!items) return;
|
|
3180
2942
|
|
|
3181
|
-
for (
|
|
2943
|
+
for (let i = 0, l = items.length; i < l; i++) {
|
|
3182
2944
|
this.add(items[i]);
|
|
3183
2945
|
if (items[i] === undefined) continue;
|
|
3184
2946
|
if (typeof items[i] === 'string') this._items[items[i]] = i;else this._nums[items[i]] = i;
|
|
@@ -3206,26 +2968,20 @@ StringSet.prototype.has = function (x) {
|
|
|
3206
2968
|
};
|
|
3207
2969
|
|
|
3208
2970
|
StringSet.prototype.values = function () {
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
var values = [];
|
|
3212
|
-
Object.keys(this._items).forEach(function (k) {
|
|
2971
|
+
const values = [];
|
|
2972
|
+
Object.keys(this._items).forEach(k => {
|
|
3213
2973
|
values.push({
|
|
3214
|
-
k
|
|
3215
|
-
v:
|
|
2974
|
+
k,
|
|
2975
|
+
v: this._items[k]
|
|
3216
2976
|
});
|
|
3217
2977
|
});
|
|
3218
|
-
Object.keys(this._nums).forEach(
|
|
2978
|
+
Object.keys(this._nums).forEach(k => {
|
|
3219
2979
|
values.push({
|
|
3220
2980
|
k: JSON.parse(k),
|
|
3221
|
-
v:
|
|
2981
|
+
v: this._nums[k]
|
|
3222
2982
|
});
|
|
3223
2983
|
});
|
|
3224
|
-
return values.sort(
|
|
3225
|
-
return a.v - b.v;
|
|
3226
|
-
}).map(function (a) {
|
|
3227
|
-
return a.k;
|
|
3228
|
-
});
|
|
2984
|
+
return values.sort((a, b) => a.v - b.v).map(a => a.k);
|
|
3229
2985
|
};
|
|
3230
2986
|
|
|
3231
2987
|
StringSet.prototype.clear = function () {
|
|
@@ -3235,31 +2991,33 @@ StringSet.prototype.clear = function () {
|
|
|
3235
2991
|
return this;
|
|
3236
2992
|
};
|
|
3237
2993
|
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
2994
|
+
const {
|
|
2995
|
+
LAT_MIN: LAT_MIN$1,
|
|
2996
|
+
LAT_MAX: LAT_MAX$1,
|
|
2997
|
+
LAT_RENDERED_MIN: LAT_RENDERED_MIN$1,
|
|
2998
|
+
LAT_RENDERED_MAX: LAT_RENDERED_MAX$1,
|
|
2999
|
+
LNG_MIN: LNG_MIN$1,
|
|
3000
|
+
LNG_MAX: LNG_MAX$1
|
|
3001
|
+
} = Constants; // Ensure that we do not drag north-south far enough for
|
|
3244
3002
|
// - any part of any feature to exceed the poles
|
|
3245
3003
|
// - any feature to be completely lost in the space between the projection's
|
|
3246
3004
|
// edge and the poles, such that it couldn't be re-selected and moved back
|
|
3247
3005
|
|
|
3248
|
-
|
|
3006
|
+
const constrain_feature_movement = function (geojsonFeatures, delta) {
|
|
3249
3007
|
// "inner edge" = a feature's latitude closest to the equator
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
geojsonFeatures.forEach(
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3008
|
+
let northInnerEdge = LAT_MIN$1;
|
|
3009
|
+
let southInnerEdge = LAT_MAX$1; // "outer edge" = a feature's latitude furthest from the equator
|
|
3010
|
+
|
|
3011
|
+
let northOuterEdge = LAT_MIN$1;
|
|
3012
|
+
let southOuterEdge = LAT_MAX$1;
|
|
3013
|
+
let westEdge = LNG_MAX$1;
|
|
3014
|
+
let eastEdge = LNG_MIN$1;
|
|
3015
|
+
geojsonFeatures.forEach(feature => {
|
|
3016
|
+
const bounds = extent(feature);
|
|
3017
|
+
const featureSouthEdge = bounds[1];
|
|
3018
|
+
const featureNorthEdge = bounds[3];
|
|
3019
|
+
const featureWestEdge = bounds[0];
|
|
3020
|
+
const featureEastEdge = bounds[2];
|
|
3263
3021
|
if (featureSouthEdge > northInnerEdge) northInnerEdge = featureSouthEdge;
|
|
3264
3022
|
if (featureNorthEdge < southInnerEdge) southInnerEdge = featureNorthEdge;
|
|
3265
3023
|
if (featureNorthEdge > northOuterEdge) northOuterEdge = featureNorthEdge;
|
|
@@ -3270,7 +3028,7 @@ var constrain_feature_movement = function constrain_feature_movement(geojsonFeat
|
|
|
3270
3028
|
// edge but also have hit the outer edge and therefore need
|
|
3271
3029
|
// another readjustment
|
|
3272
3030
|
|
|
3273
|
-
|
|
3031
|
+
const constrainedDelta = delta;
|
|
3274
3032
|
|
|
3275
3033
|
if (northInnerEdge + constrainedDelta.lat > LAT_RENDERED_MAX$1) {
|
|
3276
3034
|
constrainedDelta.lat = LAT_RENDERED_MAX$1 - northInnerEdge;
|
|
@@ -3299,34 +3057,24 @@ var constrain_feature_movement = function constrain_feature_movement(geojsonFeat
|
|
|
3299
3057
|
return constrainedDelta;
|
|
3300
3058
|
};
|
|
3301
3059
|
|
|
3302
|
-
var move_features = function
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
features.forEach(function (feature) {
|
|
3307
|
-
var currentCoordinates = feature.getCoordinates();
|
|
3060
|
+
var move_features = function (features, delta) {
|
|
3061
|
+
const constrainedDelta = constrain_feature_movement(features.map(feature => feature.toGeoJSON()), delta);
|
|
3062
|
+
features.forEach(feature => {
|
|
3063
|
+
const currentCoordinates = feature.getCoordinates();
|
|
3308
3064
|
|
|
3309
|
-
|
|
3310
|
-
|
|
3065
|
+
const moveCoordinate = coord => {
|
|
3066
|
+
const point = {
|
|
3311
3067
|
lng: coord[0] + constrainedDelta.lng,
|
|
3312
3068
|
lat: coord[1] + constrainedDelta.lat
|
|
3313
3069
|
};
|
|
3314
3070
|
return [point.lng, point.lat];
|
|
3315
3071
|
};
|
|
3316
3072
|
|
|
3317
|
-
|
|
3318
|
-
return ring.map(function (coord) {
|
|
3319
|
-
return moveCoordinate(coord);
|
|
3320
|
-
});
|
|
3321
|
-
};
|
|
3073
|
+
const moveRing = ring => ring.map(coord => moveCoordinate(coord));
|
|
3322
3074
|
|
|
3323
|
-
|
|
3324
|
-
return multi.map(function (ring) {
|
|
3325
|
-
return moveRing(ring);
|
|
3326
|
-
});
|
|
3327
|
-
};
|
|
3075
|
+
const moveMultiPolygon = multi => multi.map(ring => moveRing(ring));
|
|
3328
3076
|
|
|
3329
|
-
|
|
3077
|
+
let nextCoordinates;
|
|
3330
3078
|
|
|
3331
3079
|
if (feature.type === geojsonTypes.POINT) {
|
|
3332
3080
|
nextCoordinates = moveCoordinate(currentCoordinates);
|
|
@@ -3342,14 +3090,12 @@ var move_features = function move_features(features, delta) {
|
|
|
3342
3090
|
});
|
|
3343
3091
|
};
|
|
3344
3092
|
|
|
3345
|
-
|
|
3093
|
+
const CustomSelectMode = {};
|
|
3346
3094
|
|
|
3347
3095
|
CustomSelectMode.onSetup = function (opts) {
|
|
3348
|
-
var _this = this;
|
|
3349
|
-
|
|
3350
3096
|
console.log("Change mode: custom select"); // turn the opts into state.
|
|
3351
3097
|
|
|
3352
|
-
|
|
3098
|
+
const state = {
|
|
3353
3099
|
dragMoveLocation: null,
|
|
3354
3100
|
boxSelectStartLocation: null,
|
|
3355
3101
|
boxSelectElement: undefined,
|
|
@@ -3359,9 +3105,7 @@ CustomSelectMode.onSetup = function (opts) {
|
|
|
3359
3105
|
canDragMove: false,
|
|
3360
3106
|
initiallySelectedFeatureIds: opts.featureIds || []
|
|
3361
3107
|
};
|
|
3362
|
-
this.setSelected(state.initiallySelectedFeatureIds.filter(
|
|
3363
|
-
return _this.getFeature(id) !== undefined;
|
|
3364
|
-
}));
|
|
3108
|
+
this.setSelected(state.initiallySelectedFeatureIds.filter(id => this.getFeature(id) !== undefined));
|
|
3365
3109
|
this.fireActionable();
|
|
3366
3110
|
this.setActionableState({
|
|
3367
3111
|
combineFeatures: true,
|
|
@@ -3374,47 +3118,37 @@ CustomSelectMode.onSetup = function (opts) {
|
|
|
3374
3118
|
CustomSelectMode.fireUpdate = function () {
|
|
3375
3119
|
this.map.fire(events.UPDATE, {
|
|
3376
3120
|
action: updateActions.MOVE,
|
|
3377
|
-
features: this.getSelected().map(
|
|
3378
|
-
return f.toGeoJSON();
|
|
3379
|
-
})
|
|
3121
|
+
features: this.getSelected().map(f => f.toGeoJSON())
|
|
3380
3122
|
});
|
|
3381
3123
|
};
|
|
3382
3124
|
|
|
3383
3125
|
CustomSelectMode.fireActionable = function () {
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
var multiFeatures = selectedFeatures.filter(function (feature) {
|
|
3388
|
-
return _this2.isInstanceOf("MultiFeature", feature);
|
|
3389
|
-
});
|
|
3390
|
-
var combineFeatures = false;
|
|
3126
|
+
const selectedFeatures = this.getSelected();
|
|
3127
|
+
const multiFeatures = selectedFeatures.filter(feature => this.isInstanceOf("MultiFeature", feature));
|
|
3128
|
+
let combineFeatures = false;
|
|
3391
3129
|
|
|
3392
3130
|
if (selectedFeatures.length > 1) {
|
|
3393
3131
|
combineFeatures = true;
|
|
3394
|
-
|
|
3395
|
-
selectedFeatures.forEach(
|
|
3132
|
+
const featureType = selectedFeatures[0].type.replace("Multi", "");
|
|
3133
|
+
selectedFeatures.forEach(feature => {
|
|
3396
3134
|
if (feature.type.replace("Multi", "") !== featureType) {
|
|
3397
3135
|
combineFeatures = false;
|
|
3398
3136
|
}
|
|
3399
3137
|
});
|
|
3400
3138
|
}
|
|
3401
3139
|
|
|
3402
|
-
|
|
3403
|
-
|
|
3140
|
+
const uncombineFeatures = multiFeatures.length > 0;
|
|
3141
|
+
const trash = selectedFeatures.length > 0;
|
|
3404
3142
|
this.setActionableState({
|
|
3405
|
-
combineFeatures
|
|
3406
|
-
uncombineFeatures
|
|
3407
|
-
trash
|
|
3143
|
+
combineFeatures,
|
|
3144
|
+
uncombineFeatures,
|
|
3145
|
+
trash
|
|
3408
3146
|
});
|
|
3409
3147
|
};
|
|
3410
3148
|
|
|
3411
3149
|
CustomSelectMode.getUniqueIds = function (allFeatures) {
|
|
3412
3150
|
if (!allFeatures.length) return [];
|
|
3413
|
-
|
|
3414
|
-
return s.properties.id;
|
|
3415
|
-
}).filter(function (id) {
|
|
3416
|
-
return id !== undefined;
|
|
3417
|
-
}).reduce(function (memo, id) {
|
|
3151
|
+
const ids = allFeatures.map(s => s.properties.id).filter(id => id !== undefined).reduce((memo, id) => {
|
|
3418
3152
|
memo.add(id);
|
|
3419
3153
|
return memo;
|
|
3420
3154
|
}, new StringSet());
|
|
@@ -3462,16 +3196,12 @@ CustomSelectMode.onTap = CustomSelectMode.onClick = function (state, e) {
|
|
|
3462
3196
|
};
|
|
3463
3197
|
|
|
3464
3198
|
CustomSelectMode.clickAnywhere = function (state) {
|
|
3465
|
-
var _this3 = this;
|
|
3466
|
-
|
|
3467
3199
|
// Clear the re-render selection
|
|
3468
|
-
|
|
3200
|
+
const wasSelected = this.getSelectedIds();
|
|
3469
3201
|
|
|
3470
3202
|
if (wasSelected.length) {
|
|
3471
3203
|
this.clearSelectedFeatures();
|
|
3472
|
-
wasSelected.forEach(
|
|
3473
|
-
return _this3.doRender(id);
|
|
3474
|
-
});
|
|
3204
|
+
wasSelected.forEach(id => this.doRender(id));
|
|
3475
3205
|
}
|
|
3476
3206
|
|
|
3477
3207
|
doubleClickZoom.enable(this);
|
|
@@ -3504,20 +3234,18 @@ CustomSelectMode.startOnActiveFeature = function (state, e) {
|
|
|
3504
3234
|
};
|
|
3505
3235
|
|
|
3506
3236
|
CustomSelectMode.clickOnFeature = function (state, e) {
|
|
3507
|
-
var _this4 = this;
|
|
3508
|
-
|
|
3509
3237
|
// Stop everything
|
|
3510
3238
|
doubleClickZoom.disable(this);
|
|
3511
3239
|
this.stopExtendedInteractions(state);
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3240
|
+
const isShiftClick = isShiftDown(e);
|
|
3241
|
+
const selectedFeatureIds = this.getSelectedIds();
|
|
3242
|
+
const featureId = e.featureTarget.properties.id;
|
|
3243
|
+
const isFeatureSelected = this.isSelected(featureId); // Click (without shift) on any selected feature but a point
|
|
3516
3244
|
|
|
3517
3245
|
if (!isShiftClick && isFeatureSelected && this.getFeature(featureId).type !== geojsonTypes.POINT) {
|
|
3518
3246
|
// Enter direct select mode
|
|
3519
3247
|
return this.changeMode("custom_direct_select", {
|
|
3520
|
-
featureId
|
|
3248
|
+
featureId
|
|
3521
3249
|
});
|
|
3522
3250
|
} // Shift-click on a selected feature
|
|
3523
3251
|
|
|
@@ -3541,9 +3269,7 @@ CustomSelectMode.clickOnFeature = function (state, e) {
|
|
|
3541
3269
|
}); // Click (without shift) on an unselected feature
|
|
3542
3270
|
} else if (!isFeatureSelected && !isShiftClick) {
|
|
3543
3271
|
// Make it the only selected feature
|
|
3544
|
-
selectedFeatureIds.forEach(
|
|
3545
|
-
return _this4.doRender(id);
|
|
3546
|
-
});
|
|
3272
|
+
selectedFeatureIds.forEach(id => this.doRender(id));
|
|
3547
3273
|
this.setSelected(featureId);
|
|
3548
3274
|
this.updateUIClasses({
|
|
3549
3275
|
mouse: cursors.MOVE
|
|
@@ -3589,12 +3315,12 @@ CustomSelectMode.whileBoxSelect = function (state, e) {
|
|
|
3589
3315
|
} // Adjust the box node's width and xy position
|
|
3590
3316
|
|
|
3591
3317
|
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3318
|
+
const current = mouseEventPoint(e.originalEvent, this.map.getContainer());
|
|
3319
|
+
const minX = Math.min(state.boxSelectStartLocation.x, current.x);
|
|
3320
|
+
const maxX = Math.max(state.boxSelectStartLocation.x, current.x);
|
|
3321
|
+
const minY = Math.min(state.boxSelectStartLocation.y, current.y);
|
|
3322
|
+
const maxY = Math.max(state.boxSelectStartLocation.y, current.y);
|
|
3323
|
+
const translateValue = "translate(".concat(minX, "px, ").concat(minY, "px)");
|
|
3598
3324
|
state.boxSelectElement.style.transform = translateValue;
|
|
3599
3325
|
state.boxSelectElement.style.WebkitTransform = translateValue;
|
|
3600
3326
|
state.boxSelectElement.style.width = "".concat(maxX - minX, "px");
|
|
@@ -3605,7 +3331,7 @@ CustomSelectMode.dragMove = function (state, e) {
|
|
|
3605
3331
|
// Dragging when drag move is enabled
|
|
3606
3332
|
state.dragMoving = true;
|
|
3607
3333
|
e.originalEvent.stopPropagation();
|
|
3608
|
-
|
|
3334
|
+
const delta = {
|
|
3609
3335
|
lng: e.lngLat.lng - state.dragMoveLocation.lng,
|
|
3610
3336
|
lat: e.lngLat.lat - state.dragMoveLocation.lat
|
|
3611
3337
|
};
|
|
@@ -3614,23 +3340,17 @@ CustomSelectMode.dragMove = function (state, e) {
|
|
|
3614
3340
|
};
|
|
3615
3341
|
|
|
3616
3342
|
CustomSelectMode.onMouseUp = function (state, e) {
|
|
3617
|
-
var _this5 = this;
|
|
3618
|
-
|
|
3619
3343
|
// End any extended interactions
|
|
3620
3344
|
if (state.dragMoving) {
|
|
3621
3345
|
this.fireUpdate();
|
|
3622
3346
|
} else if (state.boxSelecting) {
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
return !_this5.isSelected(id);
|
|
3627
|
-
});
|
|
3347
|
+
const bbox = [state.boxSelectStartLocation, mouseEventPoint(e.originalEvent, this.map.getContainer())];
|
|
3348
|
+
const featuresInBox = this.featuresAt(null, bbox, "click");
|
|
3349
|
+
const idsToSelect = this.getUniqueIds(featuresInBox).filter(id => !this.isSelected(id));
|
|
3628
3350
|
|
|
3629
3351
|
if (idsToSelect.length) {
|
|
3630
3352
|
this.select(idsToSelect);
|
|
3631
|
-
idsToSelect.forEach(
|
|
3632
|
-
return _this5.doRender(id);
|
|
3633
|
-
});
|
|
3353
|
+
idsToSelect.forEach(id => this.doRender(id));
|
|
3634
3354
|
this.updateUIClasses({
|
|
3635
3355
|
mouse: cursors.MOVE
|
|
3636
3356
|
});
|
|
@@ -3654,21 +3374,21 @@ CustomSelectMode.onTrash = function () {
|
|
|
3654
3374
|
};
|
|
3655
3375
|
|
|
3656
3376
|
CustomSelectMode.onCombineFeatures = function () {
|
|
3657
|
-
|
|
3377
|
+
const selectedFeatures = this.getSelected();
|
|
3658
3378
|
if (selectedFeatures.length === 0 || selectedFeatures.length < 2) return;
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3379
|
+
const coordinates = [],
|
|
3380
|
+
featuresCombined = [];
|
|
3381
|
+
const featureType = selectedFeatures[0].type.replace("Multi", "");
|
|
3662
3382
|
|
|
3663
|
-
for (
|
|
3664
|
-
|
|
3383
|
+
for (let i = 0; i < selectedFeatures.length; i++) {
|
|
3384
|
+
const feature = selectedFeatures[i];
|
|
3665
3385
|
|
|
3666
3386
|
if (feature.type.replace("Multi", "") !== featureType) {
|
|
3667
3387
|
return;
|
|
3668
3388
|
}
|
|
3669
3389
|
|
|
3670
3390
|
if (feature.type.includes("Multi")) {
|
|
3671
|
-
feature.getCoordinates().forEach(
|
|
3391
|
+
feature.getCoordinates().forEach(subcoords => {
|
|
3672
3392
|
coordinates.push(subcoords);
|
|
3673
3393
|
});
|
|
3674
3394
|
} else {
|
|
@@ -3679,12 +3399,12 @@ CustomSelectMode.onCombineFeatures = function () {
|
|
|
3679
3399
|
}
|
|
3680
3400
|
|
|
3681
3401
|
if (featuresCombined.length > 1) {
|
|
3682
|
-
|
|
3402
|
+
const multiFeature = this.newFeature({
|
|
3683
3403
|
type: geojsonTypes.FEATURE,
|
|
3684
3404
|
properties: featuresCombined[0].properties,
|
|
3685
3405
|
geometry: {
|
|
3686
3406
|
type: "Multi".concat(featureType),
|
|
3687
|
-
coordinates
|
|
3407
|
+
coordinates
|
|
3688
3408
|
}
|
|
3689
3409
|
});
|
|
3690
3410
|
this.addFeature(multiFeature);
|
|
@@ -3702,41 +3422,31 @@ CustomSelectMode.onCombineFeatures = function () {
|
|
|
3702
3422
|
};
|
|
3703
3423
|
|
|
3704
3424
|
CustomSelectMode.onUncombineFeatures = function () {
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
var selectedFeatures = this.getSelected();
|
|
3425
|
+
const selectedFeatures = this.getSelected();
|
|
3708
3426
|
if (selectedFeatures.length === 0) return;
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
var _loop = function _loop(i) {
|
|
3713
|
-
var feature = selectedFeatures[i];
|
|
3427
|
+
const createdFeatures = [];
|
|
3428
|
+
const featuresUncombined = [];
|
|
3714
3429
|
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
_this6.addFeature(subFeature);
|
|
3430
|
+
for (let i = 0; i < selectedFeatures.length; i++) {
|
|
3431
|
+
const feature = selectedFeatures[i];
|
|
3718
3432
|
|
|
3433
|
+
if (this.isInstanceOf("MultiFeature", feature)) {
|
|
3434
|
+
feature.getFeatures().forEach(subFeature => {
|
|
3435
|
+
this.addFeature(subFeature);
|
|
3719
3436
|
subFeature.properties = feature.properties;
|
|
3720
3437
|
createdFeatures.push(subFeature.toGeoJSON());
|
|
3721
|
-
|
|
3722
|
-
_this6.select([subFeature.id]);
|
|
3438
|
+
this.select([subFeature.id]);
|
|
3723
3439
|
});
|
|
3724
|
-
|
|
3725
|
-
_this6.deleteFeature(feature.id, {
|
|
3440
|
+
this.deleteFeature(feature.id, {
|
|
3726
3441
|
silent: true
|
|
3727
3442
|
});
|
|
3728
|
-
|
|
3729
3443
|
featuresUncombined.push(feature.toGeoJSON());
|
|
3730
3444
|
}
|
|
3731
|
-
};
|
|
3732
|
-
|
|
3733
|
-
for (var i = 0; i < selectedFeatures.length; i++) {
|
|
3734
|
-
_loop(i);
|
|
3735
3445
|
}
|
|
3736
3446
|
|
|
3737
3447
|
if (createdFeatures.length > 1) {
|
|
3738
3448
|
this.map.fire(events.UNCOMBINE_FEATURES, {
|
|
3739
|
-
createdFeatures
|
|
3449
|
+
createdFeatures,
|
|
3740
3450
|
deletedFeatures: featuresUncombined
|
|
3741
3451
|
});
|
|
3742
3452
|
}
|
|
@@ -3744,13 +3454,13 @@ CustomSelectMode.onUncombineFeatures = function () {
|
|
|
3744
3454
|
this.fireActionable();
|
|
3745
3455
|
};
|
|
3746
3456
|
|
|
3747
|
-
|
|
3748
|
-
getMatchingVertices:
|
|
3457
|
+
const drawUtils = {
|
|
3458
|
+
getMatchingVertices: (vertex, featureId, allFeatures, map) => {
|
|
3749
3459
|
// number of decimals should probably be dynamic depending on zoom level
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3460
|
+
let decimals = 5;
|
|
3461
|
+
let matchingVertices = [];
|
|
3462
|
+
let v_lng = vertex[0].toFixed(decimals);
|
|
3463
|
+
let v_lat = vertex[1].toFixed(decimals);
|
|
3754
3464
|
|
|
3755
3465
|
for (var i = 0; i < allFeatures.length; i++) {
|
|
3756
3466
|
if (allFeatures[i].id !== featureId) {
|
|
@@ -3772,7 +3482,7 @@ var drawUtils = {
|
|
|
3772
3482
|
|
|
3773
3483
|
return matchingVertices;
|
|
3774
3484
|
},
|
|
3775
|
-
getDrawInstance:
|
|
3485
|
+
getDrawInstance: map => {
|
|
3776
3486
|
for (var i = map._controls.length - 1; i >= 0; i--) {
|
|
3777
3487
|
if (map._controls[i].options && map._controls[i].options.defaultMode === "custom_select") {
|
|
3778
3488
|
return map._controls[i];
|
|
@@ -3783,16 +3493,14 @@ var drawUtils = {
|
|
|
3783
3493
|
}
|
|
3784
3494
|
};
|
|
3785
3495
|
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3496
|
+
const isVertex$1 = isOfMetaType(meta.VERTEX);
|
|
3497
|
+
const isMidpoint = isOfMetaType(meta.MIDPOINT);
|
|
3498
|
+
const DirectSelect = {}; // INTERNAL FUCNTIONS
|
|
3789
3499
|
|
|
3790
3500
|
DirectSelect.fireUpdate = function () {
|
|
3791
3501
|
this.map.fire(events.UPDATE, {
|
|
3792
3502
|
action: updateActions.CHANGE_COORDINATES,
|
|
3793
|
-
features: this.getSelected().map(
|
|
3794
|
-
return f.toGeoJSON();
|
|
3795
|
-
})
|
|
3503
|
+
features: this.getSelected().map(f => f.toGeoJSON())
|
|
3796
3504
|
});
|
|
3797
3505
|
};
|
|
3798
3506
|
|
|
@@ -3819,8 +3527,8 @@ DirectSelect.stopDragging = function (state) {
|
|
|
3819
3527
|
|
|
3820
3528
|
DirectSelect.onVertex = function (state, e) {
|
|
3821
3529
|
this.startDragging(state, e);
|
|
3822
|
-
|
|
3823
|
-
|
|
3530
|
+
const about = e.featureTarget.properties;
|
|
3531
|
+
const selectedIndex = state.selectedCoordPaths.indexOf(about.coord_path);
|
|
3824
3532
|
|
|
3825
3533
|
if (!isShiftDown(e) && selectedIndex === -1) {
|
|
3826
3534
|
state.selectedCoordPaths = [about.coord_path];
|
|
@@ -3829,33 +3537,31 @@ DirectSelect.onVertex = function (state, e) {
|
|
|
3829
3537
|
} // currently this work with single selected vertices only
|
|
3830
3538
|
|
|
3831
3539
|
|
|
3832
|
-
|
|
3833
|
-
|
|
3540
|
+
let allFeatures = drawUtils.getDrawInstance(this.map).getAll();
|
|
3541
|
+
let matchingVertices = drawUtils.getMatchingVertices(e.featureTarget._geometry.coordinates, e.featureTarget.properties.parent, allFeatures.features, this.map);
|
|
3834
3542
|
state.groupMove_vertices = matchingVertices;
|
|
3835
3543
|
|
|
3836
|
-
for (
|
|
3544
|
+
for (let i = 0; i < state.groupMove_vertices.length; i++) {
|
|
3837
3545
|
state.groupMove_vertices[i].feature = this.getFeature(state.groupMove_vertices[i].featureId);
|
|
3838
3546
|
}
|
|
3839
3547
|
|
|
3840
|
-
|
|
3548
|
+
const selectedCoordinates = this.pathsToCoordinates(state.featureId, state.selectedCoordPaths);
|
|
3841
3549
|
this.setSelectedCoordinates(selectedCoordinates);
|
|
3842
3550
|
};
|
|
3843
3551
|
|
|
3844
3552
|
DirectSelect.onMidpoint = function (state, e) {
|
|
3845
3553
|
this.startDragging(state, e);
|
|
3846
|
-
|
|
3554
|
+
const about = e.featureTarget.properties;
|
|
3847
3555
|
state.feature.addCoordinate(about.coord_path, about.lng, about.lat);
|
|
3848
3556
|
this.fireUpdate();
|
|
3849
3557
|
state.selectedCoordPaths = [about.coord_path];
|
|
3850
3558
|
};
|
|
3851
3559
|
|
|
3852
3560
|
DirectSelect.pathsToCoordinates = function (featureId, paths) {
|
|
3853
|
-
return paths.map(
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
};
|
|
3858
|
-
});
|
|
3561
|
+
return paths.map(coord_path => ({
|
|
3562
|
+
feature_id: featureId,
|
|
3563
|
+
coord_path
|
|
3564
|
+
}));
|
|
3859
3565
|
};
|
|
3860
3566
|
|
|
3861
3567
|
DirectSelect.onFeature = function (state, e) {
|
|
@@ -3868,30 +3574,26 @@ DirectSelect.dragFeature = function (state, e, delta) {
|
|
|
3868
3574
|
};
|
|
3869
3575
|
|
|
3870
3576
|
DirectSelect.dragVertex = function (state, e, delta) {
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
type: geojsonTypes.
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
}
|
|
3882
|
-
};
|
|
3883
|
-
});
|
|
3884
|
-
var constrainedDelta = constrain_feature_movement(selectedCoordPoints, delta);
|
|
3577
|
+
const selectedCoords = state.selectedCoordPaths.map(coord_path => state.feature.getCoordinate(coord_path));
|
|
3578
|
+
const selectedCoordPoints = selectedCoords.map(coords => ({
|
|
3579
|
+
type: geojsonTypes.FEATURE,
|
|
3580
|
+
properties: {},
|
|
3581
|
+
geometry: {
|
|
3582
|
+
type: geojsonTypes.POINT,
|
|
3583
|
+
coordinates: coords
|
|
3584
|
+
}
|
|
3585
|
+
}));
|
|
3586
|
+
const constrainedDelta = constrain_feature_movement(selectedCoordPoints, delta);
|
|
3885
3587
|
|
|
3886
|
-
for (
|
|
3887
|
-
|
|
3588
|
+
for (let i = 0; i < selectedCoords.length; i++) {
|
|
3589
|
+
const coord = selectedCoords[i];
|
|
3888
3590
|
state.feature.updateCoordinate(state.selectedCoordPaths[i], coord[0] + constrainedDelta.lng, coord[1] + constrainedDelta.lat);
|
|
3889
3591
|
|
|
3890
|
-
for (
|
|
3891
|
-
|
|
3592
|
+
for (let k = 0; k < state.groupMove_vertices.length; k++) {
|
|
3593
|
+
let coord_path_m = state.groupMove_vertices[k].coord_path.split(".");
|
|
3892
3594
|
|
|
3893
3595
|
if (typeof coord_path_m[0] !== "undefined" && typeof coord_path_m[1] !== "undefined" && typeof state.groupMove_vertices[k].feature.coordinates[coord_path_m[0]] !== "undefined" && typeof state.groupMove_vertices[k].feature.coordinates[coord_path_m[0]][coord_path_m[1]] !== "undefined") {
|
|
3894
|
-
|
|
3596
|
+
let coord_m = state.groupMove_vertices[k].feature.coordinates[coord_path_m[0]][coord_path_m[1]];
|
|
3895
3597
|
state.groupMove_vertices[k].feature.updateCoordinate(state.groupMove_vertices[k].coord_path, coord_m[0] + constrainedDelta.lng, coord_m[1] + constrainedDelta.lat);
|
|
3896
3598
|
}
|
|
3897
3599
|
}
|
|
@@ -3914,8 +3616,8 @@ DirectSelect.clickActiveFeature = function (state) {
|
|
|
3914
3616
|
|
|
3915
3617
|
|
|
3916
3618
|
DirectSelect.onSetup = function (opts) {
|
|
3917
|
-
|
|
3918
|
-
|
|
3619
|
+
const featureId = opts.featureId;
|
|
3620
|
+
const feature = this.getFeature(featureId);
|
|
3919
3621
|
|
|
3920
3622
|
if (!feature) {
|
|
3921
3623
|
throw new Error("You must provide a featureId to enter direct_select mode");
|
|
@@ -3925,9 +3627,9 @@ DirectSelect.onSetup = function (opts) {
|
|
|
3925
3627
|
throw new TypeError("direct_select mode doesn't handle point features");
|
|
3926
3628
|
}
|
|
3927
3629
|
|
|
3928
|
-
|
|
3929
|
-
featureId
|
|
3930
|
-
feature
|
|
3630
|
+
const state = {
|
|
3631
|
+
featureId,
|
|
3632
|
+
feature,
|
|
3931
3633
|
dragMoveLocation: opts.startPos || null,
|
|
3932
3634
|
dragMoving: false,
|
|
3933
3635
|
canDragMove: false,
|
|
@@ -3968,13 +3670,9 @@ DirectSelect.toDisplayFeatures = function (state, geojson, push) {
|
|
|
3968
3670
|
DirectSelect.onTrash = function (state) {
|
|
3969
3671
|
// Uses number-aware sorting to make sure '9' < '10'. Comparison is reversed because we want them
|
|
3970
3672
|
// in reverse order so that we can remove by index safely.
|
|
3971
|
-
state.selectedCoordPaths.sort(
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
});
|
|
3975
|
-
}).forEach(function (id) {
|
|
3976
|
-
return state.feature.removeCoordinate(id);
|
|
3977
|
-
});
|
|
3673
|
+
state.selectedCoordPaths.sort((a, b) => b.localeCompare(a, "en", {
|
|
3674
|
+
numeric: true
|
|
3675
|
+
})).forEach(id => state.feature.removeCoordinate(id));
|
|
3978
3676
|
this.fireUpdate();
|
|
3979
3677
|
state.selectedCoordPaths = [];
|
|
3980
3678
|
this.clearSelectedCoordinates();
|
|
@@ -3988,9 +3686,9 @@ DirectSelect.onTrash = function (state) {
|
|
|
3988
3686
|
|
|
3989
3687
|
DirectSelect.onMouseMove = function (state, e) {
|
|
3990
3688
|
// On mousemove that is not a drag, stop vertex movement.
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3689
|
+
const isFeature = isActiveFeature(e);
|
|
3690
|
+
const onVertex = isVertex$1(e);
|
|
3691
|
+
const noCoords = state.selectedCoordPaths.length === 0;
|
|
3994
3692
|
if (isFeature && noCoords) this.updateUIClasses({
|
|
3995
3693
|
mouse: cursors.MOVE
|
|
3996
3694
|
});else if (onVertex && !noCoords) this.updateUIClasses({
|
|
@@ -4016,7 +3714,7 @@ DirectSelect.onDrag = function (state, e) {
|
|
|
4016
3714
|
if (state.canDragMove !== true) return;
|
|
4017
3715
|
state.dragMoving = true;
|
|
4018
3716
|
e.originalEvent.stopPropagation();
|
|
4019
|
-
|
|
3717
|
+
const delta = {
|
|
4020
3718
|
lng: e.lngLat.lng - state.dragMoveLocation.lng,
|
|
4021
3719
|
lat: e.lngLat.lat - state.dragMoveLocation.lat
|
|
4022
3720
|
};
|
|
@@ -4046,38 +3744,26 @@ DirectSelect.onTouchEnd = DirectSelect.onMouseUp = function (state) {
|
|
|
4046
3744
|
};
|
|
4047
3745
|
|
|
4048
3746
|
function MlFeatureEditor(props) {
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
var _useState3 = useState(false),
|
|
4061
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
4062
|
-
drawToolsReady = _useState4[0],
|
|
4063
|
-
setDrawToolsReady = _useState4[1];
|
|
4064
|
-
|
|
4065
|
-
var _useState5 = useState(false),
|
|
4066
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
4067
|
-
mouseUpTrigger = _useState6[0],
|
|
4068
|
-
setMouseUpTrigger = _useState6[1];
|
|
4069
|
-
|
|
4070
|
-
var modeChangeHandler = function modeChangeHandler(e) {
|
|
3747
|
+
const mapRef = useRef(null);
|
|
3748
|
+
const draw = useRef(null);
|
|
3749
|
+
const mapContext = useContext(MapContext);
|
|
3750
|
+
const componentId = useRef((props.idPrefix ? props.idPrefix : "MlFeatureEditor-") + v4());
|
|
3751
|
+
const onChangeRef = useRef(props.onChange);
|
|
3752
|
+
const [drawToolsInitialized, setDrawToolsInitialized] = useState(false);
|
|
3753
|
+
const [drawToolsReady, setDrawToolsReady] = useState(false);
|
|
3754
|
+
const [mouseUpTrigger, setMouseUpTrigger] = useState(false);
|
|
3755
|
+
|
|
3756
|
+
const modeChangeHandler = e => {
|
|
4071
3757
|
console.log("MlFeatureEditor mode change to " + e.mode); //setDrawMode(e.mode);
|
|
4072
3758
|
};
|
|
4073
3759
|
|
|
4074
|
-
|
|
3760
|
+
const mouseUpHandler = () => {
|
|
4075
3761
|
setMouseUpTrigger(Math.random());
|
|
4076
3762
|
};
|
|
4077
3763
|
|
|
4078
|
-
useEffect(
|
|
4079
|
-
|
|
4080
|
-
return
|
|
3764
|
+
useEffect(() => {
|
|
3765
|
+
let _componentId = componentId.current;
|
|
3766
|
+
return () => {
|
|
4081
3767
|
if (mapRef.current) {
|
|
4082
3768
|
mapRef.current.cleanup(_componentId); //mapRef.current.removeControl(draw.current, "top-left");
|
|
4083
3769
|
|
|
@@ -4085,7 +3771,7 @@ function MlFeatureEditor(props) {
|
|
|
4085
3771
|
}
|
|
4086
3772
|
};
|
|
4087
3773
|
}, []);
|
|
4088
|
-
useEffect(
|
|
3774
|
+
useEffect(() => {
|
|
4089
3775
|
if (mapContext.mapExists(props.mapId) && mapContext.getMap(props.mapId).style && !drawToolsInitialized) {
|
|
4090
3776
|
mapRef.current = mapContext.getMap(props.mapId);
|
|
4091
3777
|
setDrawToolsInitialized(true);
|
|
@@ -4110,7 +3796,7 @@ function MlFeatureEditor(props) {
|
|
|
4110
3796
|
setDrawToolsReady(true);
|
|
4111
3797
|
}
|
|
4112
3798
|
}, [mapContext.map, mapContext, props, drawToolsInitialized]);
|
|
4113
|
-
useEffect(
|
|
3799
|
+
useEffect(() => {
|
|
4114
3800
|
if (draw.current && props.geojson && props.geojson.geometry && props.geojson.geometry.coordinates) {
|
|
4115
3801
|
draw.current.set({
|
|
4116
3802
|
type: "FeatureCollection",
|
|
@@ -4118,17 +3804,17 @@ function MlFeatureEditor(props) {
|
|
|
4118
3804
|
});
|
|
4119
3805
|
}
|
|
4120
3806
|
}, [props.geojson, drawToolsReady]);
|
|
4121
|
-
useEffect(
|
|
3807
|
+
useEffect(() => {
|
|
4122
3808
|
if (draw.current && mouseUpTrigger) {
|
|
4123
3809
|
// update drawnFeatures state object
|
|
4124
|
-
|
|
3810
|
+
let currentFeatureCollection = draw.current.getAll();
|
|
4125
3811
|
|
|
4126
3812
|
if (typeof onChangeRef.current === "function") {
|
|
4127
3813
|
onChangeRef.current(currentFeatureCollection.features);
|
|
4128
3814
|
}
|
|
4129
3815
|
}
|
|
4130
3816
|
}, [mouseUpTrigger]);
|
|
4131
|
-
useEffect(
|
|
3817
|
+
useEffect(() => {
|
|
4132
3818
|
if (props.mode && draw.current) {
|
|
4133
3819
|
draw.current.changeMode(props.mode);
|
|
4134
3820
|
}
|
|
@@ -4136,14 +3822,14 @@ function MlFeatureEditor(props) {
|
|
|
4136
3822
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
|
|
4137
3823
|
}
|
|
4138
3824
|
|
|
4139
|
-
|
|
3825
|
+
const MlBasicComponent = props => {
|
|
4140
3826
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
4141
3827
|
// without the requirement of adding it to the dependency list (ignore the false eslint exhaustive deps warning)
|
|
4142
3828
|
// const layerRef = useRef(null);
|
|
4143
|
-
|
|
4144
|
-
useEffect(
|
|
3829
|
+
const mapContext = useContext(MapContext);
|
|
3830
|
+
useEffect(() => {
|
|
4145
3831
|
if (!mapContext.mapExists()) return;
|
|
4146
|
-
return
|
|
3832
|
+
return () => {
|
|
4147
3833
|
// This is the cleanup function, it is called when this react component is removed from react-dom
|
|
4148
3834
|
// try to remove anything this component has added to the MapLibre-gl instance
|
|
4149
3835
|
// e.g.: remove the layer
|
|
@@ -4153,7 +3839,7 @@ var MlBasicComponent = function MlBasicComponent(props) {
|
|
|
4153
3839
|
}
|
|
4154
3840
|
};
|
|
4155
3841
|
});
|
|
4156
|
-
useEffect(
|
|
3842
|
+
useEffect(() => {
|
|
4157
3843
|
if (!mapContext.mapExists(props.mapId)) return; // the MapLibre-gl instance (mapContext.map) is accessible here
|
|
4158
3844
|
// initialize the layer and add it to the MapLibre-gl instance
|
|
4159
3845
|
|
|
@@ -4172,32 +3858,17 @@ var MlBasicComponent = function MlBasicComponent(props) {
|
|
|
4172
3858
|
* @component
|
|
4173
3859
|
*/
|
|
4174
3860
|
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
var _useState3 = useState(50),
|
|
4188
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
4189
|
-
swipeY = _useState4[0],
|
|
4190
|
-
setSwipeY = _useState4[1];
|
|
4191
|
-
|
|
4192
|
-
var swipeYRef = useRef(50);
|
|
4193
|
-
var magnifierRadiusRef = useRef(props.magnifierRadius);
|
|
4194
|
-
|
|
4195
|
-
var _useState5 = useState(magnifierRadiusRef.current),
|
|
4196
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
4197
|
-
magnifierRadius = _useState6[0],
|
|
4198
|
-
setMagnifierRadius = _useState6[1];
|
|
4199
|
-
|
|
4200
|
-
var mapExists = useCallback(function () {
|
|
3861
|
+
const MlLayerMagnify = props => {
|
|
3862
|
+
const mapContext = useContext(MapContext);
|
|
3863
|
+
const syncMoveInitializedRef = useRef(false);
|
|
3864
|
+
const syncCleanupFunctionRef = useRef(null);
|
|
3865
|
+
const [swipeX, setSwipeX] = useState(50);
|
|
3866
|
+
const swipeXRef = useRef(50);
|
|
3867
|
+
const [swipeY, setSwipeY] = useState(50);
|
|
3868
|
+
const swipeYRef = useRef(50);
|
|
3869
|
+
const magnifierRadiusRef = useRef(props.magnifierRadius);
|
|
3870
|
+
const [magnifierRadius, setMagnifierRadius] = useState(magnifierRadiusRef.current);
|
|
3871
|
+
const mapExists = useCallback(() => {
|
|
4201
3872
|
if (!props.map1Id || !props.map2Id) {
|
|
4202
3873
|
return false;
|
|
4203
3874
|
}
|
|
@@ -4208,17 +3879,17 @@ var MlLayerMagnify = function MlLayerMagnify(props) {
|
|
|
4208
3879
|
|
|
4209
3880
|
return true;
|
|
4210
3881
|
}, [props, mapContext]);
|
|
4211
|
-
|
|
3882
|
+
const onResize = useRef(() => {
|
|
4212
3883
|
if (!mapExists()) return;
|
|
4213
3884
|
onMove({
|
|
4214
3885
|
clientX: swipeXRef.current,
|
|
4215
3886
|
clientY: swipeYRef.current
|
|
4216
3887
|
});
|
|
4217
3888
|
});
|
|
4218
|
-
useEffect(
|
|
3889
|
+
useEffect(() => {
|
|
4219
3890
|
window.addEventListener("resize", onResize.current);
|
|
4220
|
-
|
|
4221
|
-
return
|
|
3891
|
+
let _onResize = onResize.current;
|
|
3892
|
+
return () => {
|
|
4222
3893
|
window.removeEventListener("resize", _onResize);
|
|
4223
3894
|
|
|
4224
3895
|
if (syncCleanupFunctionRef.current) {
|
|
@@ -4226,15 +3897,15 @@ var MlLayerMagnify = function MlLayerMagnify(props) {
|
|
|
4226
3897
|
}
|
|
4227
3898
|
};
|
|
4228
3899
|
}, []);
|
|
4229
|
-
|
|
3900
|
+
const onMove = useCallback(e => {
|
|
4230
3901
|
if (!mapExists()) return;
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
3902
|
+
let bounds = mapContext.maps[props.map1Id].getCanvas().getBoundingClientRect();
|
|
3903
|
+
let clientX = e.clientX || (typeof e.touches !== "undefined" && typeof e.touches[0] !== "undefined" ? e.touches[0].clientX : 0);
|
|
3904
|
+
let clientY = e.clientY || (typeof e.touches !== "undefined" && typeof e.touches[0] !== "undefined" ? e.touches[0].clientY : 0);
|
|
4234
3905
|
clientX -= bounds.x;
|
|
4235
3906
|
clientY -= bounds.y;
|
|
4236
|
-
|
|
4237
|
-
|
|
3907
|
+
let swipeX_tmp = (clientX / bounds.width * 100).toFixed(2);
|
|
3908
|
+
let swipeY_tmp = (clientY / bounds.height * 100).toFixed(2);
|
|
4238
3909
|
|
|
4239
3910
|
if (swipeXRef.current !== swipeX_tmp || swipeYRef.current !== swipeY_tmp) {
|
|
4240
3911
|
setSwipeX(swipeX_tmp);
|
|
@@ -4244,7 +3915,7 @@ var MlLayerMagnify = function MlLayerMagnify(props) {
|
|
|
4244
3915
|
mapContext.maps[props.map2Id].getContainer().style.clipPath = "circle(".concat(magnifierRadiusRef.current, "px at ") + swipeXRef.current * bounds.width / 100 + "px " + swipeYRef.current * bounds.height / 100 + "px)";
|
|
4245
3916
|
}
|
|
4246
3917
|
}, [mapContext, mapExists, props]);
|
|
4247
|
-
useEffect(
|
|
3918
|
+
useEffect(() => {
|
|
4248
3919
|
if (!mapExists() || syncMoveInitializedRef.current) return;
|
|
4249
3920
|
syncMoveInitializedRef.current = true;
|
|
4250
3921
|
syncCleanupFunctionRef.current = syncMove(mapContext.getMap(props.map1Id).map, mapContext.getMap(props.map2Id).map);
|
|
@@ -4265,7 +3936,7 @@ var MlLayerMagnify = function MlLayerMagnify(props) {
|
|
|
4265
3936
|
});
|
|
4266
3937
|
}, [mapContext.mapIds, mapContext, mapExists, props, onMove]);
|
|
4267
3938
|
|
|
4268
|
-
|
|
3939
|
+
const onDown = e => {
|
|
4269
3940
|
if (e.touches) {
|
|
4270
3941
|
document.addEventListener("touchmove", onMove);
|
|
4271
3942
|
document.addEventListener("touchend", onTouchEnd);
|
|
@@ -4275,18 +3946,18 @@ var MlLayerMagnify = function MlLayerMagnify(props) {
|
|
|
4275
3946
|
}
|
|
4276
3947
|
};
|
|
4277
3948
|
|
|
4278
|
-
|
|
3949
|
+
const onTouchEnd = () => {
|
|
4279
3950
|
document.removeEventListener("touchmove", onMove);
|
|
4280
3951
|
document.removeEventListener("touchend", onTouchEnd);
|
|
4281
3952
|
};
|
|
4282
3953
|
|
|
4283
|
-
|
|
3954
|
+
const onMouseUp = () => {
|
|
4284
3955
|
document.removeEventListener("mousemove", onMove);
|
|
4285
3956
|
document.removeEventListener("mouseup", onMouseUp);
|
|
4286
3957
|
};
|
|
4287
3958
|
|
|
4288
|
-
|
|
4289
|
-
|
|
3959
|
+
const onWheel = e => {
|
|
3960
|
+
let evCopy = new WheelEvent(e.type, e);
|
|
4290
3961
|
mapContext.map.getCanvas().dispatchEvent(evCopy);
|
|
4291
3962
|
};
|
|
4292
3963
|
|
|
@@ -4343,18 +4014,13 @@ MlLayerMagnify.propTypes = {
|
|
|
4343
4014
|
* @component
|
|
4344
4015
|
*/
|
|
4345
4016
|
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
setSwipeX = _useState2[1];
|
|
4354
|
-
|
|
4355
|
-
var swipeXRef = useRef(50);
|
|
4356
|
-
var syncCleanupFunctionRef = useRef(null);
|
|
4357
|
-
var mapExists = useCallback(function () {
|
|
4017
|
+
const MlLayerSwipe = props => {
|
|
4018
|
+
const mapContext = useContext(MapContext);
|
|
4019
|
+
const initializedRef = useRef(false);
|
|
4020
|
+
const [swipeX, setSwipeX] = useState(50);
|
|
4021
|
+
const swipeXRef = useRef(50);
|
|
4022
|
+
const syncCleanupFunctionRef = useRef(null);
|
|
4023
|
+
const mapExists = useCallback(() => {
|
|
4358
4024
|
if (!props.map1Id || !props.map2Id) {
|
|
4359
4025
|
return false;
|
|
4360
4026
|
}
|
|
@@ -4366,18 +4032,18 @@ var MlLayerSwipe = function MlLayerSwipe(props) {
|
|
|
4366
4032
|
return true;
|
|
4367
4033
|
}, [mapContext, props.map1Id, props.map2Id]);
|
|
4368
4034
|
|
|
4369
|
-
|
|
4035
|
+
const cleanup = () => {
|
|
4370
4036
|
if (syncCleanupFunctionRef.current) {
|
|
4371
4037
|
syncCleanupFunctionRef.current();
|
|
4372
4038
|
}
|
|
4373
4039
|
};
|
|
4374
4040
|
|
|
4375
|
-
|
|
4041
|
+
const onMove = useCallback(e => {
|
|
4376
4042
|
if (!mapExists()) return;
|
|
4377
|
-
|
|
4378
|
-
|
|
4043
|
+
let bounds = mapContext.maps[props.map1Id].getCanvas().getBoundingClientRect();
|
|
4044
|
+
let clientX = e.clientX || (typeof e.touches !== "undefined" && typeof e.touches[0] !== "undefined" ? e.touches[0].clientX : 0);
|
|
4379
4045
|
clientX -= bounds.x;
|
|
4380
|
-
|
|
4046
|
+
let swipeX_tmp = (clientX / bounds.width * 100).toFixed(2);
|
|
4381
4047
|
|
|
4382
4048
|
if (swipeXRef.current !== swipeX_tmp) {
|
|
4383
4049
|
setSwipeX(swipeX_tmp);
|
|
@@ -4386,10 +4052,10 @@ var MlLayerSwipe = function MlLayerSwipe(props) {
|
|
|
4386
4052
|
mapContext.maps[props.map2Id].getContainer().style.clip = clipA;
|
|
4387
4053
|
}
|
|
4388
4054
|
}, [mapContext, mapExists, props.map1Id, props.map2Id]);
|
|
4389
|
-
useEffect(
|
|
4055
|
+
useEffect(() => {
|
|
4390
4056
|
return cleanup;
|
|
4391
4057
|
}, []);
|
|
4392
|
-
useEffect(
|
|
4058
|
+
useEffect(() => {
|
|
4393
4059
|
if (!mapExists() || initializedRef.current) return;
|
|
4394
4060
|
initializedRef.current = true;
|
|
4395
4061
|
syncCleanupFunctionRef.current = syncMove(mapContext.getMap(props.map1Id).map, mapContext.getMap(props.map2Id).map);
|
|
@@ -4398,7 +4064,7 @@ var MlLayerSwipe = function MlLayerSwipe(props) {
|
|
|
4398
4064
|
});
|
|
4399
4065
|
}, [mapContext.mapIds, mapContext, props, onMove, mapExists]);
|
|
4400
4066
|
|
|
4401
|
-
|
|
4067
|
+
const onDown = e => {
|
|
4402
4068
|
if (e.touches) {
|
|
4403
4069
|
document.addEventListener("touchmove", onMove);
|
|
4404
4070
|
document.addEventListener("touchend", onTouchEnd);
|
|
@@ -4408,12 +4074,12 @@ var MlLayerSwipe = function MlLayerSwipe(props) {
|
|
|
4408
4074
|
}
|
|
4409
4075
|
};
|
|
4410
4076
|
|
|
4411
|
-
|
|
4077
|
+
const onTouchEnd = () => {
|
|
4412
4078
|
document.removeEventListener("touchmove", onMove);
|
|
4413
4079
|
document.removeEventListener("touchend", onTouchEnd);
|
|
4414
4080
|
};
|
|
4415
4081
|
|
|
4416
|
-
|
|
4082
|
+
const onMouseUp = () => {
|
|
4417
4083
|
document.removeEventListener("mousemove", onMove);
|
|
4418
4084
|
document.removeEventListener("mouseup", onMouseUp);
|
|
4419
4085
|
};
|
|
@@ -4455,8 +4121,8 @@ MlLayerSwipe.propTypes = {
|
|
|
4455
4121
|
map2Id: PropTypes.string
|
|
4456
4122
|
};
|
|
4457
4123
|
|
|
4458
|
-
|
|
4459
|
-
|
|
4124
|
+
const GeoJsonContext = /*#__PURE__*/React__default.createContext({});
|
|
4125
|
+
const GeoJsonContextProvider = GeoJsonContext.Provider;
|
|
4460
4126
|
|
|
4461
4127
|
/**
|
|
4462
4128
|
* https://github.com/mapbox/togeojson
|
|
@@ -4548,9 +4214,7 @@ var toGeoJSON = function () {
|
|
|
4548
4214
|
|
|
4549
4215
|
|
|
4550
4216
|
function extend(x, y) {
|
|
4551
|
-
for (var k in y)
|
|
4552
|
-
x[k] = y[k];
|
|
4553
|
-
}
|
|
4217
|
+
for (var k in y) x[k] = y[k];
|
|
4554
4218
|
} // get one coordinate from a coordinate array, if any
|
|
4555
4219
|
|
|
4556
4220
|
|
|
@@ -4607,10 +4271,10 @@ var toGeoJSON = function () {
|
|
|
4607
4271
|
/* istanbul ignore next */
|
|
4608
4272
|
serializer = new XMLSerializer();
|
|
4609
4273
|
} else {
|
|
4610
|
-
var isNodeEnv =
|
|
4611
|
-
var isTitaniumEnv =
|
|
4274
|
+
var isNodeEnv = typeof process === "object" && !process.browser;
|
|
4275
|
+
var isTitaniumEnv = typeof Titanium === "object";
|
|
4612
4276
|
|
|
4613
|
-
if (
|
|
4277
|
+
if (typeof exports === "object" && (isNodeEnv || isTitaniumEnv)) {
|
|
4614
4278
|
serializer = new (require("xmldom").XMLSerializer)();
|
|
4615
4279
|
} else {
|
|
4616
4280
|
throw new Error("Unable to initialize serializer");
|
|
@@ -4627,7 +4291,7 @@ var toGeoJSON = function () {
|
|
|
4627
4291
|
}
|
|
4628
4292
|
|
|
4629
4293
|
var t = {
|
|
4630
|
-
kml: function
|
|
4294
|
+
kml: function (doc) {
|
|
4631
4295
|
var gj = fc(),
|
|
4632
4296
|
// styleindex keeps track of hashed styles in order to match features
|
|
4633
4297
|
styleIndex = {},
|
|
@@ -4694,15 +4358,11 @@ var toGeoJSON = function () {
|
|
|
4694
4358
|
times = [];
|
|
4695
4359
|
if (elems.length === 0) elems = get(root, "gx:coord");
|
|
4696
4360
|
|
|
4697
|
-
for (var i = 0; i < elems.length; i++)
|
|
4698
|
-
coords.push(gxCoord(nodeVal(elems[i])));
|
|
4699
|
-
}
|
|
4361
|
+
for (var i = 0; i < elems.length; i++) coords.push(gxCoord(nodeVal(elems[i])));
|
|
4700
4362
|
|
|
4701
4363
|
var timeElems = get(root, "when");
|
|
4702
4364
|
|
|
4703
|
-
for (var j = 0; j < timeElems.length; j++)
|
|
4704
|
-
times.push(nodeVal(timeElems[j]));
|
|
4705
|
-
}
|
|
4365
|
+
for (var j = 0; j < timeElems.length; j++) times.push(nodeVal(timeElems[j]));
|
|
4706
4366
|
|
|
4707
4367
|
return {
|
|
4708
4368
|
coords: coords,
|
|
@@ -4903,7 +4563,7 @@ var toGeoJSON = function () {
|
|
|
4903
4563
|
|
|
4904
4564
|
return gj;
|
|
4905
4565
|
},
|
|
4906
|
-
gpx: function
|
|
4566
|
+
gpx: function (doc) {
|
|
4907
4567
|
var i,
|
|
4908
4568
|
tracks = get(doc, "trk"),
|
|
4909
4569
|
routes = get(doc, "rte"),
|
|
@@ -5082,41 +4742,27 @@ var toGeoJSON = function () {
|
|
|
5082
4742
|
* @component
|
|
5083
4743
|
*/
|
|
5084
4744
|
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
4745
|
+
const MlGPXViewer = props => {
|
|
4746
|
+
const dataSource = useContext(GeoJsonContext);
|
|
4747
|
+
const initializedRef = useRef(false);
|
|
4748
|
+
const mapHook = useMap({
|
|
5089
4749
|
mapId: props.mapId,
|
|
5090
4750
|
waitForLayer: props.insertBeforeLayer
|
|
5091
4751
|
});
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
var _useState3 = useState(0),
|
|
5104
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
5105
|
-
zIndex = _useState4[0],
|
|
5106
|
-
setZIndex = _useState4[1];
|
|
5107
|
-
|
|
5108
|
-
var _useState5 = useState([]),
|
|
5109
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
5110
|
-
metaData = _useState6[0],
|
|
5111
|
-
setMetaData = _useState6[1];
|
|
5112
|
-
|
|
5113
|
-
var fileupload = useRef(null);
|
|
5114
|
-
var mediaIsMobile = useMediaQuery("(max-width:900px)");
|
|
5115
|
-
var popup = useRef(new Popup({
|
|
4752
|
+
const sourceName = "import-source";
|
|
4753
|
+
const layerNameLines = "importer-layer-lines";
|
|
4754
|
+
const layerNamePoints = "importer-layer-points";
|
|
4755
|
+
const [open, setIsOpen] = useState(false);
|
|
4756
|
+
const dropZone = useRef(null);
|
|
4757
|
+
const [zIndex, setZIndex] = useState(0);
|
|
4758
|
+
const [metaData, setMetaData] = useState([]);
|
|
4759
|
+
const fileupload = useRef(null);
|
|
4760
|
+
const mediaIsMobile = useMediaQuery("(max-width:900px)");
|
|
4761
|
+
const popup = useRef(new Popup({
|
|
5116
4762
|
closeButton: false,
|
|
5117
4763
|
closeOnClick: true
|
|
5118
4764
|
}));
|
|
5119
|
-
useEffect(
|
|
4765
|
+
useEffect(() => {
|
|
5120
4766
|
if (!mapHook.map || initializedRef.current) return;
|
|
5121
4767
|
initializedRef.current = true;
|
|
5122
4768
|
mapHook.map.addSource(sourceName, {
|
|
@@ -5142,14 +4788,14 @@ var MlGPXViewer = function MlGPXViewer(props) {
|
|
|
5142
4788
|
},
|
|
5143
4789
|
filter: ["==", "$type", "Point"]
|
|
5144
4790
|
}, props.insertBeforeLayer, mapHook.componentId);
|
|
5145
|
-
[layerNameLines, layerNamePoints].forEach(
|
|
4791
|
+
[layerNameLines, layerNamePoints].forEach(layerName => {
|
|
5146
4792
|
mapHook.map.setLayoutProperty(layerName, "visibility", "visible");
|
|
5147
4793
|
});
|
|
5148
|
-
mapHook.map.on("mouseenter", layerNamePoints,
|
|
4794
|
+
mapHook.map.on("mouseenter", layerNamePoints, e => {
|
|
5149
4795
|
// Change the cursor style as a UI indicator.
|
|
5150
|
-
|
|
4796
|
+
const coordinates = e.features[0].geometry.coordinates.slice(); //const description = e.features[0].properties.desc;
|
|
5151
4797
|
|
|
5152
|
-
|
|
4798
|
+
const name = e.features[0].properties.name; // Ensure that if the map is zoomed out such that multiple
|
|
5153
4799
|
// copies of the feature are visible, the popup appears
|
|
5154
4800
|
// over the copy being pointed to.
|
|
5155
4801
|
|
|
@@ -5167,19 +4813,19 @@ var MlGPXViewer = function MlGPXViewer(props) {
|
|
|
5167
4813
|
}, mapHook.componentId);
|
|
5168
4814
|
mapHook.map.setZoom(10);
|
|
5169
4815
|
}, [mapHook.map]);
|
|
5170
|
-
useEffect(
|
|
5171
|
-
|
|
4816
|
+
useEffect(() => {
|
|
4817
|
+
const dropZoneCurrent = dropZone.current;
|
|
5172
4818
|
|
|
5173
|
-
|
|
4819
|
+
const raiseDropZoneAndStopDefault = event => {
|
|
5174
4820
|
setZIndex(1000);
|
|
5175
4821
|
stopDefault(event);
|
|
5176
4822
|
};
|
|
5177
4823
|
|
|
5178
|
-
|
|
4824
|
+
const lowerDropZone = () => {
|
|
5179
4825
|
setZIndex(0);
|
|
5180
4826
|
};
|
|
5181
4827
|
|
|
5182
|
-
|
|
4828
|
+
const lowerDropZoneAndStopDefault = event => {
|
|
5183
4829
|
setZIndex(0);
|
|
5184
4830
|
stopDefault(event);
|
|
5185
4831
|
};
|
|
@@ -5188,7 +4834,7 @@ var MlGPXViewer = function MlGPXViewer(props) {
|
|
|
5188
4834
|
window.addEventListener("dragover", stopDefault);
|
|
5189
4835
|
dropZoneCurrent.addEventListener("dragleave", lowerDropZone);
|
|
5190
4836
|
window.addEventListener("drop", lowerDropZoneAndStopDefault);
|
|
5191
|
-
return
|
|
4837
|
+
return () => {
|
|
5192
4838
|
window.removeEventListener("dragenter", raiseDropZoneAndStopDefault);
|
|
5193
4839
|
window.removeEventListener("dragover", stopDefault);
|
|
5194
4840
|
dropZoneCurrent.removeEventListener("dragleave", lowerDropZone);
|
|
@@ -5196,20 +4842,20 @@ var MlGPXViewer = function MlGPXViewer(props) {
|
|
|
5196
4842
|
};
|
|
5197
4843
|
});
|
|
5198
4844
|
|
|
5199
|
-
|
|
4845
|
+
const stopDefault = event => {
|
|
5200
4846
|
event.preventDefault();
|
|
5201
4847
|
event.stopPropagation();
|
|
5202
4848
|
};
|
|
5203
4849
|
|
|
5204
|
-
useEffect(
|
|
4850
|
+
useEffect(() => {
|
|
5205
4851
|
if (!mapHook.map) return;
|
|
5206
|
-
|
|
5207
|
-
[layerNameLines, layerNamePoints].forEach(
|
|
4852
|
+
const visibility = props.visible ? "visible" : "none";
|
|
4853
|
+
[layerNameLines, layerNamePoints].forEach(layerName => {
|
|
5208
4854
|
mapHook.map.setLayoutProperty(layerName, "visibility", visibility);
|
|
5209
4855
|
});
|
|
5210
4856
|
}, [props.visible]);
|
|
5211
4857
|
|
|
5212
|
-
|
|
4858
|
+
const dropHandler = event => {
|
|
5213
4859
|
event.preventDefault();
|
|
5214
4860
|
|
|
5215
4861
|
if (event.dataTransfer.items) {
|
|
@@ -5219,74 +4865,70 @@ var MlGPXViewer = function MlGPXViewer(props) {
|
|
|
5219
4865
|
|
|
5220
4866
|
|
|
5221
4867
|
if (event.dataTransfer.items[0].kind === "file") {
|
|
5222
|
-
|
|
4868
|
+
const reader = new FileReader();
|
|
5223
4869
|
|
|
5224
|
-
reader.onload =
|
|
4870
|
+
reader.onload = payload => {
|
|
5225
4871
|
addGPXToMap(payload.currentTarget.result);
|
|
5226
4872
|
};
|
|
5227
4873
|
|
|
5228
|
-
|
|
4874
|
+
const file = event.dataTransfer.items[0].getAsFile();
|
|
5229
4875
|
reader.readAsText(file);
|
|
5230
4876
|
}
|
|
5231
4877
|
}
|
|
5232
4878
|
};
|
|
5233
4879
|
|
|
5234
|
-
|
|
4880
|
+
const addGPXToMap = gpxAsString => {
|
|
5235
4881
|
if (!mapHook.map) return;
|
|
5236
4882
|
|
|
5237
4883
|
try {
|
|
5238
4884
|
setMetaData([]);
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
metadata.childNodes.forEach(
|
|
5243
|
-
|
|
5244
|
-
|
|
4885
|
+
const domParser = new DOMParser();
|
|
4886
|
+
const gpxDoc = domParser.parseFromString(gpxAsString, "application/xml");
|
|
4887
|
+
const metadata = gpxDoc.querySelector("metadata");
|
|
4888
|
+
metadata.childNodes.forEach(node => {
|
|
4889
|
+
let value = node.textContent;
|
|
4890
|
+
const title = node.nodeName;
|
|
5245
4891
|
|
|
5246
4892
|
if (node.nodeName === "link") {
|
|
5247
4893
|
value = node.getAttribute("href");
|
|
5248
4894
|
}
|
|
5249
4895
|
|
|
5250
4896
|
if (!!value.trim().length) {
|
|
5251
|
-
|
|
4897
|
+
const metaDatEntry = {
|
|
5252
4898
|
title: title,
|
|
5253
4899
|
value: value,
|
|
5254
4900
|
id: new Date().getTime()
|
|
5255
4901
|
};
|
|
5256
|
-
setMetaData(
|
|
5257
|
-
return [].concat(_toConsumableArray(prevState), [metaDatEntry]);
|
|
5258
|
-
});
|
|
4902
|
+
setMetaData(prevState => [...prevState, metaDatEntry]);
|
|
5259
4903
|
}
|
|
5260
4904
|
});
|
|
5261
|
-
|
|
4905
|
+
const data = toGeoJSON.gpx(gpxDoc);
|
|
5262
4906
|
dataSource.setData(data);
|
|
5263
4907
|
mapHook.map.getSource(sourceName).setData(data);
|
|
5264
|
-
|
|
4908
|
+
const bounds = bbox(data);
|
|
5265
4909
|
mapHook.map.fitBounds(bounds);
|
|
5266
4910
|
} catch (e) {
|
|
5267
4911
|
console.log(e);
|
|
5268
4912
|
}
|
|
5269
4913
|
};
|
|
5270
4914
|
|
|
5271
|
-
|
|
5272
|
-
setIsOpen(
|
|
5273
|
-
return !prevState;
|
|
5274
|
-
});
|
|
4915
|
+
const toogleDrawer = () => {
|
|
4916
|
+
setIsOpen(prevState => !prevState);
|
|
5275
4917
|
};
|
|
5276
4918
|
|
|
5277
|
-
|
|
5278
|
-
|
|
4919
|
+
const fileUploadOnChange = () => {
|
|
4920
|
+
const file = fileupload.current.files[0];
|
|
5279
4921
|
if (!file) return false;
|
|
5280
|
-
|
|
4922
|
+
const reader = new FileReader();
|
|
5281
4923
|
|
|
5282
|
-
reader.onload =
|
|
4924
|
+
reader.onload = payload => {
|
|
5283
4925
|
addGPXToMap(payload.currentTarget.result);
|
|
5284
4926
|
};
|
|
5285
4927
|
|
|
5286
4928
|
reader.readAsText(file);
|
|
5287
4929
|
};
|
|
5288
4930
|
|
|
5289
|
-
|
|
4931
|
+
const manualUpload = () => {
|
|
5290
4932
|
fileupload.current.click();
|
|
5291
4933
|
};
|
|
5292
4934
|
|
|
@@ -5332,13 +4974,11 @@ var MlGPXViewer = function MlGPXViewer(props) {
|
|
|
5332
4974
|
padding: "1em"
|
|
5333
4975
|
},
|
|
5334
4976
|
noWrap: true
|
|
5335
|
-
}, "Informationen zur Route"), /*#__PURE__*/React__default.createElement(Divider, null), /*#__PURE__*/React__default.createElement(List, null, metaData.map(
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
}));
|
|
5341
|
-
}))), /*#__PURE__*/React__default.createElement("div", {
|
|
4977
|
+
}, "Informationen zur Route"), /*#__PURE__*/React__default.createElement(Divider, null), /*#__PURE__*/React__default.createElement(List, null, metaData.map(item => /*#__PURE__*/React__default.createElement(ListItem, {
|
|
4978
|
+
key: "item--".concat(item.id)
|
|
4979
|
+
}, /*#__PURE__*/React__default.createElement(ListItemText, {
|
|
4980
|
+
primary: item.value
|
|
4981
|
+
}))))), /*#__PURE__*/React__default.createElement("div", {
|
|
5342
4982
|
onDrop: dropHandler,
|
|
5343
4983
|
ref: dropZone,
|
|
5344
4984
|
style: {
|
|
@@ -5389,28 +5029,26 @@ MlGPXViewer.propTypes = {
|
|
|
5389
5029
|
insertBeforeLayer: PropTypes.string
|
|
5390
5030
|
};
|
|
5391
5031
|
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5032
|
+
const GeoJsonProvider = _ref => {
|
|
5033
|
+
let {
|
|
5034
|
+
children
|
|
5035
|
+
} = _ref;
|
|
5036
|
+
const [data, setData] = useState({
|
|
5396
5037
|
type: "FeatureCollection",
|
|
5397
5038
|
features: []
|
|
5398
|
-
})
|
|
5399
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
5400
|
-
data = _useState2[0],
|
|
5401
|
-
setData = _useState2[1];
|
|
5039
|
+
});
|
|
5402
5040
|
|
|
5403
|
-
|
|
5041
|
+
const getEmptyFeatureCollection = () => {
|
|
5404
5042
|
return {
|
|
5405
5043
|
type: "FeatureCollection",
|
|
5406
5044
|
features: []
|
|
5407
5045
|
};
|
|
5408
5046
|
};
|
|
5409
5047
|
|
|
5410
|
-
|
|
5411
|
-
data
|
|
5412
|
-
setData
|
|
5413
|
-
getEmptyFeatureCollection
|
|
5048
|
+
const value = {
|
|
5049
|
+
data,
|
|
5050
|
+
setData,
|
|
5051
|
+
getEmptyFeatureCollection
|
|
5414
5052
|
};
|
|
5415
5053
|
return /*#__PURE__*/React__default.createElement(GeoJsonContextProvider, {
|
|
5416
5054
|
value: value
|
|
@@ -5427,31 +5065,31 @@ GeoJsonProvider.propTypes = {
|
|
|
5427
5065
|
* @component
|
|
5428
5066
|
*/
|
|
5429
5067
|
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5068
|
+
const MlSpatialElevationProfile = props => {
|
|
5069
|
+
const mapContext = useContext(MapContext);
|
|
5070
|
+
const componentId = useRef((props.idPrefix ? props.idPrefix : "MlSpatialElevationProfile-") + v4());
|
|
5071
|
+
const mapRef = useRef(null);
|
|
5072
|
+
const initializedRef = useRef(false);
|
|
5073
|
+
const dataSource = useContext(GeoJsonContext);
|
|
5074
|
+
const sourceName = useRef("elevationprofile-" + v4());
|
|
5075
|
+
const layerName = useRef("elevationprofile-layer-" + v4());
|
|
5076
|
+
const createStep = useCallback((x, y, z, x2, y2) => {
|
|
5439
5077
|
//const summand = 0.0002;
|
|
5440
|
-
|
|
5441
|
-
|
|
5078
|
+
const line = lineString([[x, y], [x2, y2]]);
|
|
5079
|
+
const offsetLine = lineOffset(line, 5, {
|
|
5442
5080
|
units: "meters"
|
|
5443
5081
|
});
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5082
|
+
const x3 = offsetLine.geometry.coordinates[0][0];
|
|
5083
|
+
const y3 = offsetLine.geometry.coordinates[0][1];
|
|
5084
|
+
const x4 = offsetLine.geometry.coordinates[1][0];
|
|
5085
|
+
const y4 = offsetLine.geometry.coordinates[1][1];
|
|
5448
5086
|
return polygon([[[x, y], [x2, y2], [x4, y4], [x3, y3], [x, y]]], {
|
|
5449
5087
|
height: z * props.elevationFactor
|
|
5450
5088
|
});
|
|
5451
5089
|
}, [props.elevationFactor]);
|
|
5452
|
-
useEffect(
|
|
5453
|
-
|
|
5454
|
-
return
|
|
5090
|
+
useEffect(() => {
|
|
5091
|
+
let _componentId = componentId.current;
|
|
5092
|
+
return () => {
|
|
5455
5093
|
// This is the cleanup function, it is called when this react component is removed from react-dom
|
|
5456
5094
|
if (mapRef.current) {
|
|
5457
5095
|
mapRef.current.cleanup(_componentId);
|
|
@@ -5459,7 +5097,7 @@ var MlSpatialElevationProfile = function MlSpatialElevationProfile(props) {
|
|
|
5459
5097
|
}
|
|
5460
5098
|
};
|
|
5461
5099
|
}, []);
|
|
5462
|
-
useEffect(
|
|
5100
|
+
useEffect(() => {
|
|
5463
5101
|
if (!mapContext.mapExists(props.mapId) || initializedRef.current) return;
|
|
5464
5102
|
initializedRef.current = true;
|
|
5465
5103
|
mapRef.current = mapContext.getMap(props.mapId);
|
|
@@ -5478,51 +5116,51 @@ var MlSpatialElevationProfile = function MlSpatialElevationProfile(props) {
|
|
|
5478
5116
|
}
|
|
5479
5117
|
}, props.insertBeforeLayer, componentId.current);
|
|
5480
5118
|
}, [mapContext.mapIds, props.insertBeforeLayer, props.mapId, dataSource, mapContext]);
|
|
5481
|
-
useEffect(
|
|
5119
|
+
useEffect(() => {
|
|
5482
5120
|
var _mapRef$current$getSo;
|
|
5483
5121
|
|
|
5484
5122
|
if (!mapRef.current || !mapRef.current.getLayer(layerName.current)) return;
|
|
5485
|
-
|
|
5123
|
+
const {
|
|
5124
|
+
data
|
|
5125
|
+
} = dataSource;
|
|
5486
5126
|
if (!data || !data.features) return;
|
|
5487
|
-
|
|
5127
|
+
const line = data.features.find(element => {
|
|
5488
5128
|
return element.geometry.type === "LineString";
|
|
5489
5129
|
});
|
|
5490
5130
|
if (!line || !line.geometry) return;
|
|
5491
|
-
|
|
5131
|
+
const heights = line.geometry.coordinates.map((coordinate, index) => {
|
|
5492
5132
|
return coordinate[2];
|
|
5493
5133
|
});
|
|
5494
|
-
|
|
5495
|
-
|
|
5134
|
+
const min = Math.min(...heights);
|
|
5135
|
+
let max = Math.max(...heights) - min;
|
|
5496
5136
|
max = max === 0 ? 1 : max;
|
|
5497
5137
|
mapRef.current.setPaintProperty(layerName.current, "fill-extrusion-color", ["interpolate", ["linear"], ["get", "height"], 0, "rgb(0,255,55)", max * props.elevationFactor, "rgb(255,0,0)"]);
|
|
5498
5138
|
|
|
5499
|
-
|
|
5500
|
-
return x * (1 - a) + y * a;
|
|
5501
|
-
};
|
|
5139
|
+
const lerp = (x, y, a) => x * (1 - a) + y * a;
|
|
5502
5140
|
|
|
5503
|
-
|
|
5504
|
-
line.geometry.coordinates.forEach(
|
|
5141
|
+
const points = [];
|
|
5142
|
+
line.geometry.coordinates.forEach((coordinate, index) => {
|
|
5505
5143
|
//const point = createPoint(coordinate[0],coordinate[1],coordinate[2]-min);
|
|
5506
5144
|
//points.push(point);
|
|
5507
5145
|
if (line.geometry.coordinates[index + 1]) {
|
|
5508
|
-
|
|
5146
|
+
const wayLength = distance([coordinate[0], coordinate[1]], [line.geometry.coordinates[index + 1][0], line.geometry.coordinates[index + 1][1]], {
|
|
5509
5147
|
units: "kilometers"
|
|
5510
5148
|
});
|
|
5511
|
-
|
|
5149
|
+
let listLength = ~~(wayLength * 1000 / 10);
|
|
5512
5150
|
listLength = listLength < 1 ? 1 : listLength;
|
|
5513
5151
|
|
|
5514
|
-
for (
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5152
|
+
for (let i = 0; i < listLength; i++) {
|
|
5153
|
+
const x = lerp(line.geometry.coordinates[index][0], line.geometry.coordinates[index + 1][0], i / listLength);
|
|
5154
|
+
const y = lerp(line.geometry.coordinates[index][1], line.geometry.coordinates[index + 1][1], i / listLength);
|
|
5155
|
+
const z = lerp(line.geometry.coordinates[index][2] - min, line.geometry.coordinates[index + 1][2] - min, i / listLength);
|
|
5156
|
+
const x2 = lerp(line.geometry.coordinates[index][0], line.geometry.coordinates[index + 1][0], (i + 1) / listLength);
|
|
5157
|
+
const y2 = lerp(line.geometry.coordinates[index][1], line.geometry.coordinates[index + 1][1], (i + 1) / listLength);
|
|
5158
|
+
const point = createStep(x, y, z, x2, y2);
|
|
5521
5159
|
points.push(point);
|
|
5522
5160
|
}
|
|
5523
5161
|
}
|
|
5524
5162
|
});
|
|
5525
|
-
|
|
5163
|
+
const newData = dataSource.getEmptyFeatureCollection();
|
|
5526
5164
|
newData.features = points;
|
|
5527
5165
|
(_mapRef$current$getSo = mapRef.current.getSource(sourceName.current)) === null || _mapRef$current$getSo === void 0 ? void 0 : _mapRef$current$getSo.setData(newData);
|
|
5528
5166
|
}, [dataSource.data, createStep, dataSource, props.elevationFactor, mapContext]);
|
|
@@ -5555,5 +5193,526 @@ MlSpatialElevationProfile.propTypes = {
|
|
|
5555
5193
|
insertBeforeLayer: PropTypes.string
|
|
5556
5194
|
};
|
|
5557
5195
|
|
|
5558
|
-
|
|
5196
|
+
function _extends$3() {
|
|
5197
|
+
_extends$3 = Object.assign || function (target) {
|
|
5198
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
5199
|
+
var source = arguments[i];
|
|
5200
|
+
|
|
5201
|
+
for (var key in source) {
|
|
5202
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
5203
|
+
target[key] = source[key];
|
|
5204
|
+
}
|
|
5205
|
+
}
|
|
5206
|
+
}
|
|
5207
|
+
|
|
5208
|
+
return target;
|
|
5209
|
+
};
|
|
5210
|
+
|
|
5211
|
+
return _extends$3.apply(this, arguments);
|
|
5212
|
+
}
|
|
5213
|
+
|
|
5214
|
+
const _showNextTransitionSegment = function (props, map, transitionInProgressRef, transitionGeojsonDataRef, transitionGeojsonCommonDataRef, currentTransitionStepRef, msPerStep, transitionTimeoutRef, setDisplayGeojson) {
|
|
5215
|
+
if (typeof transitionGeojsonDataRef.current[currentTransitionStepRef.current] !== "undefined") {
|
|
5216
|
+
// if at last transition step set to target geojson
|
|
5217
|
+
// else to an assembled LineString from common geometry and the current transition step geometry
|
|
5218
|
+
let newData = currentTransitionStepRef.current + 1 === transitionGeojsonDataRef.current.length ? props.geojson : lineString$1([...transitionGeojsonCommonDataRef.current, ...transitionGeojsonDataRef.current[currentTransitionStepRef.current].geometry.coordinates]);
|
|
5219
|
+
setDisplayGeojson(newData);
|
|
5220
|
+
|
|
5221
|
+
if (typeof props.onTransitionFrame === "function") {
|
|
5222
|
+
props.onTransitionFrame(newData);
|
|
5223
|
+
}
|
|
5224
|
+
|
|
5225
|
+
currentTransitionStepRef.current++;
|
|
5226
|
+
|
|
5227
|
+
if (transitionInProgressRef.current && currentTransitionStepRef.current < transitionGeojsonDataRef.current.length) {
|
|
5228
|
+
transitionTimeoutRef.current = setTimeout(() => _showNextTransitionSegment(...arguments), msPerStep);
|
|
5229
|
+
} else {
|
|
5230
|
+
if (typeof props.onTransitionEnd === "function") {
|
|
5231
|
+
props.onTransitionEnd(props.geojson);
|
|
5232
|
+
}
|
|
5233
|
+
|
|
5234
|
+
transitionInProgressRef.current = false;
|
|
5235
|
+
}
|
|
5236
|
+
}
|
|
5237
|
+
};
|
|
5238
|
+
|
|
5239
|
+
const _transitionToGeojson = (props, transitionGeojsonCommonDataRef, transitionGeojsonDataRef, transitionInProgressRef, oldGeojsonRef, msPerStep, currentTransitionStepRef, map, transitionTimeoutRef, setDisplayGeojson) => {
|
|
5240
|
+
// create the transition geojson between oldGeojsonRef.current and props.geojson
|
|
5241
|
+
// create a geojson that contains no common point between the two line features
|
|
5242
|
+
let transitionCoordinatesShort = [];
|
|
5243
|
+
let transitionCoordinatesLong = [];
|
|
5244
|
+
let targetCoordinates = [];
|
|
5245
|
+
let srcCoordinates = [];
|
|
5246
|
+
transitionGeojsonCommonDataRef.current = [];
|
|
5247
|
+
let sourceGeojson = oldGeojsonRef.current || {
|
|
5248
|
+
geometry: {
|
|
5249
|
+
type: "LineString",
|
|
5250
|
+
coordinates: []
|
|
5251
|
+
},
|
|
5252
|
+
properties: {},
|
|
5253
|
+
type: "Feature"
|
|
5254
|
+
};
|
|
5255
|
+
let targetGeojson = props.geojson;
|
|
5256
|
+
let longerGeojson = targetGeojson;
|
|
5257
|
+
let shorterGeojson = sourceGeojson;
|
|
5258
|
+
let reverseOrder = false; // In case one geojson is missing completely use the first two coordinates of the other geojson
|
|
5259
|
+
|
|
5260
|
+
if (typeof longerGeojson.geometry === "undefined" && typeof shorterGeojson.geometry !== "undefined" && shorterGeojson.geometry.coordinates.length > 1) {
|
|
5261
|
+
longerGeojson = lineString$1(shorterGeojson.geometry.coordinates.slice(0, 2));
|
|
5262
|
+
} else if (typeof shorterGeojson.geometry === "undefined" && typeof longerGeojson.geometry !== "undefined" && longerGeojson.geometry.coordinates.length > 1) {
|
|
5263
|
+
shorterGeojson = lineString$1(longerGeojson.geometry.coordinates.slice(0, 2));
|
|
5264
|
+
} else if (typeof shorterGeojson.geometry === "undefined" && typeof longerGeojson.geometry === "undefined") {
|
|
5265
|
+
return;
|
|
5266
|
+
}
|
|
5267
|
+
|
|
5268
|
+
if (longerGeojson.geometry.coordinates.length < shorterGeojson.geometry.coordinates.length) {
|
|
5269
|
+
longerGeojson = sourceGeojson;
|
|
5270
|
+
shorterGeojson = targetGeojson;
|
|
5271
|
+
reverseOrder = true;
|
|
5272
|
+
}
|
|
5273
|
+
|
|
5274
|
+
if (longerGeojson && shorterGeojson) {
|
|
5275
|
+
for (var i = 0, len = longerGeojson.geometry.coordinates.length; i < len; i++) {
|
|
5276
|
+
if (typeof shorterGeojson.geometry.coordinates[i] !== "undefined" && longerGeojson.geometry.coordinates[i][0] === shorterGeojson.geometry.coordinates[i][0] && longerGeojson.geometry.coordinates[i][1] === shorterGeojson.geometry.coordinates[i][1]) {
|
|
5277
|
+
// if coordinates are equal
|
|
5278
|
+
transitionGeojsonCommonDataRef.current.push(longerGeojson.geometry.coordinates[i]);
|
|
5279
|
+
} else {
|
|
5280
|
+
if (typeof longerGeojson.geometry.coordinates[i] !== "undefined") {
|
|
5281
|
+
transitionCoordinatesLong.push(longerGeojson.geometry.coordinates[i]);
|
|
5282
|
+
}
|
|
5283
|
+
|
|
5284
|
+
if (typeof shorterGeojson.geometry.coordinates[i] !== "undefined") {
|
|
5285
|
+
transitionCoordinatesShort.push(shorterGeojson.geometry.coordinates[i]);
|
|
5286
|
+
}
|
|
5287
|
+
}
|
|
5288
|
+
}
|
|
5289
|
+
}
|
|
5290
|
+
|
|
5291
|
+
if (reverseOrder) {
|
|
5292
|
+
targetCoordinates = transitionCoordinatesShort;
|
|
5293
|
+
srcCoordinates = transitionCoordinatesLong;
|
|
5294
|
+
} else {
|
|
5295
|
+
targetCoordinates = transitionCoordinatesLong;
|
|
5296
|
+
srcCoordinates = transitionCoordinatesShort;
|
|
5297
|
+
}
|
|
5298
|
+
|
|
5299
|
+
if (targetCoordinates.length < 2 && srcCoordinates < 2) return; // create props.transitionTime / msPerStep (=: transitionSteps) Versions of transitionGeojsonCommonDataRef.current + transitionCoordinates making the transitionCoordinates transitionCoordinatesDistance / transitionSteps longer on each step
|
|
5300
|
+
|
|
5301
|
+
let transitionSteps = props.transitionTime / msPerStep;
|
|
5302
|
+
let srcCoordinatesDistance = srcCoordinates.length > 1 ? Math.round(length(lineString$1(srcCoordinates))) : 0;
|
|
5303
|
+
let targetCoordinatesDistance = targetCoordinates.length > 1 ? Math.round(length(lineString$1(targetCoordinates))) : 0;
|
|
5304
|
+
let transitionDistance = targetCoordinatesDistance + srcCoordinatesDistance;
|
|
5305
|
+
let srcCoordinatesShare = srcCoordinatesDistance / transitionDistance;
|
|
5306
|
+
let srcTransitionSteps = Math.round(transitionSteps * srcCoordinatesShare);
|
|
5307
|
+
let srcPerStepDistance = Math.round(srcCoordinatesDistance / srcTransitionSteps * 100) / 100;
|
|
5308
|
+
let targetCoordinatesShare = targetCoordinatesDistance / transitionDistance;
|
|
5309
|
+
let targetTransitionSteps = Math.round(transitionSteps * targetCoordinatesShare);
|
|
5310
|
+
let targetPerStepDistance = Math.round(targetCoordinatesDistance / targetTransitionSteps * 100) / 100; // use srcPerStepDistance as src coordinates are always animated backwards
|
|
5311
|
+
|
|
5312
|
+
|
|
5313
|
+
let transitionStepData;
|
|
5314
|
+
transitionStepData = [...createTransitionSteps(srcCoordinates, srcPerStepDistance, srcTransitionSteps)];
|
|
5315
|
+
transitionStepData.reverse();
|
|
5316
|
+
transitionStepData = [...transitionStepData, ...createTransitionSteps(targetCoordinates, targetPerStepDistance, targetTransitionSteps)];
|
|
5317
|
+
transitionStepData.push(targetGeojson);
|
|
5318
|
+
transitionGeojsonDataRef.current = transitionStepData;
|
|
5319
|
+
currentTransitionStepRef.current = 1;
|
|
5320
|
+
transitionInProgressRef.current = true;
|
|
5321
|
+
transitionTimeoutRef.current = setTimeout(() => _showNextTransitionSegment(props, map, transitionInProgressRef, transitionGeojsonDataRef, transitionGeojsonCommonDataRef, currentTransitionStepRef, msPerStep, transitionTimeoutRef, setDisplayGeojson), msPerStep);
|
|
5322
|
+
};
|
|
5323
|
+
|
|
5324
|
+
let createTransitionSteps = (linestringCoordinates, perStepDistance, stepCnt) => {
|
|
5325
|
+
let transitionSteps = [];
|
|
5326
|
+
|
|
5327
|
+
if (linestringCoordinates.length > 1) {
|
|
5328
|
+
let tmpChunks = lineChunk(lineString$1(linestringCoordinates), perStepDistance); // tmpLineString contains all coordinates of all previous plus current loop iteration
|
|
5329
|
+
|
|
5330
|
+
let tmpLinestring = tmpChunks.features[0];
|
|
5331
|
+
|
|
5332
|
+
for (let i = 0; i < stepCnt; i++) {
|
|
5333
|
+
transitionSteps.push(tmpLinestring);
|
|
5334
|
+
|
|
5335
|
+
if (typeof tmpChunks.features[i] !== "undefined") {
|
|
5336
|
+
tmpLinestring = lineString$1([...tmpLinestring.geometry.coordinates, ...tmpChunks.features[i].geometry.coordinates]);
|
|
5337
|
+
} else {
|
|
5338
|
+
break;
|
|
5339
|
+
}
|
|
5340
|
+
}
|
|
5341
|
+
}
|
|
5342
|
+
|
|
5343
|
+
return transitionSteps;
|
|
5344
|
+
};
|
|
5345
|
+
|
|
5346
|
+
const msPerStep = 50;
|
|
5347
|
+
/**
|
|
5348
|
+
* Adds source and layer of types "line", "fill" or "circle" to display GeoJSON data on the map.
|
|
5349
|
+
*
|
|
5350
|
+
* @component
|
|
5351
|
+
*/
|
|
5352
|
+
|
|
5353
|
+
const MlTransitionGeoJsonLayer = props => {
|
|
5354
|
+
const {
|
|
5355
|
+
geojson,
|
|
5356
|
+
...restProps
|
|
5357
|
+
} = props; // Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
5358
|
+
|
|
5359
|
+
const mapHook = useMap({
|
|
5360
|
+
mapId: props.mapId,
|
|
5361
|
+
waitForLayer: props.insertBeforeLayer
|
|
5362
|
+
});
|
|
5363
|
+
const initializedRef = useRef(false); // transition effect variables
|
|
5364
|
+
|
|
5365
|
+
const oldGeojsonRef = useRef(null);
|
|
5366
|
+
const transitionInProgressRef = useRef(false);
|
|
5367
|
+
const transitionTimeoutRef = useRef(undefined);
|
|
5368
|
+
const currentTransitionStepRef = useRef(false);
|
|
5369
|
+
const transitionGeojsonDataRef = useRef([]);
|
|
5370
|
+
const transitionGeojsonCommonDataRef = useRef([]);
|
|
5371
|
+
const [displayGeojson, setDisplayGeojson] = useState(featureCollection([]));
|
|
5372
|
+
useEffect(() => {
|
|
5373
|
+
return () => {
|
|
5374
|
+
// This is the cleanup function, it is called when this react component is removed from react-dom
|
|
5375
|
+
if (transitionTimeoutRef.current) {
|
|
5376
|
+
clearTimeout(transitionTimeoutRef.current);
|
|
5377
|
+
}
|
|
5378
|
+
};
|
|
5379
|
+
}, []);
|
|
5380
|
+
const transitionToGeojson = useCallback(() => {
|
|
5381
|
+
_transitionToGeojson(props, transitionGeojsonCommonDataRef, transitionGeojsonDataRef, transitionInProgressRef, oldGeojsonRef, msPerStep, currentTransitionStepRef, mapHook.map, transitionTimeoutRef, setDisplayGeojson);
|
|
5382
|
+
}, [props, mapHook.map]);
|
|
5383
|
+
useEffect(() => {
|
|
5384
|
+
if (!mapHook.map || !initializedRef.current) return;
|
|
5385
|
+
|
|
5386
|
+
if (typeof props.transitionTime !== "undefined" && props.type === "line" && oldGeojsonRef.current) {
|
|
5387
|
+
transitionInProgressRef.current = false;
|
|
5388
|
+
currentTransitionStepRef.current = false;
|
|
5389
|
+
transitionGeojsonDataRef.current = [];
|
|
5390
|
+
transitionGeojsonCommonDataRef.current = [];
|
|
5391
|
+
transitionToGeojson();
|
|
5392
|
+
}
|
|
5393
|
+
|
|
5394
|
+
oldGeojsonRef.current = props.geojson;
|
|
5395
|
+
}, [mapHook.map, transitionToGeojson, props]);
|
|
5396
|
+
const startTransition = useCallback(() => {
|
|
5397
|
+
if (props.type === "line" && typeof props.transitionTime !== "undefined" && props.transitionTime && typeof props.geojson.geometry !== "undefined" && JSON.stringify(oldGeojsonRef.current) !== JSON.stringify(props.geojson)) {
|
|
5398
|
+
transitionToGeojson(props.geojson);
|
|
5399
|
+
oldGeojsonRef.current = props.geojson;
|
|
5400
|
+
}
|
|
5401
|
+
}, [props, transitionToGeojson]);
|
|
5402
|
+
useEffect(() => {
|
|
5403
|
+
if (!mapHook.mapIsReady || !props.geojson) return;
|
|
5404
|
+
initializedRef.current = true;
|
|
5405
|
+
startTransition();
|
|
5406
|
+
}, [mapHook.mapIsReady, startTransition, props]);
|
|
5407
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(MlGeoJsonLayer, _extends$3({}, restProps, {
|
|
5408
|
+
geojson: displayGeojson
|
|
5409
|
+
})));
|
|
5410
|
+
};
|
|
5411
|
+
|
|
5412
|
+
MlTransitionGeoJsonLayer.propTypes = {
|
|
5413
|
+
/**
|
|
5414
|
+
* Id of the target MapLibre instance in mapContext
|
|
5415
|
+
*/
|
|
5416
|
+
mapId: PropTypes.string,
|
|
5417
|
+
|
|
5418
|
+
/**
|
|
5419
|
+
* Type of the layer that will be added to the MapLibre instance.
|
|
5420
|
+
* Possible values: "line", "circle", "fill"
|
|
5421
|
+
*/
|
|
5422
|
+
type: PropTypes.string,
|
|
5423
|
+
|
|
5424
|
+
/**
|
|
5425
|
+
* Layout property object, that is passed to the addLayer call.
|
|
5426
|
+
* Possible props depend on the layer type.
|
|
5427
|
+
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#line
|
|
5428
|
+
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
|
|
5429
|
+
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
5430
|
+
*/
|
|
5431
|
+
layout: PropTypes.object,
|
|
5432
|
+
|
|
5433
|
+
/**
|
|
5434
|
+
* Paint property object, that is passed to the addLayer call.
|
|
5435
|
+
* Possible props depend on the layer type.
|
|
5436
|
+
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#line
|
|
5437
|
+
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
|
|
5438
|
+
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
5439
|
+
*/
|
|
5440
|
+
paint: PropTypes.object,
|
|
5441
|
+
|
|
5442
|
+
/**
|
|
5443
|
+
* Javascript object with optional properties "fill", "line", "circle" to override implicit layer type default paint properties.
|
|
5444
|
+
*/
|
|
5445
|
+
defaultPaintOverrides: PropTypes.object,
|
|
5446
|
+
|
|
5447
|
+
/**
|
|
5448
|
+
* Javascript object that is spread into the addLayer commands first parameter.
|
|
5449
|
+
*/
|
|
5450
|
+
options: PropTypes.object,
|
|
5451
|
+
|
|
5452
|
+
/**
|
|
5453
|
+
* GeoJSON data that is supposed to be rendered by this component.
|
|
5454
|
+
*/
|
|
5455
|
+
geojson: PropTypes.object,
|
|
5456
|
+
|
|
5457
|
+
/**
|
|
5458
|
+
* Id of an existing layer in the mapLibre instance to help specify the layer order
|
|
5459
|
+
* This layer will be visually beneath the layer with the "insertBeforeLayer" id.
|
|
5460
|
+
*/
|
|
5461
|
+
insertBeforeLayer: PropTypes.string,
|
|
5462
|
+
|
|
5463
|
+
/**
|
|
5464
|
+
* Click event handler that is executed whenever a geometry rendered by this component is clicked.
|
|
5465
|
+
*/
|
|
5466
|
+
onClick: PropTypes.func,
|
|
5467
|
+
|
|
5468
|
+
/**
|
|
5469
|
+
* Hover event handler that is executed whenever a geometry rendered by this component is hovered.
|
|
5470
|
+
*/
|
|
5471
|
+
onHover: PropTypes.func,
|
|
5472
|
+
|
|
5473
|
+
/**
|
|
5474
|
+
* Leave event handler that is executed whenever a geometry rendered by this component is
|
|
5475
|
+
* left/unhovered.
|
|
5476
|
+
*/
|
|
5477
|
+
onLeave: PropTypes.func,
|
|
5478
|
+
|
|
5479
|
+
/**
|
|
5480
|
+
* Creates transition animation whenever the geojson prop changes.
|
|
5481
|
+
* Only works with layer type "line" and LineString GeoJSON data.
|
|
5482
|
+
*/
|
|
5483
|
+
transitionTime: PropTypes.number
|
|
5484
|
+
};
|
|
5485
|
+
|
|
5486
|
+
/**
|
|
5487
|
+
* Adds a marker to the map and displays a marker description next to it
|
|
5488
|
+
*
|
|
5489
|
+
* @param {object} props
|
|
5490
|
+
* @param {string} props.mapId Id of the target MapLibre instance in mapContext
|
|
5491
|
+
* @param {number} props.lng
|
|
5492
|
+
* @param {number} props.lat
|
|
5493
|
+
* @param {string} props.content
|
|
5494
|
+
*
|
|
5495
|
+
* @component
|
|
5496
|
+
*/
|
|
5497
|
+
|
|
5498
|
+
const MlMarker = props => {
|
|
5499
|
+
const mapContext = useContext(MapContext);
|
|
5500
|
+
const mapState = useMapState({
|
|
5501
|
+
mapId: props.mapId,
|
|
5502
|
+
watch: {
|
|
5503
|
+
viewport: true
|
|
5504
|
+
}
|
|
5505
|
+
});
|
|
5506
|
+
const iframe = useRef(undefined);
|
|
5507
|
+
const initializedRef = useRef(false);
|
|
5508
|
+
const mapRef = useRef(undefined);
|
|
5509
|
+
const componentId = useRef((props.idPrefix ? props.idPrefix : "MlMarker-") + v4());
|
|
5510
|
+
const [iframeDimensions, setIframeDimensions] = useState({
|
|
5511
|
+
width: "400px",
|
|
5512
|
+
height: "500px"
|
|
5513
|
+
});
|
|
5514
|
+
const [markerPixelPos, setMarkerPixelPos] = useState(undefined);
|
|
5515
|
+
useEffect(() => {
|
|
5516
|
+
let _componentId = componentId.current;
|
|
5517
|
+
return () => {
|
|
5518
|
+
// This is the cleanup function, it is called when this react component is removed from react-dom
|
|
5519
|
+
// try to remove anything this component has added to the MapLibre-gl instance
|
|
5520
|
+
// e.g.: remove the layer
|
|
5521
|
+
// mapContext.getMap(props.mapId).removeLayer(layerRef.current);
|
|
5522
|
+
// check for the existence of map.style before calling getLayer or getSource
|
|
5523
|
+
if (mapRef.current) {
|
|
5524
|
+
mapRef.current.cleanup(_componentId);
|
|
5525
|
+
mapRef.current = undefined;
|
|
5526
|
+
}
|
|
5527
|
+
|
|
5528
|
+
initializedRef.current = false;
|
|
5529
|
+
};
|
|
5530
|
+
}, []);
|
|
5531
|
+
useEffect(() => {
|
|
5532
|
+
if (!mapContext.mapExists(props.mapId) || initializedRef.current) return; // the MapLibre-gl instance (mapContext.getMap(props.mapId)) is accessible here
|
|
5533
|
+
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
5534
|
+
|
|
5535
|
+
initializedRef.current = true;
|
|
5536
|
+
mapRef.current = mapContext.getMap(props.mapId);
|
|
5537
|
+
}, [mapContext.mapIds, mapContext, props.mapId]);
|
|
5538
|
+
useEffect(() => {
|
|
5539
|
+
var _mapRef$current;
|
|
5540
|
+
|
|
5541
|
+
if (!((_mapRef$current = mapRef.current) !== null && _mapRef$current !== void 0 && _mapRef$current.project)) return;
|
|
5542
|
+
|
|
5543
|
+
const _pixelPos = mapRef.current.project([props.lng, props.lat]);
|
|
5544
|
+
|
|
5545
|
+
setMarkerPixelPos(_pixelPos);
|
|
5546
|
+
}, [props.lng, props.lat, mapState.viewport]);
|
|
5547
|
+
useEffect(() => {
|
|
5548
|
+
var _iframe$current, _iframe$current$conte, _iframe$current$conte2, _iframe$current$conte3;
|
|
5549
|
+
|
|
5550
|
+
if (mapRef.current && (_iframe$current = iframe.current) !== null && _iframe$current !== void 0 && (_iframe$current$conte = _iframe$current.contentWindow) !== null && _iframe$current$conte !== void 0 && (_iframe$current$conte2 = _iframe$current$conte.document) !== null && _iframe$current$conte2 !== void 0 && (_iframe$current$conte3 = _iframe$current$conte2.body) !== null && _iframe$current$conte3 !== void 0 && _iframe$current$conte3.scrollHeight) {
|
|
5551
|
+
setTimeout(() => {
|
|
5552
|
+
var _iframe$current2, _iframe$current2$cont, _iframe$current2$cont2, _iframe$current2$cont3, _iframe$current3, _iframe$current3$cont, _iframe$current3$cont2, _iframe$current3$cont3;
|
|
5553
|
+
|
|
5554
|
+
let mapHeight = mapRef.current._container.clientHeight;
|
|
5555
|
+
|
|
5556
|
+
const _pixelPos = mapRef.current.project([props.lng, props.lat]);
|
|
5557
|
+
|
|
5558
|
+
let pixelToBottom = mapHeight - _pixelPos.y;
|
|
5559
|
+
let iframeHeight = (_iframe$current2 = iframe.current) === null || _iframe$current2 === void 0 ? void 0 : (_iframe$current2$cont = _iframe$current2.contentWindow) === null || _iframe$current2$cont === void 0 ? void 0 : (_iframe$current2$cont2 = _iframe$current2$cont.document) === null || _iframe$current2$cont2 === void 0 ? void 0 : (_iframe$current2$cont3 = _iframe$current2$cont2.body) === null || _iframe$current2$cont3 === void 0 ? void 0 : _iframe$current2$cont3.scrollHeight;
|
|
5560
|
+
let iframeWidth = (_iframe$current3 = iframe.current) === null || _iframe$current3 === void 0 ? void 0 : (_iframe$current3$cont = _iframe$current3.contentWindow) === null || _iframe$current3$cont === void 0 ? void 0 : (_iframe$current3$cont2 = _iframe$current3$cont.document) === null || _iframe$current3$cont2 === void 0 ? void 0 : (_iframe$current3$cont3 = _iframe$current3$cont2.body) === null || _iframe$current3$cont3 === void 0 ? void 0 : _iframe$current3$cont3.scrollWidth;
|
|
5561
|
+
setIframeDimensions({
|
|
5562
|
+
width: iframeWidth,
|
|
5563
|
+
height: pixelToBottom < iframeHeight ? pixelToBottom : iframeHeight
|
|
5564
|
+
});
|
|
5565
|
+
}, 100);
|
|
5566
|
+
}
|
|
5567
|
+
}, [props.lng, props.lat, props.content]);
|
|
5568
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(MlGeoJsonLayer, {
|
|
5569
|
+
geojson: {
|
|
5570
|
+
type: "Feature",
|
|
5571
|
+
geometry: {
|
|
5572
|
+
type: "Point",
|
|
5573
|
+
coordinates: [props.lng, props.lat]
|
|
5574
|
+
},
|
|
5575
|
+
properties: {}
|
|
5576
|
+
},
|
|
5577
|
+
paint: {
|
|
5578
|
+
"circle-radius": 14,
|
|
5579
|
+
"circle-color": "rgba(40,200,20,0.5)"
|
|
5580
|
+
},
|
|
5581
|
+
type: "circle",
|
|
5582
|
+
mapId: props.mapId
|
|
5583
|
+
}), markerPixelPos && /*#__PURE__*/React__default.createElement(Paper, {
|
|
5584
|
+
sx: {
|
|
5585
|
+
opacity: 0.7,
|
|
5586
|
+
position: "fixed",
|
|
5587
|
+
display: "flex",
|
|
5588
|
+
|
|
5589
|
+
/** TODO: fix positioning delay when moving the map */
|
|
5590
|
+
left: markerPixelPos.x,
|
|
5591
|
+
top: markerPixelPos.y,
|
|
5592
|
+
width: iframeDimensions.width,
|
|
5593
|
+
height: iframeDimensions.height,
|
|
5594
|
+
"&:hover": {
|
|
5595
|
+
opacity: 1
|
|
5596
|
+
},
|
|
5597
|
+
zIndex: -1
|
|
5598
|
+
}
|
|
5599
|
+
}, /*#__PURE__*/React__default.createElement("iframe", {
|
|
5600
|
+
style: {
|
|
5601
|
+
width: "100%"
|
|
5602
|
+
},
|
|
5603
|
+
srcDoc: props.content,
|
|
5604
|
+
ref: iframe,
|
|
5605
|
+
sandbox: "allow-same-origin allow-popups-to-escape-sandbox",
|
|
5606
|
+
frameBorder: "0",
|
|
5607
|
+
title: componentId.current
|
|
5608
|
+
})));
|
|
5609
|
+
};
|
|
5610
|
+
|
|
5611
|
+
MlMarker.defaultProps = {
|
|
5612
|
+
mapId: undefined
|
|
5613
|
+
};
|
|
5614
|
+
MlMarker.propTypes = {
|
|
5615
|
+
/**
|
|
5616
|
+
* Id of the target MapLibre instance in mapContext
|
|
5617
|
+
*/
|
|
5618
|
+
mapId: PropTypes.string,
|
|
5619
|
+
|
|
5620
|
+
/**
|
|
5621
|
+
* Longitude of the marker position
|
|
5622
|
+
*/
|
|
5623
|
+
lng: PropTypes.number,
|
|
5624
|
+
|
|
5625
|
+
/**
|
|
5626
|
+
* Latitude of the marker position
|
|
5627
|
+
*/
|
|
5628
|
+
lat: PropTypes.number,
|
|
5629
|
+
|
|
5630
|
+
/**
|
|
5631
|
+
* Content of the description popup
|
|
5632
|
+
*/
|
|
5633
|
+
content: PropTypes.string
|
|
5634
|
+
};
|
|
5635
|
+
|
|
5636
|
+
function useWms(props) {
|
|
5637
|
+
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
5638
|
+
const [getFeatureInfoUrl, setGetFeatureInfoUrl] = useState(undefined);
|
|
5639
|
+
const [url, setUrl] = useState(props.url);
|
|
5640
|
+
const [wmsUrl, setWmsUrl] = useState("");
|
|
5641
|
+
const [capabilities, setCapabilities] = useState(undefined);
|
|
5642
|
+
const [error, setError] = useState(undefined);
|
|
5643
|
+
|
|
5644
|
+
const clearState = () => {
|
|
5645
|
+
setGetFeatureInfoUrl(undefined);
|
|
5646
|
+
setCapabilities(undefined); //setLayers([]);
|
|
5647
|
+
|
|
5648
|
+
setWmsUrl("");
|
|
5649
|
+
};
|
|
5650
|
+
|
|
5651
|
+
useEffect(() => {
|
|
5652
|
+
var _propsUrlParams2;
|
|
5653
|
+
|
|
5654
|
+
// extract URL parameters from the given URL
|
|
5655
|
+
clearState();
|
|
5656
|
+
setError(undefined);
|
|
5657
|
+
if (!url) return;
|
|
5658
|
+
|
|
5659
|
+
let _propsUrlParams;
|
|
5660
|
+
|
|
5661
|
+
let _wmsUrl = url;
|
|
5662
|
+
|
|
5663
|
+
if (url.indexOf("?") !== -1) {
|
|
5664
|
+
_propsUrlParams = url.split("?");
|
|
5665
|
+
_wmsUrl = _propsUrlParams[0];
|
|
5666
|
+
}
|
|
5667
|
+
|
|
5668
|
+
let _urlParamsFromUrl = new URLSearchParams((_propsUrlParams2 = _propsUrlParams) === null || _propsUrlParams2 === void 0 ? void 0 : _propsUrlParams2[1]);
|
|
5669
|
+
|
|
5670
|
+
let urlParamsObj = { ...Object.fromEntries(_urlParamsFromUrl),
|
|
5671
|
+
...props.urlParameters
|
|
5672
|
+
}; // create URLSearchParams object to assemble the URL Parameters
|
|
5673
|
+
|
|
5674
|
+
let urlParams = new URLSearchParams(urlParamsObj);
|
|
5675
|
+
let urlParamsStr = decodeURIComponent(urlParams.toString()) + "".replace(/%2F/g, "/").replace(/%3A/g, ":");
|
|
5676
|
+
fetch(_wmsUrl + "?" + urlParamsStr).then(res => {
|
|
5677
|
+
if (!res.ok) {
|
|
5678
|
+
throw Error(res.statusText + " (" + res.status + " - " + res.type + ")");
|
|
5679
|
+
} else {
|
|
5680
|
+
return res.text();
|
|
5681
|
+
}
|
|
5682
|
+
}).then(data => {
|
|
5683
|
+
setCapabilities(new WMSCapabilities(data).toJSON());
|
|
5684
|
+
}).catch(error => {
|
|
5685
|
+
//reset local state
|
|
5686
|
+
clearState();
|
|
5687
|
+
console.log(error);
|
|
5688
|
+
setError(error.message);
|
|
5689
|
+
});
|
|
5690
|
+
}, [url, props.urlParameters]);
|
|
5691
|
+
useEffect(() => {
|
|
5692
|
+
var _capabilities$Capabil, _capabilities$Capabil2, _capabilities$Capabil3, _capabilities$Capabil4, _capabilities$Capabil5, _capabilities$Capabil6, _capabilities$Capabil7, _capabilities$Capabil8, _capabilities$Capabil9, _capabilities$Capabil10, _capabilities$Capabil11, _capabilities$Capabil12, _capabilities$Capabil13, _capabilities$Capabil14;
|
|
5693
|
+
|
|
5694
|
+
if (!(capabilities !== null && capabilities !== void 0 && capabilities.Service)) return;
|
|
5695
|
+
setWmsUrl((_capabilities$Capabil = capabilities.Capability) === null || _capabilities$Capabil === void 0 ? void 0 : (_capabilities$Capabil2 = _capabilities$Capabil.Request) === null || _capabilities$Capabil2 === void 0 ? void 0 : (_capabilities$Capabil3 = _capabilities$Capabil2.GetMap) === null || _capabilities$Capabil3 === void 0 ? void 0 : (_capabilities$Capabil4 = _capabilities$Capabil3.DCPType) === null || _capabilities$Capabil4 === void 0 ? void 0 : (_capabilities$Capabil5 = _capabilities$Capabil4[0]) === null || _capabilities$Capabil5 === void 0 ? void 0 : (_capabilities$Capabil6 = _capabilities$Capabil5.HTTP) === null || _capabilities$Capabil6 === void 0 ? void 0 : (_capabilities$Capabil7 = _capabilities$Capabil6.Get) === null || _capabilities$Capabil7 === void 0 ? void 0 : _capabilities$Capabil7.OnlineResource); // set getFeatureInfo url
|
|
5696
|
+
|
|
5697
|
+
setGetFeatureInfoUrl((_capabilities$Capabil8 = capabilities.Capability) === null || _capabilities$Capabil8 === void 0 ? void 0 : (_capabilities$Capabil9 = _capabilities$Capabil8.Request) === null || _capabilities$Capabil9 === void 0 ? void 0 : (_capabilities$Capabil10 = _capabilities$Capabil9.GetFeatureInfo) === null || _capabilities$Capabil10 === void 0 ? void 0 : (_capabilities$Capabil11 = _capabilities$Capabil10.DCPType) === null || _capabilities$Capabil11 === void 0 ? void 0 : (_capabilities$Capabil12 = _capabilities$Capabil11[0]) === null || _capabilities$Capabil12 === void 0 ? void 0 : (_capabilities$Capabil13 = _capabilities$Capabil12.HTTP) === null || _capabilities$Capabil13 === void 0 ? void 0 : (_capabilities$Capabil14 = _capabilities$Capabil13.Get) === null || _capabilities$Capabil14 === void 0 ? void 0 : _capabilities$Capabil14.OnlineResource);
|
|
5698
|
+
}, [capabilities]);
|
|
5699
|
+
return {
|
|
5700
|
+
capabilities,
|
|
5701
|
+
getFeatureInfoUrl,
|
|
5702
|
+
wmsUrl,
|
|
5703
|
+
error,
|
|
5704
|
+
setUrl
|
|
5705
|
+
};
|
|
5706
|
+
}
|
|
5707
|
+
|
|
5708
|
+
useWms.defaultProps = {
|
|
5709
|
+
url: "",
|
|
5710
|
+
urlParameters: {
|
|
5711
|
+
SERVICE: "WMS",
|
|
5712
|
+
VERSION: "1.3.0",
|
|
5713
|
+
REQUEST: "getCapabilities"
|
|
5714
|
+
}
|
|
5715
|
+
};
|
|
5716
|
+
|
|
5717
|
+
export { GeoJsonContext, GeoJsonProvider, MapLibreMap, MlBasicComponent, MlComponentTemplate, MlCreatePdfButton, MlFeatureEditor, MlFillExtrusionLayer, MlFollowGps, MlGPXViewer, MlGeoJsonLayer, MlImageMarkerLayer, MlLayer, MlLayerMagnify, MlLayerSwipe, MlMarker, MlNavigationCompass, MlNavigationTools, MlOsmLayer, MlSpatialElevationProfile, MlTransitionGeoJsonLayer, MlVectorTileLayer, MlWmsLayer, useMap, useMapState, useWms };
|
|
5559
5718
|
//# sourceMappingURL=index.esm.js.map
|