@mapcomponents/react-maplibre 0.1.32 → 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/coverage/clover.xml +2 -2
- package/coverage/lcov-report/index.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.js.html +1 -1
- package/coverage/lcov-report/src/components/MlFollowGps/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGPXViewer/MlGPXViewer.js.html +1 -1
- package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayer/MlLayer.js.html +1 -1
- package/coverage/lcov-report/src/components/MlLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.js.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.js.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationTools/index.html +1 -1
- package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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/dist/index.esm.js +988 -1390
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -4
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.js +1 -1
- package/src/components/MlFeatureEditor/MlFeatureEditor.doc.en.md +1 -0
- package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.doc.en.md +1 -0
- package/src/components/MlFollowGps/MlFollowGps.doc.en.md +1 -0
- package/src/components/MlGPXViewer/MlGPXViewer.doc.en.md +1 -0
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.doc.en.md +1 -0
- package/src/components/MlLayerMagnify/MlLayerMagnify.doc.en.md +1 -0
- package/src/components/MlLayerSwipe/MlLayerSwipe.doc.en.md +1 -0
- package/src/components/MlNavigationCompass/MlNavigationCompass.doc.en.md +1 -0
- package/src/components/MlNavigationTools/MlNavigationTools.doc.en.md +1 -0
- package/src/components/MlScaleReference/MlScaleReference.doc.en.md +1 -0
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.doc.en.md +1 -0
- package/src/components/MlThreeJsLayer/MlThreeJsLayer.doc.en.md +1 -0
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.doc.en.md +1 -0
- package/src/components/MlWmsLoader/MlWmsLoader.doc.en.md +1 -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
9
|
import { point, circle, lineArc, bbox, lineOffset, distance, lineString as lineString$1, length, lineChunk, featureCollection } from '@turf/turf';
|
|
10
|
-
import maplibregl$1, { Popup } from 'maplibre-gl';
|
|
11
10
|
import jsPDF from 'jspdf';
|
|
12
11
|
import PrinterIcon from '@mui/icons-material/Print';
|
|
13
12
|
import ButtonGroup from '@mui/material/ButtonGroup';
|
|
@@ -34,223 +33,7 @@ import { lineString, polygon } from '@turf/helpers';
|
|
|
34
33
|
import Paper from '@mui/material/Paper';
|
|
35
34
|
import WMSCapabilities from 'wms-capabilities';
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
var keys = Object.keys(object);
|
|
39
|
-
|
|
40
|
-
if (Object.getOwnPropertySymbols) {
|
|
41
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
42
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
43
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
44
|
-
})), keys.push.apply(keys, symbols);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return keys;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function _objectSpread2(target) {
|
|
51
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
52
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
53
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
54
|
-
_defineProperty(target, key, source[key]);
|
|
55
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
56
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return target;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function _typeof(obj) {
|
|
64
|
-
"@babel/helpers - typeof";
|
|
65
|
-
|
|
66
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
67
|
-
return typeof obj;
|
|
68
|
-
} : function (obj) {
|
|
69
|
-
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
70
|
-
}, _typeof(obj);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
74
|
-
try {
|
|
75
|
-
var info = gen[key](arg);
|
|
76
|
-
var value = info.value;
|
|
77
|
-
} catch (error) {
|
|
78
|
-
reject(error);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (info.done) {
|
|
83
|
-
resolve(value);
|
|
84
|
-
} else {
|
|
85
|
-
Promise.resolve(value).then(_next, _throw);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function _asyncToGenerator(fn) {
|
|
90
|
-
return function () {
|
|
91
|
-
var self = this,
|
|
92
|
-
args = arguments;
|
|
93
|
-
return new Promise(function (resolve, reject) {
|
|
94
|
-
var gen = fn.apply(self, args);
|
|
95
|
-
|
|
96
|
-
function _next(value) {
|
|
97
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function _throw(err) {
|
|
101
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
_next(undefined);
|
|
105
|
-
});
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function _defineProperty(obj, key, value) {
|
|
110
|
-
if (key in obj) {
|
|
111
|
-
Object.defineProperty(obj, key, {
|
|
112
|
-
value: value,
|
|
113
|
-
enumerable: true,
|
|
114
|
-
configurable: true,
|
|
115
|
-
writable: true
|
|
116
|
-
});
|
|
117
|
-
} else {
|
|
118
|
-
obj[key] = value;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return obj;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function _extends() {
|
|
125
|
-
_extends = Object.assign || function (target) {
|
|
126
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
127
|
-
var source = arguments[i];
|
|
128
|
-
|
|
129
|
-
for (var key in source) {
|
|
130
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
131
|
-
target[key] = source[key];
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return target;
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
return _extends.apply(this, arguments);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
143
|
-
if (source == null) return {};
|
|
144
|
-
var target = {};
|
|
145
|
-
var sourceKeys = Object.keys(source);
|
|
146
|
-
var key, i;
|
|
147
|
-
|
|
148
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
149
|
-
key = sourceKeys[i];
|
|
150
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
151
|
-
target[key] = source[key];
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return target;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function _objectWithoutProperties(source, excluded) {
|
|
158
|
-
if (source == null) return {};
|
|
159
|
-
|
|
160
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
161
|
-
|
|
162
|
-
var key, i;
|
|
163
|
-
|
|
164
|
-
if (Object.getOwnPropertySymbols) {
|
|
165
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
166
|
-
|
|
167
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
168
|
-
key = sourceSymbolKeys[i];
|
|
169
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
170
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
171
|
-
target[key] = source[key];
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return target;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function _slicedToArray(arr, i) {
|
|
179
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function _toConsumableArray(arr) {
|
|
183
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function _arrayWithoutHoles(arr) {
|
|
187
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function _arrayWithHoles(arr) {
|
|
191
|
-
if (Array.isArray(arr)) return arr;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function _iterableToArray(iter) {
|
|
195
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
function _iterableToArrayLimit(arr, i) {
|
|
199
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
200
|
-
|
|
201
|
-
if (_i == null) return;
|
|
202
|
-
var _arr = [];
|
|
203
|
-
var _n = true;
|
|
204
|
-
var _d = false;
|
|
205
|
-
|
|
206
|
-
var _s, _e;
|
|
207
|
-
|
|
208
|
-
try {
|
|
209
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
210
|
-
_arr.push(_s.value);
|
|
211
|
-
|
|
212
|
-
if (i && _arr.length === i) break;
|
|
213
|
-
}
|
|
214
|
-
} catch (err) {
|
|
215
|
-
_d = true;
|
|
216
|
-
_e = err;
|
|
217
|
-
} finally {
|
|
218
|
-
try {
|
|
219
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
220
|
-
} finally {
|
|
221
|
-
if (_d) throw _e;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return _arr;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
229
|
-
if (!o) return;
|
|
230
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
231
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
232
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
233
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
234
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
function _arrayLikeToArray(arr, len) {
|
|
238
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
239
|
-
|
|
240
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
241
|
-
|
|
242
|
-
return arr2;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
function _nonIterableSpread() {
|
|
246
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
function _nonIterableRest() {
|
|
250
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
var _excluded = ["lng", "lat"];
|
|
36
|
+
// @ts-ignore: TS export Problem to be fixed upstream
|
|
254
37
|
/**
|
|
255
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.
|
|
256
39
|
*
|
|
@@ -259,11 +42,11 @@ var _excluded = ["lng", "lat"];
|
|
|
259
42
|
* @class
|
|
260
43
|
*/
|
|
261
44
|
|
|
262
|
-
|
|
45
|
+
const MapLibreGlWrapper = function (props) {
|
|
263
46
|
var _this = this;
|
|
264
47
|
|
|
265
48
|
// closure variable to safely point to the object context of the current MapLibreGlWrapper instance
|
|
266
|
-
|
|
49
|
+
let self = this; // element registration and cleanup on a component level is experimental
|
|
267
50
|
|
|
268
51
|
this.registeredElements = {}; // array of base layer ids, all layers that have been added by the style passed to the MapLibreGl coonstructor
|
|
269
52
|
|
|
@@ -287,7 +70,7 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
287
70
|
* @param {string} componentId
|
|
288
71
|
* @returns {undefined}
|
|
289
72
|
*/
|
|
290
|
-
on:
|
|
73
|
+
on: (eventName, handler, options, componentId) => {
|
|
291
74
|
if (!self.eventHandlers[eventName]) return;
|
|
292
75
|
|
|
293
76
|
if (typeof options === "string") {
|
|
@@ -296,10 +79,10 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
296
79
|
}
|
|
297
80
|
|
|
298
81
|
self.eventHandlers[eventName].push({
|
|
299
|
-
handler
|
|
300
|
-
options
|
|
82
|
+
handler,
|
|
83
|
+
options
|
|
301
84
|
});
|
|
302
|
-
|
|
85
|
+
let _arguments = [eventName, handler];
|
|
303
86
|
|
|
304
87
|
if (componentId && typeof componentId === "string") {
|
|
305
88
|
self.initRegisteredElements(componentId);
|
|
@@ -314,9 +97,9 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
314
97
|
* @param {function} handler
|
|
315
98
|
* @returns {undefined}
|
|
316
99
|
*/
|
|
317
|
-
off:
|
|
100
|
+
off: (eventName, handler) => {
|
|
318
101
|
if (!self.eventHandlers[eventName]) return;
|
|
319
|
-
self.eventHandlers[eventName] = self.eventHandlers[eventName].filter(
|
|
102
|
+
self.eventHandlers[eventName] = self.eventHandlers[eventName].filter(item => {
|
|
320
103
|
if (!Object.is(item.handler, handler)) {
|
|
321
104
|
return item;
|
|
322
105
|
}
|
|
@@ -332,10 +115,10 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
332
115
|
* @param {object} context
|
|
333
116
|
* @returns {undefined}
|
|
334
117
|
*/
|
|
335
|
-
fire:
|
|
118
|
+
fire: (eventName, context) => {
|
|
336
119
|
if (!self.eventHandlers[eventName]) return;
|
|
337
120
|
var scope = context || window;
|
|
338
|
-
|
|
121
|
+
let event = new Event(eventName);
|
|
339
122
|
event.data = self;
|
|
340
123
|
self.eventHandlers[eventName].forEach(function (item) {
|
|
341
124
|
item.handler.call(scope, event);
|
|
@@ -363,7 +146,7 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
363
146
|
* @param {string} layer
|
|
364
147
|
* @returns object
|
|
365
148
|
*/
|
|
366
|
-
buildLayerObject:
|
|
149
|
+
buildLayerObject: layer => {
|
|
367
150
|
//if (self.baseLayers.indexOf(layer.id) === -1) {
|
|
368
151
|
//let paint = {};
|
|
369
152
|
//let values = layer.paint?._values;
|
|
@@ -404,18 +187,16 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
404
187
|
*
|
|
405
188
|
* @returns array
|
|
406
189
|
*/
|
|
407
|
-
buildLayerObjects:
|
|
408
|
-
return self.style._order.map(
|
|
190
|
+
buildLayerObjects: () => {
|
|
191
|
+
return self.style._order.map(layerId => {
|
|
409
192
|
return self.wrapper.buildLayerObject(self.map.style._layers[layerId]);
|
|
410
|
-
}).filter(
|
|
411
|
-
return n;
|
|
412
|
-
});
|
|
193
|
+
}).filter(n => n);
|
|
413
194
|
},
|
|
414
195
|
|
|
415
196
|
/**
|
|
416
197
|
* Updates layer state info objects
|
|
417
198
|
*/
|
|
418
|
-
refreshLayerState:
|
|
199
|
+
refreshLayerState: () => {
|
|
419
200
|
self.wrapper.layerState = self.wrapper.buildLayerObjects();
|
|
420
201
|
|
|
421
202
|
if (JSON.stringify(self.wrapper.layerState) !== self.wrapper.layerStateString) {
|
|
@@ -438,24 +219,23 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
438
219
|
* Previous version of viewportStateString
|
|
439
220
|
*/
|
|
440
221
|
oldViewportStateString: "{}",
|
|
441
|
-
getViewport:
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
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: () => {
|
|
459
239
|
self.wrapper.viewportState = self.wrapper.getViewport();
|
|
460
240
|
}
|
|
461
241
|
};
|
|
@@ -466,7 +246,7 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
466
246
|
* @param {boolean} force
|
|
467
247
|
*/
|
|
468
248
|
|
|
469
|
-
this.initRegisteredElements =
|
|
249
|
+
this.initRegisteredElements = (componentId, force) => {
|
|
470
250
|
if (typeof self.registeredElements[componentId] === "undefined" || force !== "undefined" && force) {
|
|
471
251
|
self.registeredElements[componentId] = {
|
|
472
252
|
layers: [],
|
|
@@ -488,7 +268,7 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
488
268
|
*/
|
|
489
269
|
|
|
490
270
|
|
|
491
|
-
this.addLayer =
|
|
271
|
+
this.addLayer = (layer, beforeId, componentId) => {
|
|
492
272
|
if (!self.map.style) {
|
|
493
273
|
return;
|
|
494
274
|
}
|
|
@@ -497,7 +277,7 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
497
277
|
self.initRegisteredElements(componentId);
|
|
498
278
|
self.registeredElements[componentId].layers.push(layer.id);
|
|
499
279
|
|
|
500
|
-
if (
|
|
280
|
+
if (typeof layer.source === "object") {
|
|
501
281
|
self.registeredElements[componentId].sources.push(layer.id);
|
|
502
282
|
}
|
|
503
283
|
}
|
|
@@ -515,7 +295,7 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
515
295
|
*/
|
|
516
296
|
|
|
517
297
|
|
|
518
|
-
this.addSource =
|
|
298
|
+
this.addSource = (sourceId, source, options, componentId) => {
|
|
519
299
|
if (!self.map.style) {
|
|
520
300
|
return;
|
|
521
301
|
}
|
|
@@ -542,7 +322,7 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
542
322
|
*/
|
|
543
323
|
|
|
544
324
|
|
|
545
|
-
this.addImage =
|
|
325
|
+
this.addImage = (id, image, ref, componentId) => {
|
|
546
326
|
if (!self.map.style) {
|
|
547
327
|
return;
|
|
548
328
|
}
|
|
@@ -569,14 +349,12 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
569
349
|
*/
|
|
570
350
|
|
|
571
351
|
|
|
572
|
-
this.on =
|
|
573
|
-
var _self$map;
|
|
574
|
-
|
|
352
|
+
this.on = (type, layerId, listener, componentId) => {
|
|
575
353
|
if (typeof listener === "string" && typeof layerId === "function") {
|
|
576
354
|
return self.on.call(self, type, undefined, layerId, listener);
|
|
577
355
|
}
|
|
578
356
|
|
|
579
|
-
|
|
357
|
+
let _arguments = [type, layerId, listener];
|
|
580
358
|
|
|
581
359
|
if (!layerId) {
|
|
582
360
|
_arguments = [type, listener];
|
|
@@ -587,7 +365,7 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
587
365
|
self.registeredElements[componentId].events.push(_arguments);
|
|
588
366
|
}
|
|
589
367
|
|
|
590
|
-
|
|
368
|
+
self.map.on(..._arguments);
|
|
591
369
|
};
|
|
592
370
|
/**
|
|
593
371
|
* Overrides MapLibre-gl-js addControl function providing an additional componentId parameter for the wrapper element registration.
|
|
@@ -598,7 +376,7 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
598
376
|
*/
|
|
599
377
|
|
|
600
378
|
|
|
601
|
-
this.addControl =
|
|
379
|
+
this.addControl = (control, position, componentId) => {
|
|
602
380
|
if (componentId && typeof componentId === "string") {
|
|
603
381
|
self.initRegisteredElements(componentId);
|
|
604
382
|
self.registeredElements[componentId].controls.push(control);
|
|
@@ -613,177 +391,144 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
613
391
|
*/
|
|
614
392
|
|
|
615
393
|
|
|
616
|
-
this.cleanup =
|
|
394
|
+
this.cleanup = componentId => {
|
|
617
395
|
if (self.map.style && typeof self.registeredElements[componentId] !== "undefined") {
|
|
618
396
|
// cleanup layers
|
|
619
|
-
self.registeredElements[componentId].layers.forEach(
|
|
397
|
+
self.registeredElements[componentId].layers.forEach(item => {
|
|
620
398
|
if (self.map.style.getLayer(item)) {
|
|
621
399
|
self.map.style.removeLayer(item);
|
|
622
400
|
}
|
|
623
401
|
}); // cleanup sources
|
|
624
402
|
|
|
625
|
-
self.registeredElements[componentId].sources.forEach(
|
|
403
|
+
self.registeredElements[componentId].sources.forEach(item => {
|
|
626
404
|
if (self.map.style.getSource(item)) {
|
|
627
405
|
self.map.style.removeSource(item);
|
|
628
406
|
}
|
|
629
407
|
}); // cleanup images
|
|
630
408
|
|
|
631
|
-
self.registeredElements[componentId].images.forEach(
|
|
409
|
+
self.registeredElements[componentId].images.forEach(item => {
|
|
632
410
|
if (self.map.hasImage(item)) {
|
|
633
411
|
self.map.style.removeImage(item);
|
|
634
412
|
}
|
|
635
413
|
}); // cleanup events
|
|
636
414
|
|
|
637
|
-
self.registeredElements[componentId].events.forEach(
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
(_self$map2 = self.map).off.apply(_self$map2, _toConsumableArray(item));
|
|
415
|
+
self.registeredElements[componentId].events.forEach(item => {
|
|
416
|
+
self.map.off(...item);
|
|
641
417
|
}); // cleanup controls
|
|
642
418
|
|
|
643
|
-
self.registeredElements[componentId].controls.forEach(
|
|
419
|
+
self.registeredElements[componentId].controls.forEach(item => {
|
|
644
420
|
self.map.removeControl(item);
|
|
645
421
|
}); // cleanup wrapper events
|
|
646
422
|
|
|
647
|
-
self.registeredElements[componentId].wrapperEvents.forEach(
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
(_self$wrapper = self.wrapper).off.apply(_self$wrapper, _toConsumableArray(item));
|
|
423
|
+
self.registeredElements[componentId].wrapperEvents.forEach(item => {
|
|
424
|
+
self.wrapper.off(...item);
|
|
651
425
|
});
|
|
652
426
|
self.initRegisteredElements(componentId, true);
|
|
653
427
|
}
|
|
654
428
|
}; // add style prop functions that require map._update to be called afterwards
|
|
655
429
|
|
|
656
430
|
|
|
657
|
-
|
|
658
|
-
updatingStyleFunctions.forEach(
|
|
659
|
-
|
|
431
|
+
let updatingStyleFunctions = ["moveLayer", "removeLayer", "removeSource", "setPaintProperty", "setLayoutProperty"];
|
|
432
|
+
updatingStyleFunctions.forEach(item => {
|
|
433
|
+
this[item] = function () {
|
|
660
434
|
if (self.map && _this.map.style && typeof self.map.style[item] === "function") {
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
(_self$map$style = self.map.style)[item].apply(_self$map$style, arguments);
|
|
435
|
+
self.map.style[item](...arguments);
|
|
664
436
|
}
|
|
665
437
|
|
|
666
438
|
return self.map._update ? self.map._update(true) : undefined;
|
|
667
439
|
};
|
|
668
440
|
}); // add style prop functions
|
|
669
441
|
|
|
670
|
-
|
|
671
|
-
styleFunctions.forEach(
|
|
672
|
-
|
|
442
|
+
let styleFunctions = ["getLayer", "getSource", "listImages", "getPaintProperty", "getLayoutProperty", "removeImage"];
|
|
443
|
+
styleFunctions.forEach(item => {
|
|
444
|
+
this[item] = function () {
|
|
673
445
|
if (self.map && self.map.style) {
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
return (_self$map$style2 = self.map.style)[item].apply(_self$map$style2, arguments);
|
|
446
|
+
return self.map.style[item](...arguments);
|
|
677
447
|
}
|
|
678
448
|
|
|
679
449
|
return false;
|
|
680
450
|
};
|
|
681
451
|
});
|
|
682
452
|
|
|
683
|
-
this.addNativeMaplibreFunctionsAndProps =
|
|
453
|
+
this.addNativeMaplibreFunctionsAndProps = () => {
|
|
684
454
|
// add MapLibre-gl functions
|
|
685
|
-
Object.getOwnPropertyNames(Object.getPrototypeOf(
|
|
686
|
-
if (typeof
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
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);
|
|
691
459
|
};
|
|
692
460
|
}
|
|
693
461
|
}); // add MapLibre-gl properties
|
|
694
462
|
|
|
695
|
-
Object.keys(
|
|
696
|
-
if (typeof
|
|
697
|
-
|
|
463
|
+
Object.keys(this.map).forEach(item => {
|
|
464
|
+
if (typeof this[item] === "undefined") {
|
|
465
|
+
this[item] = self.map[item];
|
|
698
466
|
}
|
|
699
467
|
});
|
|
700
468
|
}; // add functions that are missing on the MapLibre instances prototype
|
|
701
469
|
|
|
702
470
|
|
|
703
|
-
|
|
704
|
-
missingFunctions.forEach(
|
|
705
|
-
|
|
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 () {
|
|
706
474
|
if (typeof self.map[item] === "function") {
|
|
707
|
-
var _self$map$item;
|
|
708
|
-
|
|
709
475
|
for (var _len = arguments.length, props = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
710
476
|
props[_key] = arguments[_key];
|
|
711
477
|
}
|
|
712
478
|
|
|
713
|
-
return
|
|
479
|
+
return self.map[item].call(self.map, ...props);
|
|
714
480
|
}
|
|
715
481
|
|
|
716
482
|
return undefined;
|
|
717
483
|
};
|
|
718
484
|
}); // initialize the MapLibre-gl instance
|
|
719
485
|
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
return fetch(props.mapOptions.style).then(function (response) {
|
|
733
|
-
if (response.ok) {
|
|
734
|
-
return response.json();
|
|
735
|
-
} else {
|
|
736
|
-
throw new Error("error loading map style.json");
|
|
737
|
-
}
|
|
738
|
-
}).then(function (styleJson) {
|
|
739
|
-
styleJson.layers.forEach(function (item) {
|
|
740
|
-
self.baseLayers.push(item.id);
|
|
741
|
-
|
|
742
|
-
if (!self.firstSymbolLayer && item.type === "symbol") {
|
|
743
|
-
self.firstSymbolLayer = item.id;
|
|
744
|
-
}
|
|
745
|
-
});
|
|
746
|
-
self.styleJson = styleJson;
|
|
747
|
-
props.mapOptions.style = styleJson;
|
|
748
|
-
}).catch(function (error) {
|
|
749
|
-
console.log(error);
|
|
750
|
-
});
|
|
751
|
-
|
|
752
|
-
case 3:
|
|
753
|
-
self.map = new maplibregl.Map(props.mapOptions);
|
|
754
|
-
self.addNativeMaplibreFunctionsAndProps();
|
|
755
|
-
self.wrapper.refreshViewport();
|
|
756
|
-
self.wrapper.fire("viewportchange");
|
|
757
|
-
self.map.on("load", function () {
|
|
758
|
-
self.addNativeMaplibreFunctionsAndProps();
|
|
759
|
-
});
|
|
760
|
-
self.map.on("move", function () {
|
|
761
|
-
self.wrapper.viewportState = self.wrapper.getViewport();
|
|
762
|
-
self.wrapper.fire("viewportchange");
|
|
763
|
-
});
|
|
764
|
-
self.map.on("idle", function () {
|
|
765
|
-
self.wrapper.refreshLayerState();
|
|
766
|
-
});
|
|
767
|
-
self.map.on("data", function () {
|
|
768
|
-
self.wrapper.refreshLayerState();
|
|
769
|
-
});
|
|
770
|
-
|
|
771
|
-
if (typeof props.onReady === "function") {
|
|
772
|
-
props.onReady(self.map, self);
|
|
773
|
-
}
|
|
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);
|
|
774
498
|
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
return _context.stop();
|
|
499
|
+
if (!self.firstSymbolLayer && item.type === "symbol") {
|
|
500
|
+
self.firstSymbolLayer = item.id;
|
|
778
501
|
}
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
|
|
502
|
+
});
|
|
503
|
+
self.styleJson = styleJson;
|
|
504
|
+
props.mapOptions.style = styleJson;
|
|
505
|
+
}).catch(error => {
|
|
506
|
+
console.log(error);
|
|
507
|
+
});
|
|
508
|
+
}
|
|
782
509
|
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
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
|
+
};
|
|
787
532
|
|
|
788
533
|
initializeMapLibre();
|
|
789
534
|
};
|
|
@@ -799,17 +544,17 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
|
|
|
799
544
|
* @component
|
|
800
545
|
*/
|
|
801
546
|
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
useEffect(
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
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 () => {
|
|
813
558
|
var _map$current, _map$current$remove;
|
|
814
559
|
|
|
815
560
|
_mapContext.removeMap(mapId);
|
|
@@ -818,14 +563,15 @@ var MapLibreMap = function MapLibreMap(props) {
|
|
|
818
563
|
map.current = null;
|
|
819
564
|
};
|
|
820
565
|
}, []);
|
|
821
|
-
useEffect(
|
|
566
|
+
useEffect(() => {
|
|
822
567
|
if (mapContainer.current) {
|
|
823
568
|
map.current = new MapLibreGlWrapper({
|
|
824
|
-
mapOptions:
|
|
825
|
-
container: mapContainer.current
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
569
|
+
mapOptions: {
|
|
570
|
+
container: mapContainer.current,
|
|
571
|
+
...mapOptions
|
|
572
|
+
},
|
|
573
|
+
onReady: (map, wrapper) => {
|
|
574
|
+
map.once("load", () => {
|
|
829
575
|
if (props.mapId) {
|
|
830
576
|
mapContext.registerMap(props.mapId, wrapper);
|
|
831
577
|
} else {
|
|
@@ -876,25 +622,15 @@ MapLibreMap.propTypes = {
|
|
|
876
622
|
|
|
877
623
|
function useMapState(props) {
|
|
878
624
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
var viewportRef = useRef(undefined);
|
|
889
|
-
|
|
890
|
-
var _useState3 = useState(undefined),
|
|
891
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
892
|
-
layers = _useState4[0],
|
|
893
|
-
setLayers = _useState4[1];
|
|
894
|
-
|
|
895
|
-
var layersRef = useRef(undefined); //const mapRef = useRef(props.map);
|
|
896
|
-
|
|
897
|
-
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());
|
|
898
634
|
/**
|
|
899
635
|
* returns the element if it matches the defined filter criteria
|
|
900
636
|
* to be used as filter function on the layers array
|
|
@@ -902,7 +638,7 @@ function useMapState(props) {
|
|
|
902
638
|
* @param {object} layer
|
|
903
639
|
*/
|
|
904
640
|
|
|
905
|
-
|
|
641
|
+
const layerIdFilter = useCallback(layer => {
|
|
906
642
|
var _props$filter, _props$filter2;
|
|
907
643
|
|
|
908
644
|
if (!(props !== null && props !== void 0 && (_props$filter = props.filter) !== null && _props$filter !== void 0 && _props$filter.includeBaseLayers) && layer.baseLayer) {
|
|
@@ -919,19 +655,19 @@ function useMapState(props) {
|
|
|
919
655
|
|
|
920
656
|
return true;
|
|
921
657
|
}, [props.filter]);
|
|
922
|
-
|
|
923
|
-
|
|
658
|
+
const refreshLayerState = useCallback(() => {
|
|
659
|
+
let _layerState = mapRef.current.wrapper.layerState.filter(layerIdFilter);
|
|
924
660
|
|
|
925
|
-
|
|
661
|
+
let _layerStateString = JSON.stringify(_layerState);
|
|
926
662
|
|
|
927
663
|
if (layersRef.current !== _layerStateString) {
|
|
928
664
|
layersRef.current = _layerStateString;
|
|
929
665
|
setLayers(_layerState);
|
|
930
666
|
}
|
|
931
667
|
}, [layerIdFilter]);
|
|
932
|
-
useEffect(
|
|
933
|
-
|
|
934
|
-
return
|
|
668
|
+
useEffect(() => {
|
|
669
|
+
let _componentId = componentId.current;
|
|
670
|
+
return () => {
|
|
935
671
|
// cleanup all event listeners
|
|
936
672
|
if (mapRef.current) {
|
|
937
673
|
mapRef.current.cleanup(_componentId);
|
|
@@ -941,7 +677,7 @@ function useMapState(props) {
|
|
|
941
677
|
initializedRef.current = false;
|
|
942
678
|
};
|
|
943
679
|
}, []);
|
|
944
|
-
useEffect(
|
|
680
|
+
useEffect(() => {
|
|
945
681
|
var _props$watch, _props$watch2;
|
|
946
682
|
|
|
947
683
|
if (!mapContext.mapExists(props.mapId) || initializedRef.current) return; // the MapLibre-gl instance (mapContext.getMap(props.mapId)) is accessible here
|
|
@@ -953,7 +689,7 @@ function useMapState(props) {
|
|
|
953
689
|
if (props !== null && props !== void 0 && (_props$watch = props.watch) !== null && _props$watch !== void 0 && _props$watch.viewport) {
|
|
954
690
|
setViewport(mapRef.current.wrapper.viewportState); // register viewportchange event handler
|
|
955
691
|
|
|
956
|
-
mapRef.current.wrapper.on("viewportchange",
|
|
692
|
+
mapRef.current.wrapper.on("viewportchange", () => {
|
|
957
693
|
var _mapRef$current;
|
|
958
694
|
|
|
959
695
|
if (viewportRef.current !== ((_mapRef$current = mapRef.current) === null || _mapRef$current === void 0 ? void 0 : _mapRef$current.wrapper.viewportStateString)) {
|
|
@@ -976,8 +712,8 @@ function useMapState(props) {
|
|
|
976
712
|
}
|
|
977
713
|
}, [mapContext.mapIds, mapContext, props.mapId, refreshLayerState, props]);
|
|
978
714
|
return {
|
|
979
|
-
layers
|
|
980
|
-
viewport
|
|
715
|
+
layers,
|
|
716
|
+
viewport
|
|
981
717
|
};
|
|
982
718
|
}
|
|
983
719
|
|
|
@@ -1021,8 +757,8 @@ useMapState.propTypes = {
|
|
|
1021
757
|
|
|
1022
758
|
function useMap(props) {
|
|
1023
759
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
1024
|
-
|
|
1025
|
-
|
|
760
|
+
const mapContext = useContext(MapContext);
|
|
761
|
+
const mapState = useMapState({
|
|
1026
762
|
mapId: props.mapId,
|
|
1027
763
|
watch: {
|
|
1028
764
|
viewport: false,
|
|
@@ -1033,18 +769,13 @@ function useMap(props) {
|
|
|
1033
769
|
includeBaseLayers: true
|
|
1034
770
|
}
|
|
1035
771
|
});
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
setMapIsReady = _useState2[1];
|
|
1044
|
-
|
|
1045
|
-
useEffect(function () {
|
|
1046
|
-
var _componentId = componentId.current;
|
|
1047
|
-
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 () => {
|
|
1048
779
|
if (mapRef.current) {
|
|
1049
780
|
mapRef.current.cleanup(_componentId);
|
|
1050
781
|
mapRef.current = undefined;
|
|
@@ -1054,15 +785,15 @@ function useMap(props) {
|
|
|
1054
785
|
setMapIsReady(false);
|
|
1055
786
|
};
|
|
1056
787
|
}, []);
|
|
1057
|
-
useEffect(
|
|
788
|
+
useEffect(() => {
|
|
1058
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)
|
|
1059
790
|
// exists as layer in the MapLibre instance
|
|
1060
791
|
|
|
1061
792
|
if (props.waitForLayer) {
|
|
1062
793
|
var _mapState$layers;
|
|
1063
794
|
|
|
1064
|
-
|
|
1065
|
-
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 => {
|
|
1066
797
|
if (layer.id === props.waitForLayer) {
|
|
1067
798
|
layerFound = true;
|
|
1068
799
|
}
|
|
@@ -1081,7 +812,7 @@ function useMap(props) {
|
|
|
1081
812
|
}, [mapContext.mapIds, mapState.layers, mapContext, props.waitForLayer, props.mapId]);
|
|
1082
813
|
return {
|
|
1083
814
|
map: mapRef.current,
|
|
1084
|
-
mapIsReady
|
|
815
|
+
mapIsReady,
|
|
1085
816
|
componentId: componentId.current,
|
|
1086
817
|
layers: mapState.layers
|
|
1087
818
|
};
|
|
@@ -1096,13 +827,13 @@ function useMap(props) {
|
|
|
1096
827
|
* @component
|
|
1097
828
|
*/
|
|
1098
829
|
|
|
1099
|
-
|
|
1100
|
-
|
|
830
|
+
const MlComponentTemplate = props => {
|
|
831
|
+
const mapHook = useMap({
|
|
1101
832
|
mapId: props.mapId,
|
|
1102
833
|
waitForLayer: props.insertBeforeLayer
|
|
1103
834
|
});
|
|
1104
|
-
|
|
1105
|
-
useEffect(
|
|
835
|
+
const initializedRef = useRef(false);
|
|
836
|
+
useEffect(() => {
|
|
1106
837
|
if (!mapHook.mapIsReady || initializedRef.current) return; // the MapLibre-gl instance (mapHook.map) is accessible here
|
|
1107
838
|
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
1108
839
|
|
|
@@ -1128,21 +859,16 @@ MlComponentTemplate.propTypes = {
|
|
|
1128
859
|
* @Component
|
|
1129
860
|
*/
|
|
1130
861
|
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
var initializedRef = useRef(false);
|
|
1142
|
-
var layerId = useRef(props.layerId || "MlFillExtrusionLayer-" + v4());
|
|
1143
|
-
useEffect(function () {
|
|
1144
|
-
var _componentId = componentId.current;
|
|
1145
|
-
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 () => {
|
|
1146
872
|
if (mapRef.current) {
|
|
1147
873
|
mapRef.current.cleanup(_componentId);
|
|
1148
874
|
mapRef.current = undefined;
|
|
@@ -1151,13 +877,13 @@ var MlFillExtrusionLayer = function MlFillExtrusionLayer(props) {
|
|
|
1151
877
|
initializedRef.current = false;
|
|
1152
878
|
};
|
|
1153
879
|
}, []);
|
|
1154
|
-
useEffect(
|
|
880
|
+
useEffect(() => {
|
|
1155
881
|
if (!mapContext.mapExists(props.mapId) || initializedRef.current) return; // the MapLibre-gl instance (mapContext.getMap(props.mapId)) is accessible here
|
|
1156
882
|
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
1157
883
|
|
|
1158
884
|
initializedRef.current = true;
|
|
1159
885
|
mapRef.current = mapContext.getMap(props.mapId);
|
|
1160
|
-
|
|
886
|
+
let lastLabelLayerId = undefined;
|
|
1161
887
|
|
|
1162
888
|
if (mapContext.map.getLayer("waterway-name")) {
|
|
1163
889
|
lastLabelLayerId = "waterway-name";
|
|
@@ -1173,10 +899,11 @@ var MlFillExtrusionLayer = function MlFillExtrusionLayer(props) {
|
|
|
1173
899
|
source: props.sourceId || "openmaptiles",
|
|
1174
900
|
"source-layer": props.sourceLayer || "building",
|
|
1175
901
|
minzoom: props.minZoom || 14,
|
|
1176
|
-
paint:
|
|
902
|
+
paint: { ...props.paint
|
|
903
|
+
}
|
|
1177
904
|
}, props.insertBeforeLayer || lastLabelLayerId, componentId.current);
|
|
1178
905
|
}, [mapContext, props.insertBeforeLayer, props.mapId, props.minZoom, props.paint, props.sourceId, props.sourceLayer]);
|
|
1179
|
-
useEffect(
|
|
906
|
+
useEffect(() => {
|
|
1180
907
|
if (!initializedRef.current) return; // toggle layer visibility by changing the layout object's visibility property
|
|
1181
908
|
|
|
1182
909
|
mapRef.current.setLayoutProperty(layerId.current, "visibility", showLayer ? "visible" : "none");
|
|
@@ -1184,9 +911,7 @@ var MlFillExtrusionLayer = function MlFillExtrusionLayer(props) {
|
|
|
1184
911
|
return /*#__PURE__*/React__default.createElement(Button, {
|
|
1185
912
|
color: "primary",
|
|
1186
913
|
variant: showLayer ? "contained" : "outlined",
|
|
1187
|
-
onClick:
|
|
1188
|
-
return setShowLayer(!showLayer);
|
|
1189
|
-
}
|
|
914
|
+
onClick: () => setShowLayer(!showLayer)
|
|
1190
915
|
}, "Composite");
|
|
1191
916
|
};
|
|
1192
917
|
|
|
@@ -1255,7 +980,7 @@ MlFillExtrusionLayer.propTypes = {
|
|
|
1255
980
|
insertBeforeLayer: PropTypes.string
|
|
1256
981
|
};
|
|
1257
982
|
|
|
1258
|
-
|
|
983
|
+
const getDefaultPaintPropsByType = (type, defaultPaintOverrides) => {
|
|
1259
984
|
switch (type) {
|
|
1260
985
|
case "fill":
|
|
1261
986
|
if (defaultPaintOverrides !== null && defaultPaintOverrides !== void 0 && defaultPaintOverrides.fill) {
|
|
@@ -1290,7 +1015,7 @@ var getDefaultPaintPropsByType = function getDefaultPaintPropsByType(type, defau
|
|
|
1290
1015
|
}
|
|
1291
1016
|
};
|
|
1292
1017
|
|
|
1293
|
-
|
|
1018
|
+
const mapGeometryTypesToLayerTypes = {
|
|
1294
1019
|
Position: "circle",
|
|
1295
1020
|
Point: "circle",
|
|
1296
1021
|
MultiPoint: "circle",
|
|
@@ -1301,7 +1026,7 @@ var mapGeometryTypesToLayerTypes = {
|
|
|
1301
1026
|
GeometryCollection: "circle"
|
|
1302
1027
|
};
|
|
1303
1028
|
|
|
1304
|
-
|
|
1029
|
+
const getDefaulLayerTypeByGeometry = geojson => {
|
|
1305
1030
|
if ((geojson === null || geojson === void 0 ? void 0 : geojson.type) === "Feature") {
|
|
1306
1031
|
var _geojson$geometry;
|
|
1307
1032
|
|
|
@@ -1317,48 +1042,48 @@ var getDefaulLayerTypeByGeometry = function getDefaulLayerTypeByGeometry(geojson
|
|
|
1317
1042
|
}
|
|
1318
1043
|
};
|
|
1319
1044
|
|
|
1320
|
-
|
|
1045
|
+
const legalLayerTypes = ["circle", "fill", "line"];
|
|
1321
1046
|
/**
|
|
1322
1047
|
* Adds source and layer of types "line", "fill" or "circle" to display GeoJSON data on the map.
|
|
1323
1048
|
*
|
|
1324
1049
|
* @component
|
|
1325
1050
|
*/
|
|
1326
1051
|
|
|
1327
|
-
|
|
1052
|
+
const MlGeoJsonLayer = props => {
|
|
1328
1053
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
1329
|
-
|
|
1054
|
+
const mapHook = useMap({
|
|
1330
1055
|
mapId: props.mapId,
|
|
1331
1056
|
waitForLayer: props.insertBeforeLayer
|
|
1332
1057
|
});
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
useEffect(
|
|
1058
|
+
const initializedRef = useRef(false);
|
|
1059
|
+
const layerId = useRef(props.layerId || "MlGeoJsonLayer-" + mapHook.componentId);
|
|
1060
|
+
const layerTypeRef = useRef(undefined);
|
|
1061
|
+
useEffect(() => {
|
|
1337
1062
|
if (!mapHook.map || !initializedRef.current) return;
|
|
1338
1063
|
|
|
1339
1064
|
for (var key in props.layout) {
|
|
1340
1065
|
mapHook.map.setLayoutProperty(layerId.current, key, props.layout[key]);
|
|
1341
1066
|
}
|
|
1342
1067
|
}, [props.layout, mapHook.map, props.mapId]);
|
|
1343
|
-
useEffect(
|
|
1068
|
+
useEffect(() => {
|
|
1344
1069
|
if (!mapHook.map || !initializedRef.current) return;
|
|
1345
1070
|
|
|
1346
|
-
|
|
1071
|
+
let _paint = props.paint || getDefaultPaintPropsByType(layerTypeRef.current, props.defaultPaintOverrides);
|
|
1347
1072
|
|
|
1348
1073
|
for (var key in _paint) {
|
|
1349
1074
|
mapHook.map.setPaintProperty(layerId.current, key, _paint[key]);
|
|
1350
1075
|
}
|
|
1351
1076
|
}, [props.paint, mapHook.map, props.mapId, props.defaultPaintOverrides]);
|
|
1352
|
-
useEffect(
|
|
1077
|
+
useEffect(() => {
|
|
1353
1078
|
var _mapHook$map;
|
|
1354
1079
|
|
|
1355
1080
|
if (!(mapHook !== null && mapHook !== void 0 && (_mapHook$map = mapHook.map) !== null && _mapHook$map !== void 0 && _mapHook$map.getSource(layerId.current)) || !initializedRef.current) return;
|
|
1356
1081
|
mapHook.map.getSource(layerId.current).setData(props.geojson);
|
|
1357
1082
|
}, [props.geojson, mapHook.map, props.type]);
|
|
1358
|
-
|
|
1359
|
-
|
|
1083
|
+
const createLayer = useCallback(() => {
|
|
1084
|
+
let geojson = props.geojson;
|
|
1360
1085
|
layerTypeRef.current = props.type || getDefaulLayerTypeByGeometry(props.geojson);
|
|
1361
|
-
mapHook.map.addLayer(
|
|
1086
|
+
mapHook.map.addLayer({
|
|
1362
1087
|
id: layerId.current,
|
|
1363
1088
|
source: {
|
|
1364
1089
|
type: "geojson",
|
|
@@ -1366,8 +1091,9 @@ var MlGeoJsonLayer = function MlGeoJsonLayer(props) {
|
|
|
1366
1091
|
},
|
|
1367
1092
|
type: layerTypeRef.current,
|
|
1368
1093
|
paint: props.paint || getDefaultPaintPropsByType(layerTypeRef.current, props.defaultPaintOverrides),
|
|
1369
|
-
layout: props.layout || {}
|
|
1370
|
-
|
|
1094
|
+
layout: props.layout || {},
|
|
1095
|
+
...props.options
|
|
1096
|
+
}, props.insertBeforeLayer, mapHook.componentId);
|
|
1371
1097
|
|
|
1372
1098
|
if (typeof props.onHover !== "undefined") {
|
|
1373
1099
|
mapHook.map.on("mousemove", layerId.current, props.onHover, mapHook.componentId);
|
|
@@ -1381,7 +1107,7 @@ var MlGeoJsonLayer = function MlGeoJsonLayer(props) {
|
|
|
1381
1107
|
mapHook.map.on("mouseleave", layerId.current, props.onLeave, mapHook.componentId);
|
|
1382
1108
|
}
|
|
1383
1109
|
}, [mapHook, props]);
|
|
1384
|
-
useEffect(
|
|
1110
|
+
useEffect(() => {
|
|
1385
1111
|
if (!mapHook.map || !props.geojson) return;
|
|
1386
1112
|
|
|
1387
1113
|
if (initializedRef.current && legalLayerTypes.indexOf(props.type) !== -1 && layerTypeRef.current && props.type !== layerTypeRef.current) {
|
|
@@ -1480,38 +1206,17 @@ MlGeoJsonLayer.propTypes = {
|
|
|
1480
1206
|
* @component
|
|
1481
1207
|
*/
|
|
1482
1208
|
|
|
1483
|
-
|
|
1484
|
-
|
|
1209
|
+
const MlFollowGps = props => {
|
|
1210
|
+
const mapHook = useMap({
|
|
1485
1211
|
mapId: props.mapId,
|
|
1486
1212
|
waitForLayer: props.insertBeforeLayer
|
|
1487
1213
|
});
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
var _useState3 = useState(undefined),
|
|
1495
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
1496
|
-
userLocationGeoJson = _useState4[0],
|
|
1497
|
-
setUserLocationGeoJson = _useState4[1];
|
|
1498
|
-
|
|
1499
|
-
var _useState5 = useState(false),
|
|
1500
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
1501
|
-
locationAccessDenied = _useState6[0],
|
|
1502
|
-
setLocationAccessDenied = _useState6[1];
|
|
1503
|
-
|
|
1504
|
-
var _useState7 = useState(),
|
|
1505
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
1506
|
-
accuracyGeoJson = _useState8[0],
|
|
1507
|
-
setAccuracyGeoJson = _useState8[1];
|
|
1508
|
-
|
|
1509
|
-
var _useState9 = useState(0),
|
|
1510
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
1511
|
-
deviceOrientation = _useState10[0],
|
|
1512
|
-
setDeviceOrientation = _useState10[1];
|
|
1513
|
-
|
|
1514
|
-
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 => {
|
|
1515
1220
|
if (!mapHook.map) return;
|
|
1516
1221
|
mapHook.map.flyTo({
|
|
1517
1222
|
center: [pos.coords.longitude, pos.coords.latitude],
|
|
@@ -1520,54 +1225,54 @@ var MlFollowGps = function MlFollowGps(props) {
|
|
|
1520
1225
|
curve: 1
|
|
1521
1226
|
});
|
|
1522
1227
|
if (!props.showUserLocation) return;
|
|
1523
|
-
|
|
1228
|
+
const geoJsonPoint = point([pos.coords.longitude, pos.coords.latitude]);
|
|
1524
1229
|
setUserLocationGeoJson(geoJsonPoint);
|
|
1525
1230
|
setAccuracyGeoJson(circle(geoJsonPoint, pos.coords.accuracy / 1000));
|
|
1526
1231
|
}, [mapHook.map, props]);
|
|
1527
1232
|
|
|
1528
|
-
|
|
1233
|
+
const getLocationError = err => {
|
|
1529
1234
|
console.log("Access of user location denied");
|
|
1530
1235
|
setLocationAccessDenied(true);
|
|
1531
1236
|
};
|
|
1532
1237
|
|
|
1533
|
-
|
|
1238
|
+
const orientationCone = useMemo(() => {
|
|
1534
1239
|
if (!userLocationGeoJson) {
|
|
1535
1240
|
return undefined;
|
|
1536
1241
|
}
|
|
1537
1242
|
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1243
|
+
let radius = 0.02;
|
|
1244
|
+
let bearing1 = deviceOrientation - 15;
|
|
1245
|
+
let bearing2 = deviceOrientation + 15;
|
|
1246
|
+
const options = {
|
|
1542
1247
|
steps: 65
|
|
1543
1248
|
};
|
|
1544
|
-
|
|
1545
|
-
|
|
1249
|
+
let arc = lineArc(userLocationGeoJson, radius, bearing1, bearing2, options);
|
|
1250
|
+
let copy = arc;
|
|
1546
1251
|
copy.geometry.coordinates.push(userLocationGeoJson.geometry.coordinates);
|
|
1547
1252
|
copy.geometry.coordinates.slice(0, 0, userLocationGeoJson.geometry.coordinates);
|
|
1548
1253
|
return copy;
|
|
1549
1254
|
}, [deviceOrientation, userLocationGeoJson]);
|
|
1550
1255
|
|
|
1551
|
-
|
|
1256
|
+
const handleOrientation = event => {
|
|
1552
1257
|
setDeviceOrientation(-event.alpha);
|
|
1553
1258
|
};
|
|
1554
1259
|
|
|
1555
|
-
useEffect(
|
|
1260
|
+
useEffect(() => {
|
|
1556
1261
|
if (isFollowed) {
|
|
1557
|
-
|
|
1262
|
+
let _handleOrientation = handleOrientation;
|
|
1558
1263
|
window.addEventListener('deviceorientation', _handleOrientation);
|
|
1559
|
-
return
|
|
1264
|
+
return () => {
|
|
1560
1265
|
window.removeEventListener('deviceorientation', _handleOrientation);
|
|
1561
1266
|
};
|
|
1562
1267
|
}
|
|
1563
1268
|
}, [isFollowed]);
|
|
1564
|
-
useEffect(
|
|
1269
|
+
useEffect(() => {
|
|
1565
1270
|
if (!mapHook.map) return;
|
|
1566
1271
|
|
|
1567
1272
|
if (isFollowed) {
|
|
1568
|
-
|
|
1273
|
+
let _watchId = navigator.geolocation.watchPosition(getLocationSuccess, getLocationError);
|
|
1569
1274
|
|
|
1570
|
-
return
|
|
1275
|
+
return () => {
|
|
1571
1276
|
navigator.geolocation.clearWatch(_watchId);
|
|
1572
1277
|
};
|
|
1573
1278
|
}
|
|
@@ -1575,10 +1280,11 @@ var MlFollowGps = function MlFollowGps(props) {
|
|
|
1575
1280
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, isFollowed && userLocationGeoJson && /*#__PURE__*/React__default.createElement(MlGeoJsonLayer, {
|
|
1576
1281
|
geojson: accuracyGeoJson,
|
|
1577
1282
|
type: "fill",
|
|
1578
|
-
paint:
|
|
1283
|
+
paint: {
|
|
1579
1284
|
"fill-color": "#cbd300",
|
|
1580
|
-
"fill-opacity": 0.3
|
|
1581
|
-
|
|
1285
|
+
"fill-opacity": 0.3,
|
|
1286
|
+
...props.accuracyPaint
|
|
1287
|
+
},
|
|
1582
1288
|
insertBeforeLayer: props.insertBeforeLayer
|
|
1583
1289
|
}), isFollowed && orientationCone && /*#__PURE__*/React__default.createElement(MlGeoJsonLayer, {
|
|
1584
1290
|
geojson: orientationCone,
|
|
@@ -1592,20 +1298,22 @@ var MlFollowGps = function MlFollowGps(props) {
|
|
|
1592
1298
|
}), isFollowed && userLocationGeoJson && /*#__PURE__*/React__default.createElement(MlGeoJsonLayer, {
|
|
1593
1299
|
geojson: userLocationGeoJson,
|
|
1594
1300
|
type: "circle",
|
|
1595
|
-
paint:
|
|
1301
|
+
paint: {
|
|
1596
1302
|
"circle-color": "#009ee0",
|
|
1597
1303
|
"circle-radius": 5,
|
|
1598
1304
|
"circle-stroke-color": "#fafaff",
|
|
1599
|
-
"circle-stroke-width": 1
|
|
1600
|
-
|
|
1305
|
+
"circle-stroke-width": 1,
|
|
1306
|
+
...props.circlePaint
|
|
1307
|
+
},
|
|
1601
1308
|
insertBeforeLayer: props.insertBeforeLayer
|
|
1602
1309
|
}), /*#__PURE__*/React__default.createElement(Button, {
|
|
1603
|
-
sx:
|
|
1310
|
+
sx: {
|
|
1604
1311
|
zIndex: 1002,
|
|
1605
|
-
color: isFollowed ? props.onColor : props.offColor
|
|
1606
|
-
|
|
1312
|
+
color: isFollowed ? props.onColor : props.offColor,
|
|
1313
|
+
...props.style
|
|
1314
|
+
},
|
|
1607
1315
|
disabled: locationAccessDenied,
|
|
1608
|
-
onClick:
|
|
1316
|
+
onClick: () => {
|
|
1609
1317
|
setIsFollowed(!isFollowed);
|
|
1610
1318
|
}
|
|
1611
1319
|
}, " ", /*#__PURE__*/React__default.createElement(GpsFixedIcon, {
|
|
@@ -1690,7 +1398,7 @@ MlFollowGps.propTypes = {
|
|
|
1690
1398
|
showOrientation: PropTypes.bool
|
|
1691
1399
|
};
|
|
1692
1400
|
|
|
1693
|
-
|
|
1401
|
+
const nmMap = {
|
|
1694
1402
|
street: ["footway", "street", "road", "street_name", "residential", "path", "pedestrian", "road_reference", "road_reference_intl", "square", "place"],
|
|
1695
1403
|
number: ["house_number", "street_number"],
|
|
1696
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"],
|
|
@@ -1698,11 +1406,11 @@ var nmMap = {
|
|
|
1698
1406
|
state: ["state", "province", "state_code"]
|
|
1699
1407
|
};
|
|
1700
1408
|
|
|
1701
|
-
|
|
1702
|
-
|
|
1409
|
+
const nmConverter = nmAddress => {
|
|
1410
|
+
const addressArr = [];
|
|
1703
1411
|
|
|
1704
|
-
for (
|
|
1705
|
-
nmMap[key].some(
|
|
1412
|
+
for (let key in nmMap) {
|
|
1413
|
+
nmMap[key].some(element => {
|
|
1706
1414
|
if (nmAddress.hasOwnProperty(element)) {
|
|
1707
1415
|
addressArr.push(nmAddress[element]);
|
|
1708
1416
|
return true;
|
|
@@ -1715,28 +1423,28 @@ var nmConverter = function nmConverter(nmAddress) {
|
|
|
1715
1423
|
return addressArr.join(", ");
|
|
1716
1424
|
};
|
|
1717
1425
|
|
|
1718
|
-
|
|
1719
|
-
|
|
1426
|
+
const toPixels = length => {
|
|
1427
|
+
let conversionFactor = 96;
|
|
1720
1428
|
conversionFactor /= 25.4;
|
|
1721
1429
|
return conversionFactor * length + "px";
|
|
1722
1430
|
};
|
|
1723
1431
|
|
|
1724
|
-
|
|
1432
|
+
const createPdf = (map, locationValue, setLoading) => {
|
|
1725
1433
|
setLoading(true);
|
|
1726
|
-
|
|
1727
|
-
|
|
1434
|
+
const width = 210;
|
|
1435
|
+
const height = 297; // Calculate pixel ratio
|
|
1728
1436
|
|
|
1729
|
-
|
|
1437
|
+
const actualPixelRatio = window.devicePixelRatio; // Create map container
|
|
1730
1438
|
|
|
1731
|
-
|
|
1439
|
+
const hidden = document.createElement("div");
|
|
1732
1440
|
hidden.className = "hidden-map";
|
|
1733
1441
|
document.body.appendChild(hidden);
|
|
1734
|
-
|
|
1442
|
+
const container = document.createElement("div");
|
|
1735
1443
|
container.style.width = toPixels(width);
|
|
1736
1444
|
container.style.height = toPixels(height);
|
|
1737
1445
|
hidden.appendChild(container); //Render map
|
|
1738
1446
|
|
|
1739
|
-
var renderMap = new maplibregl
|
|
1447
|
+
var renderMap = new maplibregl.Map({
|
|
1740
1448
|
container: container,
|
|
1741
1449
|
center: map.getCenter(),
|
|
1742
1450
|
zoom: map.getZoom(),
|
|
@@ -1747,21 +1455,17 @@ var createPdf = function createPdf(map, locationValue, setLoading) {
|
|
|
1747
1455
|
fadeDuration: 0,
|
|
1748
1456
|
attributionControl: false
|
|
1749
1457
|
});
|
|
1750
|
-
|
|
1458
|
+
let style = map.getStyle();
|
|
1751
1459
|
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
Object.keys(src).forEach(
|
|
1460
|
+
for (let name in style.sources) {
|
|
1461
|
+
let src = style.sources[name];
|
|
1462
|
+
Object.keys(src).forEach(key => {
|
|
1755
1463
|
//delete properties if value is undefined.
|
|
1756
1464
|
// for instance, raster-dem might has undefined value in "url" and "bounds"
|
|
1757
1465
|
if (!src[key]) {
|
|
1758
1466
|
delete src[key];
|
|
1759
1467
|
}
|
|
1760
1468
|
});
|
|
1761
|
-
};
|
|
1762
|
-
|
|
1763
|
-
for (var name in style.sources) {
|
|
1764
|
-
_loop(name);
|
|
1765
1469
|
}
|
|
1766
1470
|
|
|
1767
1471
|
renderMap.setStyle(style);
|
|
@@ -1769,32 +1473,32 @@ var createPdf = function createPdf(map, locationValue, setLoading) {
|
|
|
1769
1473
|
var _hidden$parentNode;
|
|
1770
1474
|
|
|
1771
1475
|
// TO DO: It is still under development
|
|
1772
|
-
|
|
1476
|
+
const pdf = new jsPDF({
|
|
1773
1477
|
orientation: "p",
|
|
1774
1478
|
unit: "mm",
|
|
1775
1479
|
compress: true
|
|
1776
1480
|
});
|
|
1777
1481
|
Object.defineProperty(window, "devicePixelRatio", {
|
|
1778
|
-
get: function
|
|
1482
|
+
get: function () {
|
|
1779
1483
|
return 300 / 96;
|
|
1780
1484
|
}
|
|
1781
1485
|
});
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
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/IECqHDmzGk25F0aqFUCxJzu2JEmqIkSvIEC0HjyqHEeuG0OzGkC2GD2uI0axIUO1IECtHz2xHUWzHEKtG0CwGj6zIkS1IUKyHz60HkSvHUKxHECzHD6uG0OxIU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NJ7khFHrdUk65cNgsh8wOhX4991GmFewVVs7nHTAiYil9tYO9Uuruh1F3n2GTONjr6dEwrnMevfrBXrEwwzGvig3GomXrvoP1HkQLJ6WV8II30OJ1XO0huQu/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 = [];
|
|
1793
1497
|
|
|
1794
1498
|
if (textChunks.length) {
|
|
1795
|
-
textChunksSeperator.forEach(
|
|
1796
|
-
|
|
1797
|
-
textChunks.push
|
|
1499
|
+
textChunksSeperator.forEach(chunk => {
|
|
1500
|
+
const limitChunks = chunk.match(/.{1,34}/g);
|
|
1501
|
+
textChunks.push(...limitChunks);
|
|
1798
1502
|
});
|
|
1799
1503
|
} //Render map image
|
|
1800
1504
|
|
|
@@ -1808,7 +1512,7 @@ var createPdf = function createPdf(map, locationValue, setLoading) {
|
|
|
1808
1512
|
pdf.text("Datenquelle: © OpenStreetMap-Mitwirkende", 140, pdf.internal.pageSize.height - 3); //Render infobox
|
|
1809
1513
|
|
|
1810
1514
|
pdf.setFillColor("white");
|
|
1811
|
-
|
|
1515
|
+
const infoBoxSize = textChunks.length * lineHeight + marginTop + marginBottom + lineHeight * 2 + innerMargin * 2 + textBuffer;
|
|
1812
1516
|
pdf.rect(offsetX, 2, 66.5, infoBoxSize, "F");
|
|
1813
1517
|
pdf.setFontSize(10);
|
|
1814
1518
|
pdf.text("Karten PDF:", 6, offsetY + marginTop); //Render inner infobox
|
|
@@ -1816,7 +1520,7 @@ var createPdf = function createPdf(map, locationValue, setLoading) {
|
|
|
1816
1520
|
pdf.rect(6, 7, 60, textChunks.length * lineHeight + innerMargin * 2 + textBuffer);
|
|
1817
1521
|
pdf.setFontSize(10); //Write out address
|
|
1818
1522
|
|
|
1819
|
-
textChunks.forEach(
|
|
1523
|
+
textChunks.forEach((text, i) => {
|
|
1820
1524
|
pdf.text(text.trim(), 8, 10 + i * 3.5 + innerMargin);
|
|
1821
1525
|
}); //Add WG Logo
|
|
1822
1526
|
|
|
@@ -1835,7 +1539,7 @@ var createPdf = function createPdf(map, locationValue, setLoading) {
|
|
|
1835
1539
|
renderMap.remove();
|
|
1836
1540
|
(_hidden$parentNode = hidden.parentNode) === null || _hidden$parentNode === void 0 ? void 0 : _hidden$parentNode.removeChild(hidden);
|
|
1837
1541
|
Object.defineProperty(window, "devicePixelRatio", {
|
|
1838
|
-
get: function
|
|
1542
|
+
get: function () {
|
|
1839
1543
|
return actualPixelRatio;
|
|
1840
1544
|
}
|
|
1841
1545
|
});
|
|
@@ -1849,11 +1553,11 @@ var createPdf = function createPdf(map, locationValue, setLoading) {
|
|
|
1849
1553
|
* @component
|
|
1850
1554
|
*/
|
|
1851
1555
|
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
useEffect(
|
|
1556
|
+
const MlCreatePdfButton = props => {
|
|
1557
|
+
const mapContext = useContext(MapContext);
|
|
1558
|
+
const initializedRef = useRef(false);
|
|
1559
|
+
const mapRef = useRef(undefined);
|
|
1560
|
+
useEffect(() => {
|
|
1857
1561
|
if (!mapContext.mapExists(props.mapId) || initializedRef.current) return;
|
|
1858
1562
|
initializedRef.current = true;
|
|
1859
1563
|
mapRef.current = mapContext.getMap(props.mapId);
|
|
@@ -1861,8 +1565,8 @@ var MlCreatePdfButton = function MlCreatePdfButton(props) {
|
|
|
1861
1565
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Button, {
|
|
1862
1566
|
color: "primary",
|
|
1863
1567
|
variant: "contained",
|
|
1864
|
-
onClick:
|
|
1865
|
-
createPdf(mapRef.current, null,
|
|
1568
|
+
onClick: () => {
|
|
1569
|
+
createPdf(mapRef.current, null, () => {});
|
|
1866
1570
|
}
|
|
1867
1571
|
}, /*#__PURE__*/React__default.createElement(PrinterIcon, null)));
|
|
1868
1572
|
};
|
|
@@ -1877,15 +1581,15 @@ MlCreatePdfButton.propTypes = {
|
|
|
1877
1581
|
mapId: PropTypes.string
|
|
1878
1582
|
};
|
|
1879
1583
|
|
|
1880
|
-
|
|
1881
|
-
|
|
1584
|
+
const MlImageMarkerLayer = props => {
|
|
1585
|
+
const mapHook = useMap({
|
|
1882
1586
|
mapId: props.mapId,
|
|
1883
1587
|
waitForLayer: props.insertBeforeLayer
|
|
1884
1588
|
});
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
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(() => {
|
|
1889
1593
|
if (!mapHook.mapIsReady || mapHook.map && !mapHook.map.getLayer(layerId.current) || !props.options) return; // the MapLibre-gl instance (mapContext.map) is accessible here
|
|
1890
1594
|
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
1891
1595
|
|
|
@@ -1903,16 +1607,16 @@ var MlImageMarkerLayer = function MlImageMarkerLayer(props) {
|
|
|
1903
1607
|
}
|
|
1904
1608
|
}
|
|
1905
1609
|
}, [props.options, layerId.current, props.mapId]);
|
|
1906
|
-
|
|
1907
|
-
|
|
1610
|
+
const addLayer = useCallback(() => {
|
|
1611
|
+
let tmpOptions = {
|
|
1908
1612
|
id: layerId.current,
|
|
1909
|
-
layout: {}
|
|
1910
|
-
|
|
1911
|
-
|
|
1613
|
+
layout: {},
|
|
1614
|
+
...props.options
|
|
1615
|
+
};
|
|
1912
1616
|
tmpOptions.layout["icon-image"] = imageIdRef.current;
|
|
1913
1617
|
mapHook.map.addLayer(tmpOptions, props.insertBeforeLayer, mapHook.componentId);
|
|
1914
1618
|
}, [props, mapHook.mapIsReady, mapHook.map]);
|
|
1915
|
-
useEffect(
|
|
1619
|
+
useEffect(() => {
|
|
1916
1620
|
if (!props.options || !mapHook.mapIsReady || layerInitializedRef.current) return;
|
|
1917
1621
|
layerInitializedRef.current = true;
|
|
1918
1622
|
|
|
@@ -1925,7 +1629,7 @@ var MlImageMarkerLayer = function MlImageMarkerLayer(props) {
|
|
|
1925
1629
|
|
|
1926
1630
|
addLayer();
|
|
1927
1631
|
}, [mapHook.mapIsReady, mapHook.map, addLayer, props]);
|
|
1928
|
-
useEffect(
|
|
1632
|
+
useEffect(() => {
|
|
1929
1633
|
if (!mapHook.mapIsReady || mapHook.map && !mapHook.map.getLayer(layerId.current) || !props.options) {
|
|
1930
1634
|
return;
|
|
1931
1635
|
}
|
|
@@ -1935,10 +1639,10 @@ var MlImageMarkerLayer = function MlImageMarkerLayer(props) {
|
|
|
1935
1639
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
|
|
1936
1640
|
};
|
|
1937
1641
|
|
|
1938
|
-
function _extends
|
|
1642
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
1939
1643
|
|
|
1940
1644
|
function SvgRotateRight(props) {
|
|
1941
|
-
return /*#__PURE__*/createElement("svg", _extends
|
|
1645
|
+
return /*#__PURE__*/createElement("svg", _extends({
|
|
1942
1646
|
width: "39.675098mm",
|
|
1943
1647
|
height: "104.27064mm",
|
|
1944
1648
|
viewBox: "0 0 39.675098 104.27064"
|
|
@@ -1955,10 +1659,10 @@ function SvgRotateRight(props) {
|
|
|
1955
1659
|
|
|
1956
1660
|
var _g;
|
|
1957
1661
|
|
|
1958
|
-
function _extends$
|
|
1662
|
+
function _extends$1() { _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
|
|
1959
1663
|
|
|
1960
1664
|
function SvgRotateLeft(props) {
|
|
1961
|
-
return /*#__PURE__*/createElement("svg", _extends$
|
|
1665
|
+
return /*#__PURE__*/createElement("svg", _extends$1({
|
|
1962
1666
|
width: "39.675098mm",
|
|
1963
1667
|
height: "104.27064mm",
|
|
1964
1668
|
viewBox: "0 0 39.675098 104.27064"
|
|
@@ -1971,10 +1675,10 @@ function SvgRotateLeft(props) {
|
|
|
1971
1675
|
|
|
1972
1676
|
var _g$1;
|
|
1973
1677
|
|
|
1974
|
-
function _extends$
|
|
1678
|
+
function _extends$2() { _extends$2 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
|
|
1975
1679
|
|
|
1976
1680
|
function SvgNeedle(props) {
|
|
1977
|
-
return /*#__PURE__*/createElement("svg", _extends$
|
|
1681
|
+
return /*#__PURE__*/createElement("svg", _extends$2({
|
|
1978
1682
|
width: "75.967445mm",
|
|
1979
1683
|
height: "234.71339mm",
|
|
1980
1684
|
viewBox: "0 0 75.967445 234.71339"
|
|
@@ -1989,7 +1693,7 @@ function SvgNeedle(props) {
|
|
|
1989
1693
|
|
|
1990
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)."; }
|
|
1991
1695
|
|
|
1992
|
-
|
|
1696
|
+
const NeedleButton = _styled("div", process.env.NODE_ENV === "production" ? {
|
|
1993
1697
|
target: "e12lzm5x2"
|
|
1994
1698
|
} : {
|
|
1995
1699
|
target: "e12lzm5x2",
|
|
@@ -2004,7 +1708,7 @@ var NeedleButton = _styled("div", process.env.NODE_ENV === "production" ? {
|
|
|
2004
1708
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
2005
1709
|
});
|
|
2006
1710
|
|
|
2007
|
-
|
|
1711
|
+
const NeedleContainer = _styled("div", process.env.NODE_ENV === "production" ? {
|
|
2008
1712
|
target: "e12lzm5x1"
|
|
2009
1713
|
} : {
|
|
2010
1714
|
target: "e12lzm5x1",
|
|
@@ -2019,7 +1723,7 @@ var NeedleContainer = _styled("div", process.env.NODE_ENV === "production" ? {
|
|
|
2019
1723
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
2020
1724
|
});
|
|
2021
1725
|
|
|
2022
|
-
|
|
1726
|
+
const RotateButton = _styled("div", process.env.NODE_ENV === "production" ? {
|
|
2023
1727
|
target: "e12lzm5x0"
|
|
2024
1728
|
} : {
|
|
2025
1729
|
target: "e12lzm5x0",
|
|
@@ -2042,21 +1746,16 @@ var RotateButton = _styled("div", process.env.NODE_ENV === "production" ? {
|
|
|
2042
1746
|
*/
|
|
2043
1747
|
|
|
2044
1748
|
|
|
2045
|
-
|
|
2046
|
-
|
|
1749
|
+
const MlNavigationCompass = props => {
|
|
1750
|
+
const mapHook = useMap({
|
|
2047
1751
|
mapId: props.mapId,
|
|
2048
1752
|
waitForLayer: props.insertBeforeLayer
|
|
2049
1753
|
});
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
2053
|
-
bearing = _useState2[0],
|
|
2054
|
-
setBearing = _useState2[1];
|
|
2055
|
-
|
|
2056
|
-
useEffect(function () {
|
|
1754
|
+
const [bearing, setBearing] = useState(0);
|
|
1755
|
+
useEffect(() => {
|
|
2057
1756
|
if (!mapHook.map) return;
|
|
2058
1757
|
|
|
2059
|
-
|
|
1758
|
+
let _updateBearing = () => {
|
|
2060
1759
|
setBearing(Math.round(mapHook.map.getBearing()));
|
|
2061
1760
|
};
|
|
2062
1761
|
|
|
@@ -2064,18 +1763,19 @@ var MlNavigationCompass = function MlNavigationCompass(props) {
|
|
|
2064
1763
|
|
|
2065
1764
|
_updateBearing();
|
|
2066
1765
|
|
|
2067
|
-
return
|
|
1766
|
+
return () => {
|
|
2068
1767
|
mapHook.map.off("rotate", _updateBearing);
|
|
2069
1768
|
};
|
|
2070
1769
|
}, [mapHook.map, props.mapId]);
|
|
2071
1770
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
|
|
2072
|
-
className: /*#__PURE__*/css(
|
|
1771
|
+
className: /*#__PURE__*/css({
|
|
2073
1772
|
zIndex: 1000,
|
|
2074
1773
|
top: 0,
|
|
2075
|
-
position: "absolute"
|
|
2076
|
-
|
|
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIk1sTmF2aWdhdGlvbkNvbXBhc3MuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBNkdtQiIsImZpbGUiOiJNbE5hdmlnYXRpb25Db21wYXNzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlYWN0LCB7IHVzZVN0YXRlLCB1c2VFZmZlY3QgfSBmcm9tIFwicmVhY3RcIjtcbmltcG9ydCBQcm9wVHlwZXMgZnJvbSBcInByb3AtdHlwZXNcIjtcblxuaW1wb3J0IHsgUmVhY3RDb21wb25lbnQgYXMgUm90YXRlUmlnaHRJY29uIH0gZnJvbSBcIi4vYXNzZXRzL3JvdGF0ZV9yaWdodC5zdmdcIjtcbmltcG9ydCB7IFJlYWN0Q29tcG9uZW50IGFzIFJvdGF0ZUxlZnRJY29uIH0gZnJvbSBcIi4vYXNzZXRzL3JvdGF0ZV9sZWZ0LnN2Z1wiO1xuaW1wb3J0IHsgUmVhY3RDb21wb25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ZVwiLFxuICAgICAgICAgIC4uLnByb3BzLnN0eWxlLFxuICAgICAgICB9KX1cbiAgICAgID5cbiAgICAgICAgPGRpdlxuICAgICAgICAgIGNsYXNzTmFtZT17Y3NzKHtcbiAgICAgICAgICAgIHBvc2l0aW9uOiBcImFic29sdXRlXCIsXG4gICAgICAgICAgICBib3JkZXI6IFwiMTBweCBzb2xpZCAjYmNiY2JjXCIsXG4gICAgICAgICAgICBiYWNrZ3JvdW5kQ29sb3I6IFwiIzcxNzE3MVwiLFxuICAgICAgICAgICAgYmFja2dyb3VuZDogXCJyYWRpYWwtZ3JhZGllbnQoIzcxNzE3MSwgIzQxNDE0MSlcIixcbiAgICAgICAgICAgIGhlaWdodDogXCIyMDBweFwiLFxuICAgICAgICAgICAgd2lkdGg6IFwiMjAwcHhcIixcbiAgICAgICAgICAgIGJvcmRlclJhZGl1czogXCI1MCVcIixcbiAgICAgICAgICAgIGRpc3BsYXk6IFwiZmxleFwiLFxuICAgICAgICAgICAganVzdGlmeUNvbnRlbnQ6IFwiY2VudGVyXCIsXG4gICAgICAgICAgICB0cmFuc2Zvcm06IFwic2NhbGUoMC4yKSB0cmFuc2xhdGVYKC00NDhweCkgdHJhbnNsYXRlWSgtNDQ4cHgpXCIsXG4gICAgICAgICAgICAuLi5wcm9wcy5iYWNrZ3JvdW5kU3R5bGUsXG4gICAgICAgICAgfSl9XG4gICAgICAgID5cbiAgICAgICAgICA8Um90YXRlQnV0dG9uIGNsYXNzTmFtZT17Y3NzKHsgLi4ucHJvcHMucm90YXRlUmlnaHRTdHlsZSB9KX0+XG4gICAgICAgICAgICA8Um90YXRlUmlnaHRJY29uXG4gICAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgICBsZXQgYmVhcmluZyA9IE1hdGgucm91bmQobWFwSG9vay5tYXA/LmdldEJlYXJpbmcoKSk7XG4gICAgICAgICAgICAgICAgbGV0IHJlc3QgPSBNYXRoLnJvdW5kKGJlYXJpbmcgJSA5MCk7XG4gICAgICAgICAgICAgICAgaWYgKGJlYXJpbmcgPiAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTAgLSByZXN0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAocmVzdCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgcmVzdCA9IDkwO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBtYXBIb29rLm1hcD8uc2V0QmVhcmluZyhNYXRoLnJvdW5kKGJlYXJpbmcgKyBNYXRoLmFicyhyZXN0KSkpO1xuICAgICAgICAgICAgICB9fVxuICAgICAgICAgICAgPjwvUm90YXRlUmlnaHRJY29uPlxuICAgICAgICAgIDwvUm90YXRlQnV0dG9uPlxuICAgICAgICAgIDxOZWVkbGVCdXR0b25cbiAgICAgICAgICAgIGNsYXNzTmFtZT17Y3NzKHsgLi4ucHJvcHMubmVlZGxlU3R5bGUgfSl9XG4gICAgICAgICAgICBvbkNsaWNrPXsoKSA9PiB7XG4gICAgICAgICAgICAgIG1hcEhvb2subWFwPy5zZXRCZWFyaW5nKDApO1xuICAgICAgICAgICAgfX1cbiAgICAgICAgICA+XG4gICAgICAgICAgICA8TmVlZGxlQ29udGFpbmVyXG4gICAgICAgICAgICAgIHN0eWxlPXt7XG4gICAgICAgICAgICAgICAgdHJhbnNmb3JtOiBcInJvdGF0ZShcIiArIGJlYXJpbmcgKyBcImRlZylcIixcbiAgICAgICAgICAgICAgfX1cbiAgICAgICAgICAgID5cbiAgICAgICAgICAgICAgPE5lZWRsZUljb24gLz5cbiAgICAgICAgICAgIDwvTmVlZGxlQ29udGFpbmVyPlxuICAgICAgICAgIDwvTmVlZGxlQnV0dG9uPlxuICAgICAgICAgIDxSb3RhdGVCdXR0b24gY2xhc3NOYW1lPXtjc3MoeyAuLi5wcm9wcy5yb3RhdGVMZWZ0U3R5bGUgfSl9PlxuICAgICAgICAgICAgPFJvdGF0ZUxlZnRJY29uXG4gICAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgICBsZXQgYmVhcmluZyA9IE1hdGgucm91bmQobWFwSG9vay5tYXA/LmdldEJlYXJpbmcoKSk7XG4gICAgICAgICAgICAgICAgbGV0IHJlc3QgPSBNYXRoLnJvdW5kKGJlYXJpbmcgJSA5MCk7XG4gICAgICAgICAgICAgICAgaWYgKGJlYXJpbmcgPCAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTAgKyByZXN0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAocmVzdCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgcmVzdCA9IDkwO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBtYXBIb29rLm1hcD8uc2V0QmVhcmluZyhNYXRoLnJvdW5kKGJlYXJpbmcgLSBNYXRoLmFicyhyZXN0KSkpO1xuICAgICAgICAgICAgICB9fVxuICAgICAgICAgICAgPjwvUm90YXRlTGVmdEljb24+XG4gICAgICAgICAgPC9Sb3RhdGVCdXR0b24+XG4gICAgICAgIDwvZGl2PlxuICAgICAgPC9kaXY+XG4gICAgPC8+XG4gICk7XG59O1xuXG5NbE5hdmlnYXRpb25Db21wYXNzLnByb3BUeXBlcyA9IHtcbiAgLyoqXG4gICAqIENvbXBvbmVudCBpZCBwcmVmaXhcbiAgICovXG4gIGlkUHJlZml4OiBQcm9wVHlwZXMuc3RyaW5nLFxuICAvKipcbiAgICogU3R5bGUgb2JqZWN0IHRvIGFkanVzdCBjc3MgZGVmaW5pdGlvbnMgb2YgdGhlIGNvbXBvbmVudC5cbiAgICovXG4gIHN0eWxlOiBQcm9wVHlwZXMub2JqZWN0LFxuICAvKipcbiAgICogU3R5bGUgb2JqZWN0IHRvIGFkanVzdCBjc3MgZGVmaW5pdGlvbnMgb2YgdGhlIGJhY2tncm91bmQuXG4gICAqL1xuICBiYWNrZ3JvdW5kU3R5bGU6IFByb3BUeXBlcy5vYmplY3QsXG4gIC8qKlxuICAgKiBTdHlsZSBvYmplY3QgdG8gYWRqdXN0IGNzcyBkZWZpbml0aW9ucyBvZiB0aGUgY29tcGFzcyBuZWVkbGUuXG4gICAqL1xuICBuZWVkbGVTdHlsZTogUHJvcFR5cGVzLm9iamVjdCxcbiAgLyoqXG4gICAqIFN0eWxlIG9iamVjdCB0byBhZGp1c3QgY3NzIGRlZmluaXRpb25zIG9mIHRoZSByb3RhdGUgcmlnaHQgYnV0dG9uLlxuICAgKi9cbiAgcm90YXRlUmlnaHRTdHlsZTogUHJvcFR5cGVzLm9iamVjdCxcbiAgLyoqXG4gICAqIFN0eWxlIG9iamVjdCB0byBhZGp1c3QgY3NzIGRlZmluaXRpb25zIG9mIHRoZSByb3RhdGUgbGVmdCBidXR0b24uXG4gICAqL1xuICByb3RhdGVMZWZ0U3R5bGU6IFByb3BUeXBlcy5vYmplY3QsXG59O1xuXG5leHBvcnQgZGVmYXVsdCBNbE5hdmlnYXRpb25Db21wYXNzO1xuIl19 */")
|
|
2077
1777
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
2078
|
-
className: /*#__PURE__*/css(
|
|
1778
|
+
className: /*#__PURE__*/css({
|
|
2079
1779
|
position: "absolute",
|
|
2080
1780
|
border: "10px solid #bcbcbc",
|
|
2081
1781
|
backgroundColor: "#717171",
|
|
@@ -2085,16 +1785,18 @@ var MlNavigationCompass = function MlNavigationCompass(props) {
|
|
|
2085
1785
|
borderRadius: "50%",
|
|
2086
1786
|
display: "flex",
|
|
2087
1787
|
justifyContent: "center",
|
|
2088
|
-
transform: "scale(0.2) translateX(-448px) translateY(-448px)"
|
|
2089
|
-
|
|
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,eyJ2Z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VhcmluZyA9ICgpID0+IHtcbiAgICAgIHNldEJlYXJpbmcoTWF0aC5yb3VuZChtYXBIb29rLm1hcC5nZXRCZWFyaW5nKCkpKTtcbiAgICB9O1xuXG4gICAgbWFwSG9vay5tYXAub24oXCJyb3RhdGVcIiwgX3VwZGF0ZUJlYXJpbmcsIG1hcEhvb2suY29tcG9uZW50SWQpO1xuICAgIF91cGRhdGVCZWFyaW5nKCk7XG5cbiAgICByZXR1cm4gKCkgPT4ge1xuICAgICAgbWFwSG9vay5tYXAub2ZmKFwicm90YXRlXCIsIF91cGRhdGVCZWFyaW5nKTtcbiAgICB9O1xuICB9LCBbbWFwSG9vay5tYXAsIHByb3BzLm1hcElkXSk7XG5cbiAgcmV0dXJuIChcbiAgICA8PlxuICAgICAgPGRpdlxuICAgICAgICBjbGFzc05hbWU9e2Nzcyh7XG4gICAgICAgICAgekluZGV4OiAxMDAwLFxuICAgICAgICAgIHRvcDogMCxcbiAgICAgICAgICBwb3NpdGlvbjogXCJhYnNvbHV0ZVwiLFxuICAgICAgICAgIC4uLnByb3BzLnN0eWxlLFxuICAgICAgICB9KX1cbiAgICAgID5cbiAgICAgICAgPGRpdlxuICAgICAgICAgIGNsYXNzTmFtZT17Y3NzKHtcbiAgICAgICAgICAgIHBvc2l0aW9uOiBcImFic29sdXRlXCIsXG4gICAgICAgICAgICBib3JkZXI6IFwiMTBweCBzb2xpZCAjYmNiY2JjXCIsXG4gICAgICAgICAgICBiYWNrZ3JvdW5kQ29sb3I6IFwiIzcxNzE3MVwiLFxuICAgICAgICAgICAgYmFja2dyb3VuZDogXCJyYWRpYWwtZ3JhZGllbnQoIzcxNzE3MSwgIzQxNDE0MSlcIixcbiAgICAgICAgICAgIGhlaWdodDogXCIyMDBweFwiLFxuICAgICAgICAgICAgd2lkdGg6IFwiMjAwcHhcIixcbiAgICAgICAgICAgIGJvcmRlclJhZGl1czogXCI1MCVcIixcbiAgICAgICAgICAgIGRpc3BsYXk6IFwiZmxleFwiLFxuICAgICAgICAgICAganVzdGlmeUNvbnRlbnQ6IFwiY2VudGVyXCIsXG4gICAgICAgICAgICB0cmFuc2Zvcm06IFwic2NhbGUoMC4yKSB0cmFuc2xhdGVYKC00NDhweCkgdHJhbnNsYXRlWSgtNDQ4cHgpXCIsXG4gICAgICAgICAgICAuLi5wcm9wcy5iYWNrZ3JvdW5kU3R5bGUsXG4gICAgICAgICAgfSl9XG4gICAgICAgID5cbiAgICAgICAgICA8Um90YXRlQnV0dG9uIGNsYXNzTmFtZT17Y3NzKHsgLi4ucHJvcHMucm90YXRlUmlnaHRTdHlsZSB9KX0+XG4gICAgICAgICAgICA8Um90YXRlUmlnaHRJY29uXG4gICAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgICBsZXQgYmVhcmluZyA9IE1hdGgucm91bmQobWFwSG9vay5tYXA/LmdldEJlYXJpbmcoKSk7XG4gICAgICAgICAgICAgICAgbGV0IHJlc3QgPSBNYXRoLnJvdW5kKGJlYXJpbmcgJSA5MCk7XG4gICAgICAgICAgICAgICAgaWYgKGJlYXJpbmcgPiAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTAgLSByZXN0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAocmVzdCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgcmVzdCA9IDkwO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBtYXBIb29rLm1hcD8uc2V0QmVhcmluZyhNYXRoLnJvdW5kKGJlYXJpbmcgKyBNYXRoLmFicyhyZXN0KSkpO1xuICAgICAgICAgICAgICB9fVxuICAgICAgICAgICAgPjwvUm90YXRlUmlnaHRJY29uPlxuICAgICAgICAgIDwvUm90YXRlQnV0dG9uPlxuICAgICAgICAgIDxOZWVkbGVCdXR0b25cbiAgICAgICAgICAgIGNsYXNzTmFtZT17Y3NzKHsgLi4ucHJvcHMubmVlZGxlU3R5bGUgfSl9XG4gICAgICAgICAgICBvbkNsaWNrPXsoKSA9PiB7XG4gICAgICAgICAgICAgIG1hcEhvb2subWFwPy5zZXRCZWFyaW5nKDApO1xuICAgICAgICAgICAgfX1cbiAgICAgICAgICA+XG4gICAgICAgICAgICA8TmVlZGxlQ29udGFpbmVyXG4gICAgICAgICAgICAgIHN0eWxlPXt7XG4gICAgICAgICAgICAgICAgdHJhbnNmb3JtOiBcInJvdGF0ZShcIiArIGJlYXJpbmcgKyBcImRlZylcIixcbiAgICAgICAgICAgICAgfX1cbiAgICAgICAgICAgID5cbiAgICAgICAgICAgICAgPE5lZWRsZUljb24gLz5cbiAgICAgICAgICAgIDwvTmVlZGxlQ29udGFpbmVyPlxuICAgICAgICAgIDwvTmVlZGxlQnV0dG9uPlxuICAgICAgICAgIDxSb3RhdGVCdXR0b24gY2xhc3NOYW1lPXtjc3MoeyAuLi5wcm9wcy5yb3RhdGVMZWZ0U3R5bGUgfSl9PlxuICAgICAgICAgICAgPFJvdGF0ZUxlZnRJY29uXG4gICAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgICBsZXQgYmVhcmluZyA9IE1hdGgucm91bmQobWFwSG9vay5tYXA/LmdldEJlYXJpbmcoKSk7XG4gICAgICAgICAgICAgICAgbGV0IHJlc3QgPSBNYXRoLnJvdW5kKGJlYXJpbmcgJSA5MCk7XG4gICAgICAgICAgICAgICAgaWYgKGJlYXJpbmcgPCAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTAgKyByZXN0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAocmVzdCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgcmVzdCA9IDkwO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBtYXBIb29rLm1hcD8uc2V0QmVhcmluZyhNYXRoLnJvdW5kKGJlYXJpbmcgLSBNYXRoLmFicyhyZXN0KSkpO1xuICAgICAgICAgICAgICB9fVxuICAg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dmlnYXRpb25Db21wYXNzO1xuIl19 */")
|
|
2090
1791
|
}, /*#__PURE__*/React__default.createElement(RotateButton, {
|
|
2091
|
-
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIk1sTmF2aWdhdGlvbkNvbXBhc3MuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBbUltQyIsImZpbGUiOiJNbE5hdmlnYXRpb25Db21wYXNzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlYWN0LCB7IHVzZVN0YXRlLCB1c2VFZmZlY3QgfSBmcm9tIFwicmVhY3RcIjtcbmltcG9ydCBQcm9wVHlwZXMgZnJvbSBcInByb3AtdHlwZXNcIjtcblxuaW1wb3J0IHsgUmVhY3RDb21wb25lbnQgYXMgUm90YXRlUmlnaHRJY29uIH0gZnJvbSBcIi4vYXNzZXRzL3JvdGF0ZV9yaWdodC5zdmdcIjtcbmltcG9ydCB7IFJlYWN0Q29tcG9uZW50IGFzIFJvdGF0ZUxlZnRJY29uIH0gZnJvbSBcIi4vYXNzZXRzL3JvdGF0ZV9sZWZ0LnN2Z1wiO1xuaW1wb3J0IHsgUmVhY3RDb21wb25lbnQgYXMgTmVlZGxlSWNvbiB9IGZyb20gXCIuL2Fzc2V0cy9uZWVkbGUuc3ZnXCI7XG5cbmltcG9ydCBzdHlsZWQgZnJvbSBcIkBlbW90aW9uL3N0eWxlZFwiO1xuaW1wb3J0IHsgY3NzIH0gZnJvbSBcIkBlbW90aW9uL2Nzc1wiO1xuaW1wb3J0IHVzZU1hcCBmcm9tIFwiLi4vLi4vaG9va3MvdXNlTWFwXCI7XG5cbmNvbnN0IE5lZWRsZUJ1dHRvbiA9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LFxuICAgICAgICAgICAgYmFja2dyb3VuZDogXCJyYWRpYWwtZ3JhZGllbnQoIzcxNzE3MSwgIzQxNDE0MSlcIixcbiAgICAgICAgICAgIGhlaWdodDogXCIyMDBweFwiLFxuICAgICAgICAgICAgd2lkdGg6IFwiMjAwcHhcIixcbiAgICAgICAgICAgIGJvcmRlclJhZGl1czogXCI1MCVcIixcbiAgICAgICAgICAgIGRpc3BsYXk6IFwiZmxleFwiLFxuICAgICAgICAgICAganVzdGlmeUNvbnRlbnQ6IFwiY2VudGVyXCIsXG4gICAgICAgICAgICB0cmFuc2Zvcm06IFwic2NhbGUoMC4yKSB0cmFuc2xhdGVYKC00NDhweCkgdHJhbnNsYXRlWSgtNDQ4cHgpXCIsXG4gICAgICAgICAgICAuLi5wcm9wcy5iYWNrZ3JvdW5kU3R5bGUsXG4gICAgICAgICAgfSl9XG4gICAgICAgID5cbiAgICAgICAgICA8Um90YXRlQnV0dG9uIGNsYXNzTmFtZT17Y3NzKHsgLi4ucHJvcHMucm90YXRlUmlnaHRTdHlsZSB9KX0+XG4gICAgICAgICAgICA8Um90YXRlUmlnaHRJY29uXG4gICAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgICBsZXQgYmVhcmluZyA9IE1hdGgucm91bmQobWFwSG9vay5tYXA/LmdldEJlYXJpbmcoKSk7XG4gICAgICAgICAgICAgICAgbGV0IHJlc3QgPSBNYXRoLnJvdW5kKGJlYXJpbmcgJSA5MCk7XG4gICAgICAgICAgICAgICAgaWYgKGJlYXJpbmcgPiAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTAgLSByZXN0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAocmVzdCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgcmVzdCA9IDkwO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBtYXBIb29rLm1hcD8uc2V0QmVhcmluZyhNYXRoLnJvdW5kKGJlYXJpbmcgKyBNYXRoLmFicyhyZXN0KSkpO1xuICAgICAgICAgICAgICB9fVxuICAgICAgICAgICAgPjwvUm90YXRlUmlnaHRJY29uPlxuICAgICAgICAgIDwvUm90YXRlQnV0dG9uPlxuICAgICAgICAgIDxOZWVkbGVCdXR0b25cbiAgICAgICAgICAgIGNsYXNzTmFtZT17Y3NzKHsgLi4ucHJvcHMubmVlZGxlU3R5bGUgfSl9XG4gICAgICAgICAgICBvbkNsaWNrPXsoKSA9PiB7XG4gICAgICAgICAgICAgIG1hcEhvb2subWFwPy5zZXRCZWFyaW5nKDApO1xuICAgICAgICAgICAgfX1cbiAgICAgICAgICA+XG4gICAgICAgICAgICA8TmVlZGxlQ29udGFpbmVyXG4gICAgICAgICAgICAgIHN0eWxlPXt7XG4gICAgICAgICAgICAgICAgdHJhbnNmb3JtOiBcInJvdGF0ZShcIiArIGJlYXJpbmcgKyBcImRlZylcIixcbiAgICAgICAgICAgICAgfX1cbiAgICAgICAgICAgID5cbiAgICAgICAgICAgICAgPE5lZWRsZUljb24gLz5cbiAgICAgICAgICAgIDwvTmVlZGxlQ29udGFpbmVyPlxuICAgICAgICAgIDwvTmVlZGxlQnV0dG9uPlxuICAgICAgICAgIDxSb3RhdGVCdXR0b24gY2xhc3NOYW1lPXtjc3MoeyAuLi5wcm9wcy5yb3RhdGVMZWZ0U3R5bGUgfSl9PlxuICAgICAgICAgICAgPFJvdGF0ZUxlZnRJY29uXG4gICAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgICBsZXQgYmVhcmluZyA9IE1hdGgucm91bmQobWFwSG9vay5tYXA/LmdldEJlYXJpbmcoKSk7XG4gICAgICAgICAgICAgICAgbGV0IHJlc3QgPSBNYXRoLnJvdW5kKGJlYXJpbmcgJSA5MCk7XG4gICAgICAgICAgICAgICAgaWYgKGJlYXJpbmcgPCAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTAgKyByZXN0O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i9cbiAgcm90YXRlUmlnaHRTdHlsZTogUHJvcFR5cGVzLm9iamVjdCxcbiAgLyoqXG4gICAqIFN0eWxlIG9iamVjdCB0byBhZGp1c3QgY3NzIGRlZmluaXRpb25zIG9mIHRoZSByb3RhdGUgbGVmdCBidXR0b24uXG4gICAqL1xuICByb3RhdGVMZWZ0U3R5bGU6IFByb3BUeXBlcy5vYmplY3QsXG59O1xuXG5leHBvcnQgZGVmYXVsdCBNbE5hdmlnYXRpb25Db21wYXNzO1xuIl19 */")
|
|
2092
1794
|
}, /*#__PURE__*/React__default.createElement(SvgRotateRight, {
|
|
2093
|
-
onClick:
|
|
1795
|
+
onClick: () => {
|
|
2094
1796
|
var _mapHook$map, _mapHook$map2;
|
|
2095
1797
|
|
|
2096
|
-
|
|
2097
|
-
|
|
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);
|
|
2098
1800
|
|
|
2099
1801
|
if (bearing > 0) {
|
|
2100
1802
|
rest = 90 - rest;
|
|
@@ -2107,8 +1809,9 @@ var MlNavigationCompass = function MlNavigationCompass(props) {
|
|
|
2107
1809
|
(_mapHook$map2 = mapHook.map) === null || _mapHook$map2 === void 0 ? void 0 : _mapHook$map2.setBearing(Math.round(bearing + Math.abs(rest)));
|
|
2108
1810
|
}
|
|
2109
1811
|
})), /*#__PURE__*/React__default.createElement(NeedleButton, {
|
|
2110
|
-
className: /*#__PURE__*/css(
|
|
2111
|
-
|
|
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIk1sTmF2aWdhdGlvbkNvbXBhc3MuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncy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CkpKTtcbiAgICB9O1xuXG4gICAgbWFwSG9vay5tYXAub24oXCJyb3RhdGVcIiwgX3VwZGF0ZUJlYXJpbmcsIG1hcEhvb2suY29tcG9uZW50SWQpO1xuICAgIF91cGRhdGVCZWFyaW5nKCk7XG5cbiAgICByZXR1cm4gKCkgPT4ge1xuICAgICAgbWFwSG9vay5tYXAub2ZmKFwicm90YXRlXCIsIF91cGRhdGVCZWFyaW5nKTtcbiAgICB9O1xuICB9LCBbbWFwSG9vay5tYXAsIHByb3BzLm1hcElkXSk7XG5cbiAgcmV0dXJuIChcbiAgICA8PlxuICAgICAgPGRpdlxuICAgICAgICBjbGFzc05hbWU9e2Nzcyh7XG4gICAgICAgICAgekluZGV4OiAxMDAwLFxuICAgICAgICAgIHRvcDogMCxcbiAgICAgICAgICBwb3NpdGlvbjogXCJhYnNvbHV0ZVwiLFxuICAgICAgICAgIC4uLnByb3BzLnN0eWxlLFxuICAgICAgICB9KX1cbiAgICAgID5cbiAgICAgICAgPGRpdlxuICAgICAgICAgIGNsYXNzTmFtZT17Y3NzKHtcbiAgICAgICAgICAgIHBvc2l0aW9uOiBcImFic29sdXRlXCIsXG4gICAgICAgICAgICBib3JkZXI6IFwiMTBweCBzb2xpZCAjYmNiY2JjXCIsXG4gICAgICAgICAgICBiYWNrZ3JvdW5kQ29sb3I6IFwiIzcxNzE3MVwiLFxuICAgICAgICAgICAgYmFja2dyb3VuZDogXCJyYWRpYWwtZ3JhZGllbnQoIzcxNzE3MSwgIzQxNDE0MSlcIixcbiAgICAgICAgICAgIGhlaWdodDogXCIyMDBweFwiLFxuICAgICAgICAgICAgd2lkdGg6IFwiMjAwcHhcIixcbiAgICAgICAgICAgIGJvcmRlclJhZGl1czogXCI1MCVcIixcbiAgICAgICAgICAgIGRpc3BsYXk6IFwiZmxleFwiLFxuICAgICAgICAgICAganVzdGlmeUNvbnRlbnQ6IFwiY2VudGVyXCIsXG4gICAgICAgICAgICB0cmFuc2Zvcm06IFwic2NhbGUoMC4yKSB0cmFuc2xhdGVYKC00NDhweCkgdHJhbnNsYXRlWSgtNDQ4cHgpXCIsXG4gICAgICAgICAgICAuLi5wcm9wcy5iYWNrZ3JvdW5kU3R5bGUsXG4gICAgICAgICAgfSl9XG4gICAgICAgID5cbiAgICAgICAgICA8Um90YXRlQnV0dG9uIGNsYXNzTmFtZT17Y3NzKHsgLi4ucHJvcHMucm90YXRlUmlnaHRTdHlsZSB9KX0+XG4gICAgICAgICAgICA8Um90YXRlUmlnaHRJY29uXG4gICAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgICBsZXQgYmVhcmluZyA9IE1hdGgucm91bmQobWFwSG9vay5tYXA/LmdldEJlYXJpbmcoKSk7XG4gICAgICAgICAgICAgICAgbGV0IHJlc3QgPSBNYXRoLnJvdW5kKGJlYXJpbmcgJSA5MCk7XG4gICAgICAgICAgICAgICAgaWYgKGJlYXJpbmcgPiAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTAgLSByZXN0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAocmVzdCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgcmVzdCA9IDkwO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBtYXBIb29rLm1hcD8uc2V0QmVhcmluZyhNYXRoLnJvdW5kKGJlYXJpbmcgKyBNYXRoLmFicyhyZXN0KSkpO1xuICAgICAgICAgICAgICB9fVxuICAgICAgICAgICAgPjwvUm90YXRlUmlnaHRJY29uPlxuICAgICAgICAgIDwvUm90YXRlQnV0dG9uPlxuICAgICAgICAgIDxOZWVkbGVCdXR0b25cbiAgICAgICAgICAgIGNsYXNzTmFtZT17Y3NzKHsgLi4ucHJvcHMubmVlZGxlU3R5bGUgfSl9XG4gICAgICAgICAgICBvbkNsaWNrPXsoKSA9PiB7XG4gICAgICAgICAgICAgIG1hcEhvb2subWFwPy5zZXRCZWFyaW5nKDApO1xuICAgICAgICAgICAgfX1cbiAgICAgICAgICA+XG4gICAgICAgICAgICA8TmVlZGxlQ29udGFpbmVyXG4gICAgICAgICAgICAgIHN0eWxlPXt7XG4gICAgICAgICAgICAgICAgdHJhbnNmb3JtOiBcInJvdGF0ZShcIiArIGJlYXJpbmcgKyBcImRlZylcIixcbiAgICAgICAgICAgICAgfX1cbiAgICAgICAgICAgID5cbiAgICAgICAgICAgICAgPE5lZWRsZUljb24gLz5cbiAgICAgICAgICAgIDwvTmVlZGxlQ29udGFpbmVyPlxuICAgICAgICAgIDwvTmVlZGxlQnV0dG9uPlxuICAgICAgICAgIDxSb3RhdGVCdXR0b24gY2xhc3NOYW1lPXtjc3MoeyAuLi5wcm9wcy5yb3RhdGVMZWZ0U3R5bGUgfSl9PlxuICAgICAgICAgICAgPFJvdGF0ZUxlZnRJY29uXG4gICAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgICBsZXQgYmVhcmluZyA9IE1hdGgucm91bmQobWFwSG9vay5tYXA/LmdldEJlYXJpbmcoKSk7XG4gICAgICAgICAgICAgICAgbGV0IHJlc3QgPSBNYXRoLnJvdW5kKGJlYXJpbmcgJSA5MCk7XG4gICAgICAgICAgICAgICAgaWYgKGJlYXJpbmcgPCAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTAgKyByZXN0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAocmVzdCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgcmVzdCA9IDkwO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBtYXBIb29rLm1hcD8uc2V0QmVhcmluZyhNYXRoLnJvdW5kKGJlYXJpbmcgLSBNYXRoLmFicyhyZXN0KSkpO1xuICAgICAgICAgICAgICB9fVxuICAgICAgICAgICAgPjwvUm90YXRlTGVmdEljb24+XG4gICAgICAgICAgPC9Sb3RhdGVCdXR0b24+XG4gICAgICAgIDwvZGl2Plxu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
|
2114
1817
|
(_mapHook$map3 = mapHook.map) === null || _mapHook$map3 === void 0 ? void 0 : _mapHook$map3.setBearing(0);
|
|
@@ -2118,13 +1821,14 @@ var MlNavigationCompass = function MlNavigationCompass(props) {
|
|
|
2118
1821
|
transform: "rotate(" + bearing + "deg)"
|
|
2119
1822
|
}
|
|
2120
1823
|
}, /*#__PURE__*/React__default.createElement(SvgNeedle, null))), /*#__PURE__*/React__default.createElement(RotateButton, {
|
|
2121
|
-
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIk1sTmF2aWdhdGlvbkNvbXBhc3MuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBZ0ttQyIsImZpbGUiOiJNbE5hdmlnYXRpb25Db21wYXNzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlYWN0LCB7IHVzZVN0YXRlLCB1c2VFZmZlY3QgfSBmcm9tIFwicmVhY3RcIjtcbmltcG9ydCBQcm9wVHlwZXMgZnJvbSBcInByb3AtdHlwZXNcIjtcblxuaW1wb3J0IHsgUmVhY3RDb21wb25lbnQgYXMgUm90YXRlUmlnaHRJY29uIH0gZnJvbSBcIi4vYXNzZXRzL3JvdGF0ZV9yaWdodC5zdmdcIjtcbmltcG9ydCB7IFJlYWN0Q29tcG9uZW50IGFzIFJvdGF0ZUxlZnRJY29uIH0gZnJvbSBcIi4vYXNzZXRzL3JvdGF0ZV9sZWZ0LnN2Z1wiO1xuaW1wb3J0IHsgUmVhY3RDb21wb25lbnQgYXMgTmVlZGxlSWNvbiB9IGZyb20gXCIuL2Fzc2V0cy9uZWVkbGUuc3ZnXCI7XG5cbmltcG9ydCBzdHlsZWQgZnJvbS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YXNzTmFtZT17Y3NzKHtcbiAgICAgICAgICAgIHBvc2l0aW9uOiBcImFic29sdXRlXCIsXG4gICAgICAgICAgICBib3JkZXI6IFwiMTBweCBzb2xpZCAjYmNiY2JjXCIsXG4gICAgICAgICAgICBiYWNrZ3JvdW5kQ29sb3I6IFwiIzcxNzE3MVwiLFxuICAgICAgICAgICAgYmFja2dyb3VuZDogXCJyYWRpYWwtZ3JhZGllbnQoIzcxNzE3MSwgIzQxNDE0MSlcIixcbiAgICAgICAgICAgIGhlaWdodDogXCIyMDBweFwiLFxuICAgICAgICAgICAgd2lkdGg6IFwiMjAwcHhcIixcbiAgICAgICAgICAgIGJvcmRlclJhZGl1czogXCI1MCVcIixcbiAgICAgICAgICAgIGRpc3BsYXk6IFwiZmxleFwiLFxuICAgICAgICAgICAganVzdGlmeUNvbnRlbnQ6IFwiY2VudGVyXCIsXG4gICAgICAgICAgICB0cmFuc2Zvcm06IFwic2NhbGUoMC4yKSB0cmFuc2xhdGVYKC00NDhweCkgdHJhbnNsYXRlWSgtNDQ4cHgpXCIsXG4gICAgICAgICAgICAuLi5wcm9wcy5iYWNrZ3JvdW5kU3R5bGUsXG4gICAgICAgICAgfSl9XG4gICAgICAgID5cbiAgICAgICAgICA8Um90YXRlQnV0dG9uIGNsYXNzTmFtZT17Y3NzKHsgLi4ucHJvcHMucm90YXRlUmlnaHRTdHlsZSB9KX0+XG4gICAgICAgICAgICA8Um90YXRlUmlnaHRJY29uXG4gICAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgICBsZXQgYmVhcmluZyA9IE1hdGgucm91bmQobWFwSG9vay5tYXA/LmdldEJlYXJpbmcoKSk7XG4gICAgICAgICAgICAgICAgbGV0IHJlc3QgPSBNYXRoLnJvdW5kKGJlYXJpbmcgJSA5MCk7XG4gICAgICAgICAgICAgICAgaWYgKGJlYXJpbmcgPiAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTAgLSByZXN0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAocmVzdCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgcmVzdCA9IDkwO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBtYXBIb29rLm1hcD8uc2V0QmVhcmluZyhNYXRoLnJvdW5kKGJlYXJpbmcgKyBNYXRoLmFicyhyZXN0KSkpO1xuICAgICAgICAgICAgICB9fVxuICAgICAgICAgICAgPjwvUm90YXRlUmlnaHRJY29uPlxuICAgICAgICAgIDwvUm90YXRlQnV0dG9uPlxuICAgICAgICAgIDxOZWVkbGVCdXR0b25cbiAgICAgICAgICAgIGNsYXNzTmFtZT17Y3NzKHsgLi4ucHJvcHMubmVlZGxlU3R5bGUgfSl9XG4gICAgICAgICAgICBvbkNsaWNrPXsoKSA9PiB7XG4gICAgICAgICAgICAgIG1hcEhvb2subWFwPy5zZXRCZWFyaW5nKDApO1xuICAgICAgICAgICAgfX1cbiAgICAgICAgICA+XG4gICAgICAgICAgICA8TmVlZGxlQ29udGFpbmVyXG4gICAgICAgICAgICAgIHN0eWxlPXt7XG4gICAgICAgICAgICAgICAgdHJhbnNmb3JtOiBcInJvdGF0ZShcIiArIGJlYXJpbmcgKyBcImRlZylcIixcbiAgICAgICAgICAgICAgfX1cbiAgICAgICAgICAgID5cbiAgICAgICAgICAgICAgPE5lZWRsZUljb24gLz5cbiAgICAgICAgICAgIDwvTmVlZGxlQ29udGFpbmVyPlxuICAgICAgICAgIDwvTmVlZGxlQnV0dG9uPlxuICAgICAgICAgIDxSb3RhdGVCdXR0b24gY2xhc3NOYW1lPXtjc3MoeyAuLi5wcm9wcy5yb3RhdGVMZWZ0U3R5bGUgfSl9PlxuICAgICAgICAgICAgPFJvdGF0ZUxlZnRJY29uXG4gICAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgICBsZXQgYmVhcmluZyA9IE1hdGgucm91bmQobWFwSG9vay5tYXA/LmdldEJlYXJpbmcoKSk7XG4gICAgICAgICAgICAgICAgbGV0IHJlc3QgPSBNYXRoLnJvdW5kKGJlYXJpbmcgJSA5MCk7XG4gICAgICAgICAgICAgICAgaWYgKGJlYXJpbmcgPCAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTAgKyByZXN0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAocmVzdCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgcmVzdCA9IDkwO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBtYXBIb29rLm1hcD8uc2V0QmVhcmluZyhNYXRoLnJvdW5kKGJlYXJpbmcgLSBNYXRoLmFicyhyZXN0KSkpO1xuICAgICAgICAgICAgICB9fVxuICAgICAgICAgICAgPjwvUm90YXRlTGVmdEljb24+XG4gICAgICAgICAgPC9Sb3RhdGVCdXR0b24+XG4gICAgICAgIDwvZGl2PlxuICAgICAgPC9kaXY+XG4gICAgPC8+XG4gICk7XG59O1xuXG5NbE5hdmlnYXRpb25Db21wYXNzLnByb3BUeXBlcyA9IHtcbiAgLyoqXG4gICAqIENvbXBvbmVudCBpZCBwcmVmaXhcbiAgICovXG4gIGlkUHJlZml4OiBQcm9wVHlwZXMuc3RyaW5nLFxuICAvKipcbiAgICogU3R5bGUgb2JqZWN0IHRvIGFkanVzdCBjc3MgZGVmaW5pdGlvbnMgb2YgdGhlIGNvbXBvbmVudC5cbiAgICovXG4gIHN0eWxlOiBQcm9wVHlwZXMub2JqZWN0LFxuICAvKipcbiAgICogU3R5bGUgb2JqZWN0IHRvIGFkanVzdCBjc3MgZGVmaW5pdGlvbnMgb2YgdGhlIGJhY2tncm91bmQuXG4gICAqL1xuICBiYWNrZ3JvdW5kU3R5bGU6IFByb3BUeXBlcy5vYmplY3QsXG4gIC8qKlxuICAgKiBTdHlsZSBvYmplY3QgdG8gYWRqdXN0IGNzcyBkZWZpbml0aW9ucyBvZiB0aGUgY29tcGFzcyBuZWVkbGUuXG4gICAqL1xuICBuZWVkbGVTdHlsZTogUHJvcFR5cGVzLm9iamVjdCxcbiAgLyoqXG4gICAqIFN0eWxlIG9iamVjdCB0byBhZGp1c3QgY3NzIGRlZmluaXRpb25zIG9mIHRoZSByb3RhdGUgcmlnaHQgYnV0dG9uLlxuICAgKi9cbiAgcm90YXRlUmlnaHRTdHlsZTogUHJvcFR5cGVzLm9iamVjdCxcbiAgLyoqXG4gICAqIFN0eWxlIG9iamVjdCB0byBhZGp1c3QgY3NzIGRlZmluaXRpb25zIG9mIHRoZSByb3RhdGUgbGVmdCBidXR0b24uXG4gICAqL1xuICByb3RhdGVMZWZ0U3R5bGU6IFByb3BUeXBlcy5vYmplY3QsXG59O1xuXG5leHBvcnQgZGVmYXVsdCBNbE5hdmlnYXRpb25Db21wYXNzO1xuIl19 */")
|
|
2122
1826
|
}, /*#__PURE__*/React__default.createElement(SvgRotateLeft, {
|
|
2123
|
-
onClick:
|
|
1827
|
+
onClick: () => {
|
|
2124
1828
|
var _mapHook$map4, _mapHook$map5;
|
|
2125
1829
|
|
|
2126
|
-
|
|
2127
|
-
|
|
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);
|
|
2128
1832
|
|
|
2129
1833
|
if (bearing < 0) {
|
|
2130
1834
|
rest = 90 + rest;
|
|
@@ -2171,26 +1875,15 @@ MlNavigationCompass.propTypes = {
|
|
|
2171
1875
|
rotateLeftStyle: PropTypes.object
|
|
2172
1876
|
};
|
|
2173
1877
|
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
var MlNavigationTools = function MlNavigationTools(props) {
|
|
2177
|
-
var mapHook = useMap({
|
|
1878
|
+
const MlNavigationTools = props => {
|
|
1879
|
+
const mapHook = useMap({
|
|
2178
1880
|
mapId: props.mapId,
|
|
2179
1881
|
waitForLayer: props.insertBeforeLayer
|
|
2180
1882
|
});
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
setPitch = _useState2[1];
|
|
2186
|
-
|
|
2187
|
-
var _useState3 = useState(false),
|
|
2188
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
2189
|
-
locationAccessDenied = _useState4[0],
|
|
2190
|
-
setLocationAccessDenied = _useState4[1];
|
|
2191
|
-
|
|
2192
|
-
var mediaIsMobile = useMediaQuery("(max-width:900px)");
|
|
2193
|
-
var buttonStyle = {
|
|
1883
|
+
const [pitch, setPitch] = useState(0);
|
|
1884
|
+
const [locationAccessDenied, setLocationAccessDenied] = useState(false);
|
|
1885
|
+
const mediaIsMobile = useMediaQuery("(max-width:900px)");
|
|
1886
|
+
const buttonStyle = {
|
|
2194
1887
|
minWidth: "20px",
|
|
2195
1888
|
minHeight: "20px",
|
|
2196
1889
|
width: mediaIsMobile ? "50px" : "30px",
|
|
@@ -2206,15 +1899,15 @@ var MlNavigationTools = function MlNavigationTools(props) {
|
|
|
2206
1899
|
},
|
|
2207
1900
|
color: "#ececec"
|
|
2208
1901
|
};
|
|
2209
|
-
useEffect(
|
|
1902
|
+
useEffect(() => {
|
|
2210
1903
|
if (!mapHook.map) return;
|
|
2211
|
-
mapHook.map.on("pitchend",
|
|
1904
|
+
mapHook.map.on("pitchend", () => {
|
|
2212
1905
|
setPitch(mapHook.map.getPitch());
|
|
2213
1906
|
});
|
|
2214
1907
|
setPitch(mapHook.map.getPitch());
|
|
2215
1908
|
}, [mapHook.map, props.mapId]);
|
|
2216
1909
|
|
|
2217
|
-
|
|
1910
|
+
const zoomIn = () => {
|
|
2218
1911
|
if (!mapHook.map) return;
|
|
2219
1912
|
|
|
2220
1913
|
if (mapHook.map.transform._zoom + 0.5 <= mapHook.map.transform._maxZoom) {
|
|
@@ -2224,7 +1917,7 @@ var MlNavigationTools = function MlNavigationTools(props) {
|
|
|
2224
1917
|
}
|
|
2225
1918
|
};
|
|
2226
1919
|
|
|
2227
|
-
|
|
1920
|
+
const zoomOut = () => {
|
|
2228
1921
|
if (!mapHook.map) return;
|
|
2229
1922
|
|
|
2230
1923
|
if (mapHook.map.transform._zoom - 0.5 >= mapHook.map.transform._minZoom) {
|
|
@@ -2234,9 +1927,9 @@ var MlNavigationTools = function MlNavigationTools(props) {
|
|
|
2234
1927
|
}
|
|
2235
1928
|
};
|
|
2236
1929
|
|
|
2237
|
-
|
|
1930
|
+
const adjustPitch = () => {
|
|
2238
1931
|
if (!mapHook.map) return;
|
|
2239
|
-
|
|
1932
|
+
let targetPitch = 60;
|
|
2240
1933
|
|
|
2241
1934
|
if (mapHook.map.getPitch() !== 0) {
|
|
2242
1935
|
targetPitch = 0;
|
|
@@ -2247,15 +1940,15 @@ var MlNavigationTools = function MlNavigationTools(props) {
|
|
|
2247
1940
|
});
|
|
2248
1941
|
};
|
|
2249
1942
|
|
|
2250
|
-
|
|
1943
|
+
const moveToCurrentLocation = () => {
|
|
2251
1944
|
navigator.geolocation.getCurrentPosition(getLocationSuccess, getLocationError);
|
|
2252
1945
|
};
|
|
2253
1946
|
|
|
2254
|
-
|
|
1947
|
+
const getLocationSuccess = location => {
|
|
2255
1948
|
mapHook.map.setCenter([location.coords.longitude, location.coords.latitude]);
|
|
2256
1949
|
};
|
|
2257
1950
|
|
|
2258
|
-
|
|
1951
|
+
const getLocationError = () => {
|
|
2259
1952
|
console.log("Access of user location denied");
|
|
2260
1953
|
setLocationAccessDenied(true);
|
|
2261
1954
|
};
|
|
@@ -2281,9 +1974,9 @@ var MlNavigationTools = function MlNavigationTools(props) {
|
|
|
2281
1974
|
boxShadow: "0px 0px 18px rgba(0,0,0,.5)"
|
|
2282
1975
|
}
|
|
2283
1976
|
}), /*#__PURE__*/React__default.createElement(Button, {
|
|
2284
|
-
sx:
|
|
1977
|
+
sx: { ...buttonStyle,
|
|
2285
1978
|
fontWeight: 600
|
|
2286
|
-
}
|
|
1979
|
+
},
|
|
2287
1980
|
onClick: adjustPitch
|
|
2288
1981
|
}, pitch ? "2D" : "3D"), /*#__PURE__*/React__default.createElement(Button, {
|
|
2289
1982
|
sx: buttonStyle,
|
|
@@ -2294,12 +1987,14 @@ var MlNavigationTools = function MlNavigationTools(props) {
|
|
|
2294
1987
|
fontSize: mediaIsMobile ? "1.5em" : "1.2em"
|
|
2295
1988
|
}
|
|
2296
1989
|
})), /*#__PURE__*/React__default.createElement(MlFollowGps, {
|
|
2297
|
-
style:
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
1990
|
+
style: { ...(_ref => {
|
|
1991
|
+
let {
|
|
1992
|
+
color,
|
|
1993
|
+
...rest
|
|
1994
|
+
} = _ref;
|
|
1995
|
+
return rest;
|
|
1996
|
+
})(buttonStyle)
|
|
1997
|
+
}
|
|
2303
1998
|
}), /*#__PURE__*/React__default.createElement(ButtonGroup, {
|
|
2304
1999
|
orientation: "vertical",
|
|
2305
2000
|
sx: {
|
|
@@ -2315,18 +2010,18 @@ var MlNavigationTools = function MlNavigationTools(props) {
|
|
|
2315
2010
|
}
|
|
2316
2011
|
}
|
|
2317
2012
|
}, /*#__PURE__*/React__default.createElement(Button, {
|
|
2318
|
-
sx:
|
|
2013
|
+
sx: { ...buttonStyle,
|
|
2319
2014
|
color: "#ececec"
|
|
2320
|
-
}
|
|
2015
|
+
},
|
|
2321
2016
|
onClick: zoomIn
|
|
2322
2017
|
}, /*#__PURE__*/React__default.createElement(ControlPointIcon, {
|
|
2323
2018
|
sx: {
|
|
2324
2019
|
fontSize: mediaIsMobile ? "1.5em" : "1.2em"
|
|
2325
2020
|
}
|
|
2326
2021
|
})), /*#__PURE__*/React__default.createElement(Button, {
|
|
2327
|
-
sx:
|
|
2022
|
+
sx: { ...buttonStyle,
|
|
2328
2023
|
color: "#ececec"
|
|
2329
|
-
}
|
|
2024
|
+
},
|
|
2330
2025
|
onClick: zoomOut
|
|
2331
2026
|
}, /*#__PURE__*/React__default.createElement(RemoveCircleOutlineIcon, {
|
|
2332
2027
|
sx: {
|
|
@@ -2335,10 +2030,10 @@ var MlNavigationTools = function MlNavigationTools(props) {
|
|
|
2335
2030
|
}))));
|
|
2336
2031
|
};
|
|
2337
2032
|
|
|
2338
|
-
|
|
2033
|
+
const MlLayer = props => {
|
|
2339
2034
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
2340
|
-
|
|
2341
|
-
|
|
2035
|
+
const mapContext = useContext(MapContext);
|
|
2036
|
+
const mapState = useMapState({
|
|
2342
2037
|
mapId: props.mapId,
|
|
2343
2038
|
watch: {
|
|
2344
2039
|
viewport: false,
|
|
@@ -2346,29 +2041,29 @@ var MlLayer = function MlLayer(props) {
|
|
|
2346
2041
|
sources: false
|
|
2347
2042
|
}
|
|
2348
2043
|
});
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
useEffect(
|
|
2356
|
-
|
|
2357
|
-
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 () => {
|
|
2358
2053
|
if (mapRef.current) {
|
|
2359
2054
|
mapRef.current.cleanup(_componentId);
|
|
2360
2055
|
mapRef.current = null;
|
|
2361
2056
|
}
|
|
2362
2057
|
};
|
|
2363
2058
|
}, []);
|
|
2364
|
-
useEffect(
|
|
2059
|
+
useEffect(() => {
|
|
2365
2060
|
var _mapContext$getMap, _mapContext$getMap$ge;
|
|
2366
2061
|
|
|
2367
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
|
|
2368
2063
|
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
2369
2064
|
|
|
2370
2065
|
var key;
|
|
2371
|
-
|
|
2066
|
+
let layoutString = JSON.stringify(props.options.layout);
|
|
2372
2067
|
|
|
2373
2068
|
if (props.options.layout && layoutString !== layerLayoutConfRef.current) {
|
|
2374
2069
|
for (key in props.options.layout) {
|
|
@@ -2378,7 +2073,7 @@ var MlLayer = function MlLayer(props) {
|
|
|
2378
2073
|
layerLayoutConfRef.current = layoutString;
|
|
2379
2074
|
}
|
|
2380
2075
|
|
|
2381
|
-
|
|
2076
|
+
let paintString = JSON.stringify(props.options.paint);
|
|
2382
2077
|
|
|
2383
2078
|
if (props.options.paint && paintString === layerPaintConfRef.current) {
|
|
2384
2079
|
for (key in props.options.paint) {
|
|
@@ -2386,7 +2081,7 @@ var MlLayer = function MlLayer(props) {
|
|
|
2386
2081
|
}
|
|
2387
2082
|
}
|
|
2388
2083
|
}, [props.options, layerId, mapContext, props]);
|
|
2389
|
-
useEffect(
|
|
2084
|
+
useEffect(() => {
|
|
2390
2085
|
if (!mapContext.mapExists(props.mapId) || layerInitializedRef.current) return; // the MapLibre-gl instance (mapContext.map) is accessible here
|
|
2391
2086
|
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
2392
2087
|
//check if insertBeforeLayer exists
|
|
@@ -2394,8 +2089,8 @@ var MlLayer = function MlLayer(props) {
|
|
|
2394
2089
|
if (props.insertBeforeLayer) {
|
|
2395
2090
|
var _mapState$layers;
|
|
2396
2091
|
|
|
2397
|
-
|
|
2398
|
-
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 => {
|
|
2399
2094
|
if (layer.id === props.insertBeforeLayer) {
|
|
2400
2095
|
layerFound = true;
|
|
2401
2096
|
}
|
|
@@ -2412,13 +2107,14 @@ var MlLayer = function MlLayer(props) {
|
|
|
2412
2107
|
var _props$options, _props$options2;
|
|
2413
2108
|
|
|
2414
2109
|
layerInitializedRef.current = true;
|
|
2415
|
-
mapRef.current.addLayer(
|
|
2110
|
+
mapRef.current.addLayer({
|
|
2416
2111
|
id: layerId.current,
|
|
2417
2112
|
type: "background",
|
|
2418
2113
|
paint: {
|
|
2419
2114
|
"background-color": "rgba(0,0,0,0)"
|
|
2420
|
-
}
|
|
2421
|
-
|
|
2115
|
+
},
|
|
2116
|
+
...props.options
|
|
2117
|
+
}, props.insertBeforeLayer, componentId.current);
|
|
2422
2118
|
layerPaintConfRef.current = JSON.stringify((_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.paint);
|
|
2423
2119
|
layerLayoutConfRef.current = JSON.stringify((_props$options2 = props.options) === null || _props$options2 === void 0 ? void 0 : _props$options2.layout);
|
|
2424
2120
|
}
|
|
@@ -2433,25 +2129,27 @@ var MlLayer = function MlLayer(props) {
|
|
|
2433
2129
|
* @component
|
|
2434
2130
|
*/
|
|
2435
2131
|
|
|
2436
|
-
|
|
2437
|
-
|
|
2132
|
+
const MlOsmLayer = props => {
|
|
2133
|
+
const mapHook = useMap({
|
|
2438
2134
|
mapId: props.mapId,
|
|
2439
2135
|
waitForLayer: props.insertBeforeLayer
|
|
2440
2136
|
});
|
|
2441
|
-
|
|
2442
|
-
useEffect(
|
|
2137
|
+
const layerId = useRef(props.layerId || "MlOsmLayer-" + mapHook.componentId);
|
|
2138
|
+
useEffect(() => {
|
|
2443
2139
|
if (!mapHook.map) return;
|
|
2444
|
-
mapHook.map.addSource(layerId.current,
|
|
2140
|
+
mapHook.map.addSource(layerId.current, {
|
|
2445
2141
|
type: "raster",
|
|
2446
|
-
tileSize: 256
|
|
2447
|
-
|
|
2448
|
-
mapHook.
|
|
2142
|
+
tileSize: 256,
|
|
2143
|
+
...props.sourceOptions
|
|
2144
|
+
}, mapHook.componentId);
|
|
2145
|
+
mapHook.map.addLayer({
|
|
2449
2146
|
id: layerId.current,
|
|
2450
2147
|
type: "raster",
|
|
2451
2148
|
source: layerId.current,
|
|
2452
2149
|
minzoom: 0,
|
|
2453
|
-
maxzoom: 22
|
|
2454
|
-
|
|
2150
|
+
maxzoom: 22,
|
|
2151
|
+
...props.layerOptions
|
|
2152
|
+
}, props.insertBeforeLayer, mapHook.componentId);
|
|
2455
2153
|
}, [props, mapHook.map]);
|
|
2456
2154
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
|
|
2457
2155
|
};
|
|
@@ -2492,32 +2190,33 @@ MlOsmLayer.propTypes = {
|
|
|
2492
2190
|
* @component
|
|
2493
2191
|
*/
|
|
2494
2192
|
|
|
2495
|
-
|
|
2496
|
-
|
|
2193
|
+
const MlVectorTileLayer = props => {
|
|
2194
|
+
const mapHook = useMap({
|
|
2497
2195
|
mapId: props.mapId,
|
|
2498
2196
|
waitForLayer: props.insertBeforeLayer
|
|
2499
2197
|
});
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
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(() => {
|
|
2506
2204
|
if (!mapHook.map || initializedRef.current) return;
|
|
2507
2205
|
initializedRef.current = true; // Add the new layer to the openlayers instance once it is available
|
|
2508
2206
|
|
|
2509
|
-
mapHook.map.addSource(layerId.current,
|
|
2207
|
+
mapHook.map.addSource(layerId.current, {
|
|
2510
2208
|
type: "vector",
|
|
2511
2209
|
tiles: [props.url],
|
|
2512
2210
|
tileSize: 512,
|
|
2513
|
-
attribution: ""
|
|
2514
|
-
|
|
2211
|
+
attribution: "",
|
|
2212
|
+
...props.sourceOptions
|
|
2213
|
+
}, mapHook.componentId);
|
|
2515
2214
|
|
|
2516
|
-
for (
|
|
2517
|
-
|
|
2215
|
+
for (let key in props.layers) {
|
|
2216
|
+
let _layerId = layerId.current + "_" + key;
|
|
2518
2217
|
|
|
2519
2218
|
layerIdsRef.current[key] = _layerId;
|
|
2520
|
-
mapHook.map.addLayer(
|
|
2219
|
+
mapHook.map.addLayer({
|
|
2521
2220
|
id: _layerId,
|
|
2522
2221
|
source: layerId.current,
|
|
2523
2222
|
type: "line",
|
|
@@ -2528,32 +2227,33 @@ var MlVectorTileLayer = function MlVectorTileLayer(props) {
|
|
|
2528
2227
|
"line-opacity": 0.5,
|
|
2529
2228
|
"line-color": "rgb(80, 80, 80)",
|
|
2530
2229
|
"line-width": 2
|
|
2531
|
-
}
|
|
2532
|
-
|
|
2230
|
+
},
|
|
2231
|
+
...props.layers[key]
|
|
2232
|
+
}, props.insertBeforeLayer, mapHook.componentId);
|
|
2533
2233
|
layerPaintConfsRef.current[key] = JSON.stringify(props.layers[key].paint);
|
|
2534
2234
|
layerLayoutConfsRef.current[key] = JSON.stringify(props.layers[key].layout);
|
|
2535
2235
|
}
|
|
2536
2236
|
}, [mapHook.map, props]);
|
|
2537
|
-
useEffect(
|
|
2237
|
+
useEffect(() => {
|
|
2538
2238
|
if (!mapHook.map || !initializedRef.current) return; // initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
2539
2239
|
|
|
2540
2240
|
for (var key in props.layers) {
|
|
2541
2241
|
if (mapHook.map.getLayer(layerIdsRef.current[key])) {
|
|
2542
2242
|
// update changed paint property
|
|
2543
|
-
|
|
2243
|
+
let layerPaintConfString = JSON.stringify(props.layers[key].paint);
|
|
2544
2244
|
|
|
2545
2245
|
if (layerPaintConfString !== layerPaintConfsRef.current[key]) {
|
|
2546
|
-
for (
|
|
2246
|
+
for (let paintKey in props.layers[key].paint) {
|
|
2547
2247
|
mapHook.map.setPaintProperty(layerIdsRef.current[key], paintKey, props.layers[key].paint[paintKey]);
|
|
2548
2248
|
}
|
|
2549
2249
|
}
|
|
2550
2250
|
|
|
2551
2251
|
layerPaintConfsRef.current[key] = layerPaintConfString; // update changed layout property
|
|
2552
2252
|
|
|
2553
|
-
|
|
2253
|
+
let layerLayoutConfString = JSON.stringify(props.layers[key].layout);
|
|
2554
2254
|
|
|
2555
2255
|
if (layerLayoutConfString !== layerLayoutConfsRef.current[key]) {
|
|
2556
|
-
for (
|
|
2256
|
+
for (let layoutKey in props.layers[key].layout) {
|
|
2557
2257
|
mapHook.map.setLayoutProperty(layerIdsRef.current[key], layoutKey, props.layers[key].layout[layoutKey]);
|
|
2558
2258
|
}
|
|
2559
2259
|
}
|
|
@@ -2587,7 +2287,7 @@ MlVectorTileLayer.propTypes = {
|
|
|
2587
2287
|
url: PropTypes.string
|
|
2588
2288
|
};
|
|
2589
2289
|
|
|
2590
|
-
|
|
2290
|
+
const defaultProps = {
|
|
2591
2291
|
visible: true,
|
|
2592
2292
|
urlParameters: {
|
|
2593
2293
|
bbox: "{bbox-epsg-3857}",
|
|
@@ -2627,52 +2327,56 @@ var defaultProps = {
|
|
|
2627
2327
|
* @component
|
|
2628
2328
|
*/
|
|
2629
2329
|
|
|
2630
|
-
|
|
2631
|
-
|
|
2330
|
+
const MlWmsLayer = props => {
|
|
2331
|
+
const mapHook = useMap({
|
|
2632
2332
|
mapId: props.mapId,
|
|
2633
2333
|
waitForLayer: props.insertBeforeLayer
|
|
2634
2334
|
});
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
useEffect(
|
|
2335
|
+
const initializedRef = useRef(false);
|
|
2336
|
+
const layerId = useRef(props.layerId || "MlWmsLayer-" + mapHook.componentId);
|
|
2337
|
+
useEffect(() => {
|
|
2638
2338
|
var _propsUrlParams2;
|
|
2639
2339
|
|
|
2640
2340
|
if (!mapHook.map || initializedRef.current) return;
|
|
2641
2341
|
initializedRef.current = true;
|
|
2642
2342
|
|
|
2643
|
-
|
|
2343
|
+
let _propsUrlParams;
|
|
2644
2344
|
|
|
2645
|
-
|
|
2345
|
+
let _wmsUrl = props.url;
|
|
2646
2346
|
|
|
2647
2347
|
if (props.url.indexOf("?") !== -1) {
|
|
2648
2348
|
_propsUrlParams = props.url.split("?");
|
|
2649
2349
|
_wmsUrl = _propsUrlParams[0];
|
|
2650
2350
|
}
|
|
2651
2351
|
|
|
2652
|
-
|
|
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
|
|
2653
2353
|
|
|
2654
2354
|
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
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, {
|
|
2660
2362
|
type: "raster",
|
|
2661
2363
|
tiles: [_wmsUrl + "?" + urlParamsStr],
|
|
2662
2364
|
tileSize: urlParamsObj.width,
|
|
2663
|
-
attribution: props.attribution
|
|
2664
|
-
|
|
2665
|
-
mapHook.
|
|
2365
|
+
attribution: props.attribution,
|
|
2366
|
+
...props.sourceOptions
|
|
2367
|
+
}, mapHook.componentId);
|
|
2368
|
+
mapHook.map.addLayer({
|
|
2666
2369
|
id: layerId.current,
|
|
2667
2370
|
type: "raster",
|
|
2668
|
-
source: layerId.current
|
|
2669
|
-
|
|
2371
|
+
source: layerId.current,
|
|
2372
|
+
...props.layerOptions
|
|
2373
|
+
}, props.insertBeforeLayer, mapHook.componentId);
|
|
2670
2374
|
|
|
2671
2375
|
if (!props.visible) {
|
|
2672
2376
|
mapHook.map.setLayoutProperty(layerId.current, "visibility", "none");
|
|
2673
2377
|
}
|
|
2674
2378
|
}, [mapHook, props]);
|
|
2675
|
-
useEffect(
|
|
2379
|
+
useEffect(() => {
|
|
2676
2380
|
if (!mapHook.map || !initializedRef.current) return; // toggle layer visibility by changing the layout object's visibility property
|
|
2677
2381
|
|
|
2678
2382
|
if (props.visible) {
|
|
@@ -2684,7 +2388,8 @@ var MlWmsLayer = function MlWmsLayer(props) {
|
|
|
2684
2388
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
|
|
2685
2389
|
};
|
|
2686
2390
|
|
|
2687
|
-
MlWmsLayer.defaultProps =
|
|
2391
|
+
MlWmsLayer.defaultProps = { ...defaultProps
|
|
2392
|
+
};
|
|
2688
2393
|
MlWmsLayer.propTypes = {
|
|
2689
2394
|
/**
|
|
2690
2395
|
* WMS URL
|
|
@@ -2738,7 +2443,7 @@ MlWmsLayer.propTypes = {
|
|
|
2738
2443
|
visible: PropTypes.bool
|
|
2739
2444
|
};
|
|
2740
2445
|
|
|
2741
|
-
|
|
2446
|
+
const classes = {
|
|
2742
2447
|
CONTROL_BASE: 'mapboxgl-ctrl',
|
|
2743
2448
|
CONTROL_PREFIX: 'mapboxgl-ctrl-',
|
|
2744
2449
|
CONTROL_BUTTON: 'mapbox-gl-draw_ctrl-draw-btn',
|
|
@@ -2753,19 +2458,23 @@ var classes = {
|
|
|
2753
2458
|
ACTIVE_BUTTON: 'active',
|
|
2754
2459
|
BOX_SELECT: 'mapbox-gl-draw_boxselect'
|
|
2755
2460
|
};
|
|
2756
|
-
|
|
2461
|
+
const sources = {
|
|
2462
|
+
HOT: 'mapbox-gl-draw-hot',
|
|
2463
|
+
COLD: 'mapbox-gl-draw-cold'
|
|
2464
|
+
};
|
|
2465
|
+
const cursors = {
|
|
2757
2466
|
ADD: 'add',
|
|
2758
2467
|
MOVE: 'move',
|
|
2759
2468
|
DRAG: 'drag',
|
|
2760
2469
|
POINTER: 'pointer',
|
|
2761
2470
|
NONE: 'none'
|
|
2762
2471
|
};
|
|
2763
|
-
|
|
2472
|
+
const types = {
|
|
2764
2473
|
POLYGON: 'polygon',
|
|
2765
2474
|
LINE: 'line_string',
|
|
2766
2475
|
POINT: 'point'
|
|
2767
2476
|
};
|
|
2768
|
-
|
|
2477
|
+
const geojsonTypes = {
|
|
2769
2478
|
FEATURE: 'Feature',
|
|
2770
2479
|
POLYGON: 'Polygon',
|
|
2771
2480
|
LINE_STRING: 'LineString',
|
|
@@ -2776,7 +2485,15 @@ var geojsonTypes = {
|
|
|
2776
2485
|
MULTI_LINE_STRING: 'MultiLineString',
|
|
2777
2486
|
MULTI_POLYGON: 'MultiPolygon'
|
|
2778
2487
|
};
|
|
2779
|
-
|
|
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 = {
|
|
2780
2497
|
CREATE: 'draw.create',
|
|
2781
2498
|
DELETE: 'draw.delete',
|
|
2782
2499
|
UPDATE: 'draw.update',
|
|
@@ -2787,29 +2504,51 @@ var events = {
|
|
|
2787
2504
|
COMBINE_FEATURES: 'draw.combine',
|
|
2788
2505
|
UNCOMBINE_FEATURES: 'draw.uncombine'
|
|
2789
2506
|
};
|
|
2790
|
-
|
|
2507
|
+
const updateActions = {
|
|
2791
2508
|
MOVE: 'move',
|
|
2792
2509
|
CHANGE_COORDINATES: 'change_coordinates'
|
|
2793
2510
|
};
|
|
2794
|
-
|
|
2511
|
+
const meta = {
|
|
2795
2512
|
FEATURE: 'feature',
|
|
2796
2513
|
MIDPOINT: 'midpoint',
|
|
2797
2514
|
VERTEX: 'vertex'
|
|
2798
2515
|
};
|
|
2799
|
-
|
|
2516
|
+
const activeStates = {
|
|
2800
2517
|
ACTIVE: 'true',
|
|
2801
2518
|
INACTIVE: 'false'
|
|
2802
2519
|
};
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
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
|
+
});
|
|
2809
2548
|
|
|
2810
2549
|
function isOfMetaType(type) {
|
|
2811
2550
|
return function (e) {
|
|
2812
|
-
|
|
2551
|
+
const featureTarget = e.featureTarget;
|
|
2813
2552
|
if (!featureTarget) return false;
|
|
2814
2553
|
if (!featureTarget.properties) return false;
|
|
2815
2554
|
return featureTarget.properties.meta === type;
|
|
@@ -2839,7 +2578,7 @@ function isFeature(e) {
|
|
|
2839
2578
|
return e.featureTarget.properties.meta === meta.FEATURE;
|
|
2840
2579
|
}
|
|
2841
2580
|
function isVertex(e) {
|
|
2842
|
-
|
|
2581
|
+
const featureTarget = e.featureTarget;
|
|
2843
2582
|
if (!featureTarget) return false;
|
|
2844
2583
|
if (!featureTarget.properties) return false;
|
|
2845
2584
|
return featureTarget.properties.meta === meta.VERTEX;
|
|
@@ -2855,9 +2594,9 @@ function isEnterKey(e) {
|
|
|
2855
2594
|
return e.keyCode === 13;
|
|
2856
2595
|
}
|
|
2857
2596
|
|
|
2858
|
-
|
|
2859
|
-
enable
|
|
2860
|
-
setTimeout(
|
|
2597
|
+
const doubleClickZoom = {
|
|
2598
|
+
enable(ctx) {
|
|
2599
|
+
setTimeout(() => {
|
|
2861
2600
|
// First check we've got a map and some context.
|
|
2862
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)
|
|
2863
2602
|
|
|
@@ -2865,13 +2604,15 @@ var doubleClickZoom = {
|
|
|
2865
2604
|
ctx.map.doubleClickZoom.enable();
|
|
2866
2605
|
}, 0);
|
|
2867
2606
|
},
|
|
2868
|
-
|
|
2869
|
-
|
|
2607
|
+
|
|
2608
|
+
disable(ctx) {
|
|
2609
|
+
setTimeout(() => {
|
|
2870
2610
|
if (!ctx.map || !ctx.map.doubleClickZoom) return; // Always disable here, as it's necessary in some cases.
|
|
2871
2611
|
|
|
2872
2612
|
ctx.map.doubleClickZoom.disable();
|
|
2873
2613
|
}, 0);
|
|
2874
2614
|
}
|
|
2615
|
+
|
|
2875
2616
|
};
|
|
2876
2617
|
|
|
2877
2618
|
function isEventAtCoordinates(event, coordinates) {
|
|
@@ -2891,7 +2632,7 @@ function isEventAtCoordinates(event, coordinates) {
|
|
|
2891
2632
|
* @return {GeoJSON} Point
|
|
2892
2633
|
*/
|
|
2893
2634
|
|
|
2894
|
-
|
|
2635
|
+
const create_vertex = function (parentId, coordinates, path, selected) {
|
|
2895
2636
|
return {
|
|
2896
2637
|
type: geojsonTypes.FEATURE,
|
|
2897
2638
|
properties: {
|
|
@@ -2902,16 +2643,16 @@ var create_vertex = function create_vertex(parentId, coordinates, path, selected
|
|
|
2902
2643
|
},
|
|
2903
2644
|
geometry: {
|
|
2904
2645
|
type: geojsonTypes.POINT,
|
|
2905
|
-
coordinates
|
|
2646
|
+
coordinates
|
|
2906
2647
|
}
|
|
2907
2648
|
};
|
|
2908
2649
|
};
|
|
2909
2650
|
|
|
2910
|
-
|
|
2651
|
+
const CustomPolygonMode = {};
|
|
2911
2652
|
|
|
2912
2653
|
CustomPolygonMode.onSetup = function () {
|
|
2913
2654
|
console.log("Change mode: custom polygon");
|
|
2914
|
-
|
|
2655
|
+
const polygon = this.newFeature({
|
|
2915
2656
|
type: geojsonTypes.FEATURE,
|
|
2916
2657
|
properties: {},
|
|
2917
2658
|
geometry: {
|
|
@@ -2930,7 +2671,7 @@ CustomPolygonMode.onSetup = function () {
|
|
|
2930
2671
|
trash: true
|
|
2931
2672
|
});
|
|
2932
2673
|
return {
|
|
2933
|
-
polygon
|
|
2674
|
+
polygon,
|
|
2934
2675
|
currentVertexPosition: 0
|
|
2935
2676
|
};
|
|
2936
2677
|
};
|
|
@@ -3013,13 +2754,13 @@ CustomPolygonMode.onStop = function (state) {
|
|
|
3013
2754
|
};
|
|
3014
2755
|
|
|
3015
2756
|
CustomPolygonMode.toDisplayFeatures = function (state, geojson, display) {
|
|
3016
|
-
|
|
2757
|
+
const isActivePolygon = geojson.properties.id === state.polygon.id;
|
|
3017
2758
|
geojson.properties.active = isActivePolygon ? activeStates.ACTIVE : activeStates.INACTIVE;
|
|
3018
2759
|
if (!isActivePolygon) return display(geojson); // Don't render a polygon until it has two positions
|
|
3019
2760
|
// (and a 3rd which is just the first repeated)
|
|
3020
2761
|
|
|
3021
2762
|
if (geojson.geometry.coordinates.length === 0) return;
|
|
3022
|
-
|
|
2763
|
+
const coordinateCount = geojson.geometry.coordinates[0].length; // 2 coordinates after selecting a draw type
|
|
3023
2764
|
// 3 after creating the first point
|
|
3024
2765
|
|
|
3025
2766
|
if (coordinateCount < 3) {
|
|
@@ -3032,14 +2773,14 @@ CustomPolygonMode.toDisplayFeatures = function (state, geojson, display) {
|
|
|
3032
2773
|
if (coordinateCount > 3) {
|
|
3033
2774
|
// Add a start position marker to the map, clicking on this will finish the feature
|
|
3034
2775
|
// This should only be shown when we're in a valid spot
|
|
3035
|
-
|
|
2776
|
+
const endPos = geojson.geometry.coordinates[0].length - 3;
|
|
3036
2777
|
display(create_vertex(state.polygon.id, geojson.geometry.coordinates[0][endPos], "0.".concat(endPos), false));
|
|
3037
2778
|
}
|
|
3038
2779
|
|
|
3039
2780
|
if (coordinateCount <= 4) {
|
|
3040
2781
|
// If we've only drawn two positions (plus the closer),
|
|
3041
2782
|
// make a LineString instead of a Polygon
|
|
3042
|
-
|
|
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
|
|
3043
2784
|
|
|
3044
2785
|
display({
|
|
3045
2786
|
type: geojsonTypes.FEATURE,
|
|
@@ -3076,20 +2817,20 @@ CustomPolygonMode.onTrash = function (state) {
|
|
|
3076
2817
|
*/
|
|
3077
2818
|
|
|
3078
2819
|
function mouseEventPoint(mouseEvent, container) {
|
|
3079
|
-
|
|
2820
|
+
const rect = container.getBoundingClientRect();
|
|
3080
2821
|
return new Point(mouseEvent.clientX - rect.left - (container.clientLeft || 0), mouseEvent.clientY - rect.top - (container.clientTop || 0));
|
|
3081
2822
|
}
|
|
3082
2823
|
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
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,
|
|
3086
2827
|
// so run away
|
|
3087
2828
|
|
|
3088
2829
|
if (startCoord[1] > LAT_RENDERED_MAX || startCoord[1] < LAT_RENDERED_MIN || endCoord[1] > LAT_RENDERED_MAX || endCoord[1] < LAT_RENDERED_MIN) {
|
|
3089
2830
|
return null;
|
|
3090
2831
|
}
|
|
3091
2832
|
|
|
3092
|
-
|
|
2833
|
+
const mid = {
|
|
3093
2834
|
lng: (startCoord[0] + endCoord[0]) / 2,
|
|
3094
2835
|
lat: (startCoord[1] + endCoord[1]) / 2
|
|
3095
2836
|
};
|
|
@@ -3097,7 +2838,7 @@ var create_midpoint = function create_midpoint(parent, startVertex, endVertex) {
|
|
|
3097
2838
|
type: geojsonTypes.FEATURE,
|
|
3098
2839
|
properties: {
|
|
3099
2840
|
meta: meta.MIDPOINT,
|
|
3100
|
-
parent
|
|
2841
|
+
parent,
|
|
3101
2842
|
lng: mid.lng,
|
|
3102
2843
|
lat: mid.lat,
|
|
3103
2844
|
coord_path: endVertex.properties.coord_path
|
|
@@ -3110,13 +2851,14 @@ var create_midpoint = function create_midpoint(parent, startVertex, endVertex) {
|
|
|
3110
2851
|
};
|
|
3111
2852
|
|
|
3112
2853
|
function createSupplementaryPoints(geojson) {
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
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 = [];
|
|
3120
2862
|
|
|
3121
2863
|
if (type === geojsonTypes.POINT) {
|
|
3122
2864
|
// For points, just create a vertex
|
|
@@ -3124,7 +2866,7 @@ function createSupplementaryPoints(geojson) {
|
|
|
3124
2866
|
} else if (type === geojsonTypes.POLYGON) {
|
|
3125
2867
|
// Cycle through a Polygon's rings and
|
|
3126
2868
|
// process each line
|
|
3127
|
-
coordinates.forEach(
|
|
2869
|
+
coordinates.forEach((line, lineIndex) => {
|
|
3128
2870
|
processLine(line, basePath !== null ? "".concat(basePath, ".").concat(lineIndex) : String(lineIndex));
|
|
3129
2871
|
});
|
|
3130
2872
|
} else if (type === geojsonTypes.LINE_STRING) {
|
|
@@ -3134,16 +2876,16 @@ function createSupplementaryPoints(geojson) {
|
|
|
3134
2876
|
}
|
|
3135
2877
|
|
|
3136
2878
|
function processLine(line, lineBasePath) {
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
line.forEach(
|
|
3140
|
-
|
|
3141
|
-
|
|
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
|
|
3142
2884
|
// vertex before this one. If so, add a midpoint
|
|
3143
2885
|
// between that vertex and this one.
|
|
3144
2886
|
|
|
3145
2887
|
if (options.midpoints && lastVertex) {
|
|
3146
|
-
|
|
2888
|
+
const midpoint = create_midpoint(featureId, lastVertex, vertex);
|
|
3147
2889
|
|
|
3148
2890
|
if (midpoint) {
|
|
3149
2891
|
supplementaryPoints.push(midpoint);
|
|
@@ -3154,7 +2896,7 @@ function createSupplementaryPoints(geojson) {
|
|
|
3154
2896
|
// point, we want to draw a midpoint before it but not another vertex on it
|
|
3155
2897
|
// (since we already a vertex there, from the first point).
|
|
3156
2898
|
|
|
3157
|
-
|
|
2899
|
+
const stringifiedPoint = JSON.stringify(point);
|
|
3158
2900
|
|
|
3159
2901
|
if (firstPointString !== stringifiedPoint) {
|
|
3160
2902
|
supplementaryPoints.push(vertex);
|
|
@@ -3175,9 +2917,9 @@ function createSupplementaryPoints(geojson) {
|
|
|
3175
2917
|
|
|
3176
2918
|
|
|
3177
2919
|
function processMultiGeometry() {
|
|
3178
|
-
|
|
3179
|
-
coordinates.forEach(
|
|
3180
|
-
|
|
2920
|
+
const subType = type.replace(geojsonTypes.MULTI_PREFIX, "");
|
|
2921
|
+
coordinates.forEach((subCoordinates, index) => {
|
|
2922
|
+
const subFeature = {
|
|
3181
2923
|
type: geojsonTypes.FEATURE,
|
|
3182
2924
|
properties: geojson.properties,
|
|
3183
2925
|
geometry: {
|
|
@@ -3198,7 +2940,7 @@ function StringSet(items) {
|
|
|
3198
2940
|
this._length = items ? items.length : 0;
|
|
3199
2941
|
if (!items) return;
|
|
3200
2942
|
|
|
3201
|
-
for (
|
|
2943
|
+
for (let i = 0, l = items.length; i < l; i++) {
|
|
3202
2944
|
this.add(items[i]);
|
|
3203
2945
|
if (items[i] === undefined) continue;
|
|
3204
2946
|
if (typeof items[i] === 'string') this._items[items[i]] = i;else this._nums[items[i]] = i;
|
|
@@ -3226,26 +2968,20 @@ StringSet.prototype.has = function (x) {
|
|
|
3226
2968
|
};
|
|
3227
2969
|
|
|
3228
2970
|
StringSet.prototype.values = function () {
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
var values = [];
|
|
3232
|
-
Object.keys(this._items).forEach(function (k) {
|
|
2971
|
+
const values = [];
|
|
2972
|
+
Object.keys(this._items).forEach(k => {
|
|
3233
2973
|
values.push({
|
|
3234
|
-
k
|
|
3235
|
-
v:
|
|
2974
|
+
k,
|
|
2975
|
+
v: this._items[k]
|
|
3236
2976
|
});
|
|
3237
2977
|
});
|
|
3238
|
-
Object.keys(this._nums).forEach(
|
|
2978
|
+
Object.keys(this._nums).forEach(k => {
|
|
3239
2979
|
values.push({
|
|
3240
2980
|
k: JSON.parse(k),
|
|
3241
|
-
v:
|
|
2981
|
+
v: this._nums[k]
|
|
3242
2982
|
});
|
|
3243
2983
|
});
|
|
3244
|
-
return values.sort(
|
|
3245
|
-
return a.v - b.v;
|
|
3246
|
-
}).map(function (a) {
|
|
3247
|
-
return a.k;
|
|
3248
|
-
});
|
|
2984
|
+
return values.sort((a, b) => a.v - b.v).map(a => a.k);
|
|
3249
2985
|
};
|
|
3250
2986
|
|
|
3251
2987
|
StringSet.prototype.clear = function () {
|
|
@@ -3255,31 +2991,33 @@ StringSet.prototype.clear = function () {
|
|
|
3255
2991
|
return this;
|
|
3256
2992
|
};
|
|
3257
2993
|
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
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
|
|
3264
3002
|
// - any part of any feature to exceed the poles
|
|
3265
3003
|
// - any feature to be completely lost in the space between the projection's
|
|
3266
3004
|
// edge and the poles, such that it couldn't be re-selected and moved back
|
|
3267
3005
|
|
|
3268
|
-
|
|
3006
|
+
const constrain_feature_movement = function (geojsonFeatures, delta) {
|
|
3269
3007
|
// "inner edge" = a feature's latitude closest to the equator
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
geojsonFeatures.forEach(
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
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];
|
|
3283
3021
|
if (featureSouthEdge > northInnerEdge) northInnerEdge = featureSouthEdge;
|
|
3284
3022
|
if (featureNorthEdge < southInnerEdge) southInnerEdge = featureNorthEdge;
|
|
3285
3023
|
if (featureNorthEdge > northOuterEdge) northOuterEdge = featureNorthEdge;
|
|
@@ -3290,7 +3028,7 @@ var constrain_feature_movement = function constrain_feature_movement(geojsonFeat
|
|
|
3290
3028
|
// edge but also have hit the outer edge and therefore need
|
|
3291
3029
|
// another readjustment
|
|
3292
3030
|
|
|
3293
|
-
|
|
3031
|
+
const constrainedDelta = delta;
|
|
3294
3032
|
|
|
3295
3033
|
if (northInnerEdge + constrainedDelta.lat > LAT_RENDERED_MAX$1) {
|
|
3296
3034
|
constrainedDelta.lat = LAT_RENDERED_MAX$1 - northInnerEdge;
|
|
@@ -3319,34 +3057,24 @@ var constrain_feature_movement = function constrain_feature_movement(geojsonFeat
|
|
|
3319
3057
|
return constrainedDelta;
|
|
3320
3058
|
};
|
|
3321
3059
|
|
|
3322
|
-
var move_features = function
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
features.forEach(function (feature) {
|
|
3327
|
-
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();
|
|
3328
3064
|
|
|
3329
|
-
|
|
3330
|
-
|
|
3065
|
+
const moveCoordinate = coord => {
|
|
3066
|
+
const point = {
|
|
3331
3067
|
lng: coord[0] + constrainedDelta.lng,
|
|
3332
3068
|
lat: coord[1] + constrainedDelta.lat
|
|
3333
3069
|
};
|
|
3334
3070
|
return [point.lng, point.lat];
|
|
3335
3071
|
};
|
|
3336
3072
|
|
|
3337
|
-
|
|
3338
|
-
return ring.map(function (coord) {
|
|
3339
|
-
return moveCoordinate(coord);
|
|
3340
|
-
});
|
|
3341
|
-
};
|
|
3073
|
+
const moveRing = ring => ring.map(coord => moveCoordinate(coord));
|
|
3342
3074
|
|
|
3343
|
-
|
|
3344
|
-
return multi.map(function (ring) {
|
|
3345
|
-
return moveRing(ring);
|
|
3346
|
-
});
|
|
3347
|
-
};
|
|
3075
|
+
const moveMultiPolygon = multi => multi.map(ring => moveRing(ring));
|
|
3348
3076
|
|
|
3349
|
-
|
|
3077
|
+
let nextCoordinates;
|
|
3350
3078
|
|
|
3351
3079
|
if (feature.type === geojsonTypes.POINT) {
|
|
3352
3080
|
nextCoordinates = moveCoordinate(currentCoordinates);
|
|
@@ -3362,14 +3090,12 @@ var move_features = function move_features(features, delta) {
|
|
|
3362
3090
|
});
|
|
3363
3091
|
};
|
|
3364
3092
|
|
|
3365
|
-
|
|
3093
|
+
const CustomSelectMode = {};
|
|
3366
3094
|
|
|
3367
3095
|
CustomSelectMode.onSetup = function (opts) {
|
|
3368
|
-
var _this = this;
|
|
3369
|
-
|
|
3370
3096
|
console.log("Change mode: custom select"); // turn the opts into state.
|
|
3371
3097
|
|
|
3372
|
-
|
|
3098
|
+
const state = {
|
|
3373
3099
|
dragMoveLocation: null,
|
|
3374
3100
|
boxSelectStartLocation: null,
|
|
3375
3101
|
boxSelectElement: undefined,
|
|
@@ -3379,9 +3105,7 @@ CustomSelectMode.onSetup = function (opts) {
|
|
|
3379
3105
|
canDragMove: false,
|
|
3380
3106
|
initiallySelectedFeatureIds: opts.featureIds || []
|
|
3381
3107
|
};
|
|
3382
|
-
this.setSelected(state.initiallySelectedFeatureIds.filter(
|
|
3383
|
-
return _this.getFeature(id) !== undefined;
|
|
3384
|
-
}));
|
|
3108
|
+
this.setSelected(state.initiallySelectedFeatureIds.filter(id => this.getFeature(id) !== undefined));
|
|
3385
3109
|
this.fireActionable();
|
|
3386
3110
|
this.setActionableState({
|
|
3387
3111
|
combineFeatures: true,
|
|
@@ -3394,47 +3118,37 @@ CustomSelectMode.onSetup = function (opts) {
|
|
|
3394
3118
|
CustomSelectMode.fireUpdate = function () {
|
|
3395
3119
|
this.map.fire(events.UPDATE, {
|
|
3396
3120
|
action: updateActions.MOVE,
|
|
3397
|
-
features: this.getSelected().map(
|
|
3398
|
-
return f.toGeoJSON();
|
|
3399
|
-
})
|
|
3121
|
+
features: this.getSelected().map(f => f.toGeoJSON())
|
|
3400
3122
|
});
|
|
3401
3123
|
};
|
|
3402
3124
|
|
|
3403
3125
|
CustomSelectMode.fireActionable = function () {
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
var multiFeatures = selectedFeatures.filter(function (feature) {
|
|
3408
|
-
return _this2.isInstanceOf("MultiFeature", feature);
|
|
3409
|
-
});
|
|
3410
|
-
var combineFeatures = false;
|
|
3126
|
+
const selectedFeatures = this.getSelected();
|
|
3127
|
+
const multiFeatures = selectedFeatures.filter(feature => this.isInstanceOf("MultiFeature", feature));
|
|
3128
|
+
let combineFeatures = false;
|
|
3411
3129
|
|
|
3412
3130
|
if (selectedFeatures.length > 1) {
|
|
3413
3131
|
combineFeatures = true;
|
|
3414
|
-
|
|
3415
|
-
selectedFeatures.forEach(
|
|
3132
|
+
const featureType = selectedFeatures[0].type.replace("Multi", "");
|
|
3133
|
+
selectedFeatures.forEach(feature => {
|
|
3416
3134
|
if (feature.type.replace("Multi", "") !== featureType) {
|
|
3417
3135
|
combineFeatures = false;
|
|
3418
3136
|
}
|
|
3419
3137
|
});
|
|
3420
3138
|
}
|
|
3421
3139
|
|
|
3422
|
-
|
|
3423
|
-
|
|
3140
|
+
const uncombineFeatures = multiFeatures.length > 0;
|
|
3141
|
+
const trash = selectedFeatures.length > 0;
|
|
3424
3142
|
this.setActionableState({
|
|
3425
|
-
combineFeatures
|
|
3426
|
-
uncombineFeatures
|
|
3427
|
-
trash
|
|
3143
|
+
combineFeatures,
|
|
3144
|
+
uncombineFeatures,
|
|
3145
|
+
trash
|
|
3428
3146
|
});
|
|
3429
3147
|
};
|
|
3430
3148
|
|
|
3431
3149
|
CustomSelectMode.getUniqueIds = function (allFeatures) {
|
|
3432
3150
|
if (!allFeatures.length) return [];
|
|
3433
|
-
|
|
3434
|
-
return s.properties.id;
|
|
3435
|
-
}).filter(function (id) {
|
|
3436
|
-
return id !== undefined;
|
|
3437
|
-
}).reduce(function (memo, id) {
|
|
3151
|
+
const ids = allFeatures.map(s => s.properties.id).filter(id => id !== undefined).reduce((memo, id) => {
|
|
3438
3152
|
memo.add(id);
|
|
3439
3153
|
return memo;
|
|
3440
3154
|
}, new StringSet());
|
|
@@ -3482,16 +3196,12 @@ CustomSelectMode.onTap = CustomSelectMode.onClick = function (state, e) {
|
|
|
3482
3196
|
};
|
|
3483
3197
|
|
|
3484
3198
|
CustomSelectMode.clickAnywhere = function (state) {
|
|
3485
|
-
var _this3 = this;
|
|
3486
|
-
|
|
3487
3199
|
// Clear the re-render selection
|
|
3488
|
-
|
|
3200
|
+
const wasSelected = this.getSelectedIds();
|
|
3489
3201
|
|
|
3490
3202
|
if (wasSelected.length) {
|
|
3491
3203
|
this.clearSelectedFeatures();
|
|
3492
|
-
wasSelected.forEach(
|
|
3493
|
-
return _this3.doRender(id);
|
|
3494
|
-
});
|
|
3204
|
+
wasSelected.forEach(id => this.doRender(id));
|
|
3495
3205
|
}
|
|
3496
3206
|
|
|
3497
3207
|
doubleClickZoom.enable(this);
|
|
@@ -3524,20 +3234,18 @@ CustomSelectMode.startOnActiveFeature = function (state, e) {
|
|
|
3524
3234
|
};
|
|
3525
3235
|
|
|
3526
3236
|
CustomSelectMode.clickOnFeature = function (state, e) {
|
|
3527
|
-
var _this4 = this;
|
|
3528
|
-
|
|
3529
3237
|
// Stop everything
|
|
3530
3238
|
doubleClickZoom.disable(this);
|
|
3531
3239
|
this.stopExtendedInteractions(state);
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
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
|
|
3536
3244
|
|
|
3537
3245
|
if (!isShiftClick && isFeatureSelected && this.getFeature(featureId).type !== geojsonTypes.POINT) {
|
|
3538
3246
|
// Enter direct select mode
|
|
3539
3247
|
return this.changeMode("custom_direct_select", {
|
|
3540
|
-
featureId
|
|
3248
|
+
featureId
|
|
3541
3249
|
});
|
|
3542
3250
|
} // Shift-click on a selected feature
|
|
3543
3251
|
|
|
@@ -3561,9 +3269,7 @@ CustomSelectMode.clickOnFeature = function (state, e) {
|
|
|
3561
3269
|
}); // Click (without shift) on an unselected feature
|
|
3562
3270
|
} else if (!isFeatureSelected && !isShiftClick) {
|
|
3563
3271
|
// Make it the only selected feature
|
|
3564
|
-
selectedFeatureIds.forEach(
|
|
3565
|
-
return _this4.doRender(id);
|
|
3566
|
-
});
|
|
3272
|
+
selectedFeatureIds.forEach(id => this.doRender(id));
|
|
3567
3273
|
this.setSelected(featureId);
|
|
3568
3274
|
this.updateUIClasses({
|
|
3569
3275
|
mouse: cursors.MOVE
|
|
@@ -3609,12 +3315,12 @@ CustomSelectMode.whileBoxSelect = function (state, e) {
|
|
|
3609
3315
|
} // Adjust the box node's width and xy position
|
|
3610
3316
|
|
|
3611
3317
|
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
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)");
|
|
3618
3324
|
state.boxSelectElement.style.transform = translateValue;
|
|
3619
3325
|
state.boxSelectElement.style.WebkitTransform = translateValue;
|
|
3620
3326
|
state.boxSelectElement.style.width = "".concat(maxX - minX, "px");
|
|
@@ -3625,7 +3331,7 @@ CustomSelectMode.dragMove = function (state, e) {
|
|
|
3625
3331
|
// Dragging when drag move is enabled
|
|
3626
3332
|
state.dragMoving = true;
|
|
3627
3333
|
e.originalEvent.stopPropagation();
|
|
3628
|
-
|
|
3334
|
+
const delta = {
|
|
3629
3335
|
lng: e.lngLat.lng - state.dragMoveLocation.lng,
|
|
3630
3336
|
lat: e.lngLat.lat - state.dragMoveLocation.lat
|
|
3631
3337
|
};
|
|
@@ -3634,23 +3340,17 @@ CustomSelectMode.dragMove = function (state, e) {
|
|
|
3634
3340
|
};
|
|
3635
3341
|
|
|
3636
3342
|
CustomSelectMode.onMouseUp = function (state, e) {
|
|
3637
|
-
var _this5 = this;
|
|
3638
|
-
|
|
3639
3343
|
// End any extended interactions
|
|
3640
3344
|
if (state.dragMoving) {
|
|
3641
3345
|
this.fireUpdate();
|
|
3642
3346
|
} else if (state.boxSelecting) {
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
return !_this5.isSelected(id);
|
|
3647
|
-
});
|
|
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));
|
|
3648
3350
|
|
|
3649
3351
|
if (idsToSelect.length) {
|
|
3650
3352
|
this.select(idsToSelect);
|
|
3651
|
-
idsToSelect.forEach(
|
|
3652
|
-
return _this5.doRender(id);
|
|
3653
|
-
});
|
|
3353
|
+
idsToSelect.forEach(id => this.doRender(id));
|
|
3654
3354
|
this.updateUIClasses({
|
|
3655
3355
|
mouse: cursors.MOVE
|
|
3656
3356
|
});
|
|
@@ -3674,21 +3374,21 @@ CustomSelectMode.onTrash = function () {
|
|
|
3674
3374
|
};
|
|
3675
3375
|
|
|
3676
3376
|
CustomSelectMode.onCombineFeatures = function () {
|
|
3677
|
-
|
|
3377
|
+
const selectedFeatures = this.getSelected();
|
|
3678
3378
|
if (selectedFeatures.length === 0 || selectedFeatures.length < 2) return;
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3379
|
+
const coordinates = [],
|
|
3380
|
+
featuresCombined = [];
|
|
3381
|
+
const featureType = selectedFeatures[0].type.replace("Multi", "");
|
|
3682
3382
|
|
|
3683
|
-
for (
|
|
3684
|
-
|
|
3383
|
+
for (let i = 0; i < selectedFeatures.length; i++) {
|
|
3384
|
+
const feature = selectedFeatures[i];
|
|
3685
3385
|
|
|
3686
3386
|
if (feature.type.replace("Multi", "") !== featureType) {
|
|
3687
3387
|
return;
|
|
3688
3388
|
}
|
|
3689
3389
|
|
|
3690
3390
|
if (feature.type.includes("Multi")) {
|
|
3691
|
-
feature.getCoordinates().forEach(
|
|
3391
|
+
feature.getCoordinates().forEach(subcoords => {
|
|
3692
3392
|
coordinates.push(subcoords);
|
|
3693
3393
|
});
|
|
3694
3394
|
} else {
|
|
@@ -3699,12 +3399,12 @@ CustomSelectMode.onCombineFeatures = function () {
|
|
|
3699
3399
|
}
|
|
3700
3400
|
|
|
3701
3401
|
if (featuresCombined.length > 1) {
|
|
3702
|
-
|
|
3402
|
+
const multiFeature = this.newFeature({
|
|
3703
3403
|
type: geojsonTypes.FEATURE,
|
|
3704
3404
|
properties: featuresCombined[0].properties,
|
|
3705
3405
|
geometry: {
|
|
3706
3406
|
type: "Multi".concat(featureType),
|
|
3707
|
-
coordinates
|
|
3407
|
+
coordinates
|
|
3708
3408
|
}
|
|
3709
3409
|
});
|
|
3710
3410
|
this.addFeature(multiFeature);
|
|
@@ -3722,41 +3422,31 @@ CustomSelectMode.onCombineFeatures = function () {
|
|
|
3722
3422
|
};
|
|
3723
3423
|
|
|
3724
3424
|
CustomSelectMode.onUncombineFeatures = function () {
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
var selectedFeatures = this.getSelected();
|
|
3425
|
+
const selectedFeatures = this.getSelected();
|
|
3728
3426
|
if (selectedFeatures.length === 0) return;
|
|
3729
|
-
|
|
3730
|
-
|
|
3427
|
+
const createdFeatures = [];
|
|
3428
|
+
const featuresUncombined = [];
|
|
3731
3429
|
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
if (_this6.isInstanceOf("MultiFeature", feature)) {
|
|
3736
|
-
feature.getFeatures().forEach(function (subFeature) {
|
|
3737
|
-
_this6.addFeature(subFeature);
|
|
3430
|
+
for (let i = 0; i < selectedFeatures.length; i++) {
|
|
3431
|
+
const feature = selectedFeatures[i];
|
|
3738
3432
|
|
|
3433
|
+
if (this.isInstanceOf("MultiFeature", feature)) {
|
|
3434
|
+
feature.getFeatures().forEach(subFeature => {
|
|
3435
|
+
this.addFeature(subFeature);
|
|
3739
3436
|
subFeature.properties = feature.properties;
|
|
3740
3437
|
createdFeatures.push(subFeature.toGeoJSON());
|
|
3741
|
-
|
|
3742
|
-
_this6.select([subFeature.id]);
|
|
3438
|
+
this.select([subFeature.id]);
|
|
3743
3439
|
});
|
|
3744
|
-
|
|
3745
|
-
_this6.deleteFeature(feature.id, {
|
|
3440
|
+
this.deleteFeature(feature.id, {
|
|
3746
3441
|
silent: true
|
|
3747
3442
|
});
|
|
3748
|
-
|
|
3749
3443
|
featuresUncombined.push(feature.toGeoJSON());
|
|
3750
3444
|
}
|
|
3751
|
-
};
|
|
3752
|
-
|
|
3753
|
-
for (var i = 0; i < selectedFeatures.length; i++) {
|
|
3754
|
-
_loop(i);
|
|
3755
3445
|
}
|
|
3756
3446
|
|
|
3757
3447
|
if (createdFeatures.length > 1) {
|
|
3758
3448
|
this.map.fire(events.UNCOMBINE_FEATURES, {
|
|
3759
|
-
createdFeatures
|
|
3449
|
+
createdFeatures,
|
|
3760
3450
|
deletedFeatures: featuresUncombined
|
|
3761
3451
|
});
|
|
3762
3452
|
}
|
|
@@ -3764,13 +3454,13 @@ CustomSelectMode.onUncombineFeatures = function () {
|
|
|
3764
3454
|
this.fireActionable();
|
|
3765
3455
|
};
|
|
3766
3456
|
|
|
3767
|
-
|
|
3768
|
-
getMatchingVertices:
|
|
3457
|
+
const drawUtils = {
|
|
3458
|
+
getMatchingVertices: (vertex, featureId, allFeatures, map) => {
|
|
3769
3459
|
// number of decimals should probably be dynamic depending on zoom level
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3460
|
+
let decimals = 5;
|
|
3461
|
+
let matchingVertices = [];
|
|
3462
|
+
let v_lng = vertex[0].toFixed(decimals);
|
|
3463
|
+
let v_lat = vertex[1].toFixed(decimals);
|
|
3774
3464
|
|
|
3775
3465
|
for (var i = 0; i < allFeatures.length; i++) {
|
|
3776
3466
|
if (allFeatures[i].id !== featureId) {
|
|
@@ -3792,7 +3482,7 @@ var drawUtils = {
|
|
|
3792
3482
|
|
|
3793
3483
|
return matchingVertices;
|
|
3794
3484
|
},
|
|
3795
|
-
getDrawInstance:
|
|
3485
|
+
getDrawInstance: map => {
|
|
3796
3486
|
for (var i = map._controls.length - 1; i >= 0; i--) {
|
|
3797
3487
|
if (map._controls[i].options && map._controls[i].options.defaultMode === "custom_select") {
|
|
3798
3488
|
return map._controls[i];
|
|
@@ -3803,16 +3493,14 @@ var drawUtils = {
|
|
|
3803
3493
|
}
|
|
3804
3494
|
};
|
|
3805
3495
|
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3496
|
+
const isVertex$1 = isOfMetaType(meta.VERTEX);
|
|
3497
|
+
const isMidpoint = isOfMetaType(meta.MIDPOINT);
|
|
3498
|
+
const DirectSelect = {}; // INTERNAL FUCNTIONS
|
|
3809
3499
|
|
|
3810
3500
|
DirectSelect.fireUpdate = function () {
|
|
3811
3501
|
this.map.fire(events.UPDATE, {
|
|
3812
3502
|
action: updateActions.CHANGE_COORDINATES,
|
|
3813
|
-
features: this.getSelected().map(
|
|
3814
|
-
return f.toGeoJSON();
|
|
3815
|
-
})
|
|
3503
|
+
features: this.getSelected().map(f => f.toGeoJSON())
|
|
3816
3504
|
});
|
|
3817
3505
|
};
|
|
3818
3506
|
|
|
@@ -3839,8 +3527,8 @@ DirectSelect.stopDragging = function (state) {
|
|
|
3839
3527
|
|
|
3840
3528
|
DirectSelect.onVertex = function (state, e) {
|
|
3841
3529
|
this.startDragging(state, e);
|
|
3842
|
-
|
|
3843
|
-
|
|
3530
|
+
const about = e.featureTarget.properties;
|
|
3531
|
+
const selectedIndex = state.selectedCoordPaths.indexOf(about.coord_path);
|
|
3844
3532
|
|
|
3845
3533
|
if (!isShiftDown(e) && selectedIndex === -1) {
|
|
3846
3534
|
state.selectedCoordPaths = [about.coord_path];
|
|
@@ -3849,33 +3537,31 @@ DirectSelect.onVertex = function (state, e) {
|
|
|
3849
3537
|
} // currently this work with single selected vertices only
|
|
3850
3538
|
|
|
3851
3539
|
|
|
3852
|
-
|
|
3853
|
-
|
|
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);
|
|
3854
3542
|
state.groupMove_vertices = matchingVertices;
|
|
3855
3543
|
|
|
3856
|
-
for (
|
|
3544
|
+
for (let i = 0; i < state.groupMove_vertices.length; i++) {
|
|
3857
3545
|
state.groupMove_vertices[i].feature = this.getFeature(state.groupMove_vertices[i].featureId);
|
|
3858
3546
|
}
|
|
3859
3547
|
|
|
3860
|
-
|
|
3548
|
+
const selectedCoordinates = this.pathsToCoordinates(state.featureId, state.selectedCoordPaths);
|
|
3861
3549
|
this.setSelectedCoordinates(selectedCoordinates);
|
|
3862
3550
|
};
|
|
3863
3551
|
|
|
3864
3552
|
DirectSelect.onMidpoint = function (state, e) {
|
|
3865
3553
|
this.startDragging(state, e);
|
|
3866
|
-
|
|
3554
|
+
const about = e.featureTarget.properties;
|
|
3867
3555
|
state.feature.addCoordinate(about.coord_path, about.lng, about.lat);
|
|
3868
3556
|
this.fireUpdate();
|
|
3869
3557
|
state.selectedCoordPaths = [about.coord_path];
|
|
3870
3558
|
};
|
|
3871
3559
|
|
|
3872
3560
|
DirectSelect.pathsToCoordinates = function (featureId, paths) {
|
|
3873
|
-
return paths.map(
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
};
|
|
3878
|
-
});
|
|
3561
|
+
return paths.map(coord_path => ({
|
|
3562
|
+
feature_id: featureId,
|
|
3563
|
+
coord_path
|
|
3564
|
+
}));
|
|
3879
3565
|
};
|
|
3880
3566
|
|
|
3881
3567
|
DirectSelect.onFeature = function (state, e) {
|
|
@@ -3888,30 +3574,26 @@ DirectSelect.dragFeature = function (state, e, delta) {
|
|
|
3888
3574
|
};
|
|
3889
3575
|
|
|
3890
3576
|
DirectSelect.dragVertex = function (state, e, delta) {
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
type: geojsonTypes.
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
}
|
|
3902
|
-
};
|
|
3903
|
-
});
|
|
3904
|
-
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);
|
|
3905
3587
|
|
|
3906
|
-
for (
|
|
3907
|
-
|
|
3588
|
+
for (let i = 0; i < selectedCoords.length; i++) {
|
|
3589
|
+
const coord = selectedCoords[i];
|
|
3908
3590
|
state.feature.updateCoordinate(state.selectedCoordPaths[i], coord[0] + constrainedDelta.lng, coord[1] + constrainedDelta.lat);
|
|
3909
3591
|
|
|
3910
|
-
for (
|
|
3911
|
-
|
|
3592
|
+
for (let k = 0; k < state.groupMove_vertices.length; k++) {
|
|
3593
|
+
let coord_path_m = state.groupMove_vertices[k].coord_path.split(".");
|
|
3912
3594
|
|
|
3913
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") {
|
|
3914
|
-
|
|
3596
|
+
let coord_m = state.groupMove_vertices[k].feature.coordinates[coord_path_m[0]][coord_path_m[1]];
|
|
3915
3597
|
state.groupMove_vertices[k].feature.updateCoordinate(state.groupMove_vertices[k].coord_path, coord_m[0] + constrainedDelta.lng, coord_m[1] + constrainedDelta.lat);
|
|
3916
3598
|
}
|
|
3917
3599
|
}
|
|
@@ -3934,8 +3616,8 @@ DirectSelect.clickActiveFeature = function (state) {
|
|
|
3934
3616
|
|
|
3935
3617
|
|
|
3936
3618
|
DirectSelect.onSetup = function (opts) {
|
|
3937
|
-
|
|
3938
|
-
|
|
3619
|
+
const featureId = opts.featureId;
|
|
3620
|
+
const feature = this.getFeature(featureId);
|
|
3939
3621
|
|
|
3940
3622
|
if (!feature) {
|
|
3941
3623
|
throw new Error("You must provide a featureId to enter direct_select mode");
|
|
@@ -3945,9 +3627,9 @@ DirectSelect.onSetup = function (opts) {
|
|
|
3945
3627
|
throw new TypeError("direct_select mode doesn't handle point features");
|
|
3946
3628
|
}
|
|
3947
3629
|
|
|
3948
|
-
|
|
3949
|
-
featureId
|
|
3950
|
-
feature
|
|
3630
|
+
const state = {
|
|
3631
|
+
featureId,
|
|
3632
|
+
feature,
|
|
3951
3633
|
dragMoveLocation: opts.startPos || null,
|
|
3952
3634
|
dragMoving: false,
|
|
3953
3635
|
canDragMove: false,
|
|
@@ -3988,13 +3670,9 @@ DirectSelect.toDisplayFeatures = function (state, geojson, push) {
|
|
|
3988
3670
|
DirectSelect.onTrash = function (state) {
|
|
3989
3671
|
// Uses number-aware sorting to make sure '9' < '10'. Comparison is reversed because we want them
|
|
3990
3672
|
// in reverse order so that we can remove by index safely.
|
|
3991
|
-
state.selectedCoordPaths.sort(
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
});
|
|
3995
|
-
}).forEach(function (id) {
|
|
3996
|
-
return state.feature.removeCoordinate(id);
|
|
3997
|
-
});
|
|
3673
|
+
state.selectedCoordPaths.sort((a, b) => b.localeCompare(a, "en", {
|
|
3674
|
+
numeric: true
|
|
3675
|
+
})).forEach(id => state.feature.removeCoordinate(id));
|
|
3998
3676
|
this.fireUpdate();
|
|
3999
3677
|
state.selectedCoordPaths = [];
|
|
4000
3678
|
this.clearSelectedCoordinates();
|
|
@@ -4008,9 +3686,9 @@ DirectSelect.onTrash = function (state) {
|
|
|
4008
3686
|
|
|
4009
3687
|
DirectSelect.onMouseMove = function (state, e) {
|
|
4010
3688
|
// On mousemove that is not a drag, stop vertex movement.
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
3689
|
+
const isFeature = isActiveFeature(e);
|
|
3690
|
+
const onVertex = isVertex$1(e);
|
|
3691
|
+
const noCoords = state.selectedCoordPaths.length === 0;
|
|
4014
3692
|
if (isFeature && noCoords) this.updateUIClasses({
|
|
4015
3693
|
mouse: cursors.MOVE
|
|
4016
3694
|
});else if (onVertex && !noCoords) this.updateUIClasses({
|
|
@@ -4036,7 +3714,7 @@ DirectSelect.onDrag = function (state, e) {
|
|
|
4036
3714
|
if (state.canDragMove !== true) return;
|
|
4037
3715
|
state.dragMoving = true;
|
|
4038
3716
|
e.originalEvent.stopPropagation();
|
|
4039
|
-
|
|
3717
|
+
const delta = {
|
|
4040
3718
|
lng: e.lngLat.lng - state.dragMoveLocation.lng,
|
|
4041
3719
|
lat: e.lngLat.lat - state.dragMoveLocation.lat
|
|
4042
3720
|
};
|
|
@@ -4066,38 +3744,26 @@ DirectSelect.onTouchEnd = DirectSelect.onMouseUp = function (state) {
|
|
|
4066
3744
|
};
|
|
4067
3745
|
|
|
4068
3746
|
function MlFeatureEditor(props) {
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
var _useState3 = useState(false),
|
|
4081
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
4082
|
-
drawToolsReady = _useState4[0],
|
|
4083
|
-
setDrawToolsReady = _useState4[1];
|
|
4084
|
-
|
|
4085
|
-
var _useState5 = useState(false),
|
|
4086
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
4087
|
-
mouseUpTrigger = _useState6[0],
|
|
4088
|
-
setMouseUpTrigger = _useState6[1];
|
|
4089
|
-
|
|
4090
|
-
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 => {
|
|
4091
3757
|
console.log("MlFeatureEditor mode change to " + e.mode); //setDrawMode(e.mode);
|
|
4092
3758
|
};
|
|
4093
3759
|
|
|
4094
|
-
|
|
3760
|
+
const mouseUpHandler = () => {
|
|
4095
3761
|
setMouseUpTrigger(Math.random());
|
|
4096
3762
|
};
|
|
4097
3763
|
|
|
4098
|
-
useEffect(
|
|
4099
|
-
|
|
4100
|
-
return
|
|
3764
|
+
useEffect(() => {
|
|
3765
|
+
let _componentId = componentId.current;
|
|
3766
|
+
return () => {
|
|
4101
3767
|
if (mapRef.current) {
|
|
4102
3768
|
mapRef.current.cleanup(_componentId); //mapRef.current.removeControl(draw.current, "top-left");
|
|
4103
3769
|
|
|
@@ -4105,7 +3771,7 @@ function MlFeatureEditor(props) {
|
|
|
4105
3771
|
}
|
|
4106
3772
|
};
|
|
4107
3773
|
}, []);
|
|
4108
|
-
useEffect(
|
|
3774
|
+
useEffect(() => {
|
|
4109
3775
|
if (mapContext.mapExists(props.mapId) && mapContext.getMap(props.mapId).style && !drawToolsInitialized) {
|
|
4110
3776
|
mapRef.current = mapContext.getMap(props.mapId);
|
|
4111
3777
|
setDrawToolsInitialized(true);
|
|
@@ -4130,7 +3796,7 @@ function MlFeatureEditor(props) {
|
|
|
4130
3796
|
setDrawToolsReady(true);
|
|
4131
3797
|
}
|
|
4132
3798
|
}, [mapContext.map, mapContext, props, drawToolsInitialized]);
|
|
4133
|
-
useEffect(
|
|
3799
|
+
useEffect(() => {
|
|
4134
3800
|
if (draw.current && props.geojson && props.geojson.geometry && props.geojson.geometry.coordinates) {
|
|
4135
3801
|
draw.current.set({
|
|
4136
3802
|
type: "FeatureCollection",
|
|
@@ -4138,17 +3804,17 @@ function MlFeatureEditor(props) {
|
|
|
4138
3804
|
});
|
|
4139
3805
|
}
|
|
4140
3806
|
}, [props.geojson, drawToolsReady]);
|
|
4141
|
-
useEffect(
|
|
3807
|
+
useEffect(() => {
|
|
4142
3808
|
if (draw.current && mouseUpTrigger) {
|
|
4143
3809
|
// update drawnFeatures state object
|
|
4144
|
-
|
|
3810
|
+
let currentFeatureCollection = draw.current.getAll();
|
|
4145
3811
|
|
|
4146
3812
|
if (typeof onChangeRef.current === "function") {
|
|
4147
3813
|
onChangeRef.current(currentFeatureCollection.features);
|
|
4148
3814
|
}
|
|
4149
3815
|
}
|
|
4150
3816
|
}, [mouseUpTrigger]);
|
|
4151
|
-
useEffect(
|
|
3817
|
+
useEffect(() => {
|
|
4152
3818
|
if (props.mode && draw.current) {
|
|
4153
3819
|
draw.current.changeMode(props.mode);
|
|
4154
3820
|
}
|
|
@@ -4156,14 +3822,14 @@ function MlFeatureEditor(props) {
|
|
|
4156
3822
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
|
|
4157
3823
|
}
|
|
4158
3824
|
|
|
4159
|
-
|
|
3825
|
+
const MlBasicComponent = props => {
|
|
4160
3826
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
4161
3827
|
// without the requirement of adding it to the dependency list (ignore the false eslint exhaustive deps warning)
|
|
4162
3828
|
// const layerRef = useRef(null);
|
|
4163
|
-
|
|
4164
|
-
useEffect(
|
|
3829
|
+
const mapContext = useContext(MapContext);
|
|
3830
|
+
useEffect(() => {
|
|
4165
3831
|
if (!mapContext.mapExists()) return;
|
|
4166
|
-
return
|
|
3832
|
+
return () => {
|
|
4167
3833
|
// This is the cleanup function, it is called when this react component is removed from react-dom
|
|
4168
3834
|
// try to remove anything this component has added to the MapLibre-gl instance
|
|
4169
3835
|
// e.g.: remove the layer
|
|
@@ -4173,7 +3839,7 @@ var MlBasicComponent = function MlBasicComponent(props) {
|
|
|
4173
3839
|
}
|
|
4174
3840
|
};
|
|
4175
3841
|
});
|
|
4176
|
-
useEffect(
|
|
3842
|
+
useEffect(() => {
|
|
4177
3843
|
if (!mapContext.mapExists(props.mapId)) return; // the MapLibre-gl instance (mapContext.map) is accessible here
|
|
4178
3844
|
// initialize the layer and add it to the MapLibre-gl instance
|
|
4179
3845
|
|
|
@@ -4192,32 +3858,17 @@ var MlBasicComponent = function MlBasicComponent(props) {
|
|
|
4192
3858
|
* @component
|
|
4193
3859
|
*/
|
|
4194
3860
|
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
var _useState3 = useState(50),
|
|
4208
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
4209
|
-
swipeY = _useState4[0],
|
|
4210
|
-
setSwipeY = _useState4[1];
|
|
4211
|
-
|
|
4212
|
-
var swipeYRef = useRef(50);
|
|
4213
|
-
var magnifierRadiusRef = useRef(props.magnifierRadius);
|
|
4214
|
-
|
|
4215
|
-
var _useState5 = useState(magnifierRadiusRef.current),
|
|
4216
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
4217
|
-
magnifierRadius = _useState6[0],
|
|
4218
|
-
setMagnifierRadius = _useState6[1];
|
|
4219
|
-
|
|
4220
|
-
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(() => {
|
|
4221
3872
|
if (!props.map1Id || !props.map2Id) {
|
|
4222
3873
|
return false;
|
|
4223
3874
|
}
|
|
@@ -4228,17 +3879,17 @@ var MlLayerMagnify = function MlLayerMagnify(props) {
|
|
|
4228
3879
|
|
|
4229
3880
|
return true;
|
|
4230
3881
|
}, [props, mapContext]);
|
|
4231
|
-
|
|
3882
|
+
const onResize = useRef(() => {
|
|
4232
3883
|
if (!mapExists()) return;
|
|
4233
3884
|
onMove({
|
|
4234
3885
|
clientX: swipeXRef.current,
|
|
4235
3886
|
clientY: swipeYRef.current
|
|
4236
3887
|
});
|
|
4237
3888
|
});
|
|
4238
|
-
useEffect(
|
|
3889
|
+
useEffect(() => {
|
|
4239
3890
|
window.addEventListener("resize", onResize.current);
|
|
4240
|
-
|
|
4241
|
-
return
|
|
3891
|
+
let _onResize = onResize.current;
|
|
3892
|
+
return () => {
|
|
4242
3893
|
window.removeEventListener("resize", _onResize);
|
|
4243
3894
|
|
|
4244
3895
|
if (syncCleanupFunctionRef.current) {
|
|
@@ -4246,15 +3897,15 @@ var MlLayerMagnify = function MlLayerMagnify(props) {
|
|
|
4246
3897
|
}
|
|
4247
3898
|
};
|
|
4248
3899
|
}, []);
|
|
4249
|
-
|
|
3900
|
+
const onMove = useCallback(e => {
|
|
4250
3901
|
if (!mapExists()) return;
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
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);
|
|
4254
3905
|
clientX -= bounds.x;
|
|
4255
3906
|
clientY -= bounds.y;
|
|
4256
|
-
|
|
4257
|
-
|
|
3907
|
+
let swipeX_tmp = (clientX / bounds.width * 100).toFixed(2);
|
|
3908
|
+
let swipeY_tmp = (clientY / bounds.height * 100).toFixed(2);
|
|
4258
3909
|
|
|
4259
3910
|
if (swipeXRef.current !== swipeX_tmp || swipeYRef.current !== swipeY_tmp) {
|
|
4260
3911
|
setSwipeX(swipeX_tmp);
|
|
@@ -4264,7 +3915,7 @@ var MlLayerMagnify = function MlLayerMagnify(props) {
|
|
|
4264
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)";
|
|
4265
3916
|
}
|
|
4266
3917
|
}, [mapContext, mapExists, props]);
|
|
4267
|
-
useEffect(
|
|
3918
|
+
useEffect(() => {
|
|
4268
3919
|
if (!mapExists() || syncMoveInitializedRef.current) return;
|
|
4269
3920
|
syncMoveInitializedRef.current = true;
|
|
4270
3921
|
syncCleanupFunctionRef.current = syncMove(mapContext.getMap(props.map1Id).map, mapContext.getMap(props.map2Id).map);
|
|
@@ -4285,7 +3936,7 @@ var MlLayerMagnify = function MlLayerMagnify(props) {
|
|
|
4285
3936
|
});
|
|
4286
3937
|
}, [mapContext.mapIds, mapContext, mapExists, props, onMove]);
|
|
4287
3938
|
|
|
4288
|
-
|
|
3939
|
+
const onDown = e => {
|
|
4289
3940
|
if (e.touches) {
|
|
4290
3941
|
document.addEventListener("touchmove", onMove);
|
|
4291
3942
|
document.addEventListener("touchend", onTouchEnd);
|
|
@@ -4295,18 +3946,18 @@ var MlLayerMagnify = function MlLayerMagnify(props) {
|
|
|
4295
3946
|
}
|
|
4296
3947
|
};
|
|
4297
3948
|
|
|
4298
|
-
|
|
3949
|
+
const onTouchEnd = () => {
|
|
4299
3950
|
document.removeEventListener("touchmove", onMove);
|
|
4300
3951
|
document.removeEventListener("touchend", onTouchEnd);
|
|
4301
3952
|
};
|
|
4302
3953
|
|
|
4303
|
-
|
|
3954
|
+
const onMouseUp = () => {
|
|
4304
3955
|
document.removeEventListener("mousemove", onMove);
|
|
4305
3956
|
document.removeEventListener("mouseup", onMouseUp);
|
|
4306
3957
|
};
|
|
4307
3958
|
|
|
4308
|
-
|
|
4309
|
-
|
|
3959
|
+
const onWheel = e => {
|
|
3960
|
+
let evCopy = new WheelEvent(e.type, e);
|
|
4310
3961
|
mapContext.map.getCanvas().dispatchEvent(evCopy);
|
|
4311
3962
|
};
|
|
4312
3963
|
|
|
@@ -4363,18 +4014,13 @@ MlLayerMagnify.propTypes = {
|
|
|
4363
4014
|
* @component
|
|
4364
4015
|
*/
|
|
4365
4016
|
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
setSwipeX = _useState2[1];
|
|
4374
|
-
|
|
4375
|
-
var swipeXRef = useRef(50);
|
|
4376
|
-
var syncCleanupFunctionRef = useRef(null);
|
|
4377
|
-
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(() => {
|
|
4378
4024
|
if (!props.map1Id || !props.map2Id) {
|
|
4379
4025
|
return false;
|
|
4380
4026
|
}
|
|
@@ -4386,18 +4032,18 @@ var MlLayerSwipe = function MlLayerSwipe(props) {
|
|
|
4386
4032
|
return true;
|
|
4387
4033
|
}, [mapContext, props.map1Id, props.map2Id]);
|
|
4388
4034
|
|
|
4389
|
-
|
|
4035
|
+
const cleanup = () => {
|
|
4390
4036
|
if (syncCleanupFunctionRef.current) {
|
|
4391
4037
|
syncCleanupFunctionRef.current();
|
|
4392
4038
|
}
|
|
4393
4039
|
};
|
|
4394
4040
|
|
|
4395
|
-
|
|
4041
|
+
const onMove = useCallback(e => {
|
|
4396
4042
|
if (!mapExists()) return;
|
|
4397
|
-
|
|
4398
|
-
|
|
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);
|
|
4399
4045
|
clientX -= bounds.x;
|
|
4400
|
-
|
|
4046
|
+
let swipeX_tmp = (clientX / bounds.width * 100).toFixed(2);
|
|
4401
4047
|
|
|
4402
4048
|
if (swipeXRef.current !== swipeX_tmp) {
|
|
4403
4049
|
setSwipeX(swipeX_tmp);
|
|
@@ -4406,10 +4052,10 @@ var MlLayerSwipe = function MlLayerSwipe(props) {
|
|
|
4406
4052
|
mapContext.maps[props.map2Id].getContainer().style.clip = clipA;
|
|
4407
4053
|
}
|
|
4408
4054
|
}, [mapContext, mapExists, props.map1Id, props.map2Id]);
|
|
4409
|
-
useEffect(
|
|
4055
|
+
useEffect(() => {
|
|
4410
4056
|
return cleanup;
|
|
4411
4057
|
}, []);
|
|
4412
|
-
useEffect(
|
|
4058
|
+
useEffect(() => {
|
|
4413
4059
|
if (!mapExists() || initializedRef.current) return;
|
|
4414
4060
|
initializedRef.current = true;
|
|
4415
4061
|
syncCleanupFunctionRef.current = syncMove(mapContext.getMap(props.map1Id).map, mapContext.getMap(props.map2Id).map);
|
|
@@ -4418,7 +4064,7 @@ var MlLayerSwipe = function MlLayerSwipe(props) {
|
|
|
4418
4064
|
});
|
|
4419
4065
|
}, [mapContext.mapIds, mapContext, props, onMove, mapExists]);
|
|
4420
4066
|
|
|
4421
|
-
|
|
4067
|
+
const onDown = e => {
|
|
4422
4068
|
if (e.touches) {
|
|
4423
4069
|
document.addEventListener("touchmove", onMove);
|
|
4424
4070
|
document.addEventListener("touchend", onTouchEnd);
|
|
@@ -4428,12 +4074,12 @@ var MlLayerSwipe = function MlLayerSwipe(props) {
|
|
|
4428
4074
|
}
|
|
4429
4075
|
};
|
|
4430
4076
|
|
|
4431
|
-
|
|
4077
|
+
const onTouchEnd = () => {
|
|
4432
4078
|
document.removeEventListener("touchmove", onMove);
|
|
4433
4079
|
document.removeEventListener("touchend", onTouchEnd);
|
|
4434
4080
|
};
|
|
4435
4081
|
|
|
4436
|
-
|
|
4082
|
+
const onMouseUp = () => {
|
|
4437
4083
|
document.removeEventListener("mousemove", onMove);
|
|
4438
4084
|
document.removeEventListener("mouseup", onMouseUp);
|
|
4439
4085
|
};
|
|
@@ -4475,8 +4121,8 @@ MlLayerSwipe.propTypes = {
|
|
|
4475
4121
|
map2Id: PropTypes.string
|
|
4476
4122
|
};
|
|
4477
4123
|
|
|
4478
|
-
|
|
4479
|
-
|
|
4124
|
+
const GeoJsonContext = /*#__PURE__*/React__default.createContext({});
|
|
4125
|
+
const GeoJsonContextProvider = GeoJsonContext.Provider;
|
|
4480
4126
|
|
|
4481
4127
|
/**
|
|
4482
4128
|
* https://github.com/mapbox/togeojson
|
|
@@ -4568,9 +4214,7 @@ var toGeoJSON = function () {
|
|
|
4568
4214
|
|
|
4569
4215
|
|
|
4570
4216
|
function extend(x, y) {
|
|
4571
|
-
for (var k in y)
|
|
4572
|
-
x[k] = y[k];
|
|
4573
|
-
}
|
|
4217
|
+
for (var k in y) x[k] = y[k];
|
|
4574
4218
|
} // get one coordinate from a coordinate array, if any
|
|
4575
4219
|
|
|
4576
4220
|
|
|
@@ -4627,10 +4271,10 @@ var toGeoJSON = function () {
|
|
|
4627
4271
|
/* istanbul ignore next */
|
|
4628
4272
|
serializer = new XMLSerializer();
|
|
4629
4273
|
} else {
|
|
4630
|
-
var isNodeEnv =
|
|
4631
|
-
var isTitaniumEnv =
|
|
4274
|
+
var isNodeEnv = typeof process === "object" && !process.browser;
|
|
4275
|
+
var isTitaniumEnv = typeof Titanium === "object";
|
|
4632
4276
|
|
|
4633
|
-
if (
|
|
4277
|
+
if (typeof exports === "object" && (isNodeEnv || isTitaniumEnv)) {
|
|
4634
4278
|
serializer = new (require("xmldom").XMLSerializer)();
|
|
4635
4279
|
} else {
|
|
4636
4280
|
throw new Error("Unable to initialize serializer");
|
|
@@ -4647,7 +4291,7 @@ var toGeoJSON = function () {
|
|
|
4647
4291
|
}
|
|
4648
4292
|
|
|
4649
4293
|
var t = {
|
|
4650
|
-
kml: function
|
|
4294
|
+
kml: function (doc) {
|
|
4651
4295
|
var gj = fc(),
|
|
4652
4296
|
// styleindex keeps track of hashed styles in order to match features
|
|
4653
4297
|
styleIndex = {},
|
|
@@ -4714,15 +4358,11 @@ var toGeoJSON = function () {
|
|
|
4714
4358
|
times = [];
|
|
4715
4359
|
if (elems.length === 0) elems = get(root, "gx:coord");
|
|
4716
4360
|
|
|
4717
|
-
for (var i = 0; i < elems.length; i++)
|
|
4718
|
-
coords.push(gxCoord(nodeVal(elems[i])));
|
|
4719
|
-
}
|
|
4361
|
+
for (var i = 0; i < elems.length; i++) coords.push(gxCoord(nodeVal(elems[i])));
|
|
4720
4362
|
|
|
4721
4363
|
var timeElems = get(root, "when");
|
|
4722
4364
|
|
|
4723
|
-
for (var j = 0; j < timeElems.length; j++)
|
|
4724
|
-
times.push(nodeVal(timeElems[j]));
|
|
4725
|
-
}
|
|
4365
|
+
for (var j = 0; j < timeElems.length; j++) times.push(nodeVal(timeElems[j]));
|
|
4726
4366
|
|
|
4727
4367
|
return {
|
|
4728
4368
|
coords: coords,
|
|
@@ -4923,7 +4563,7 @@ var toGeoJSON = function () {
|
|
|
4923
4563
|
|
|
4924
4564
|
return gj;
|
|
4925
4565
|
},
|
|
4926
|
-
gpx: function
|
|
4566
|
+
gpx: function (doc) {
|
|
4927
4567
|
var i,
|
|
4928
4568
|
tracks = get(doc, "trk"),
|
|
4929
4569
|
routes = get(doc, "rte"),
|
|
@@ -5102,41 +4742,27 @@ var toGeoJSON = function () {
|
|
|
5102
4742
|
* @component
|
|
5103
4743
|
*/
|
|
5104
4744
|
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
4745
|
+
const MlGPXViewer = props => {
|
|
4746
|
+
const dataSource = useContext(GeoJsonContext);
|
|
4747
|
+
const initializedRef = useRef(false);
|
|
4748
|
+
const mapHook = useMap({
|
|
5109
4749
|
mapId: props.mapId,
|
|
5110
4750
|
waitForLayer: props.insertBeforeLayer
|
|
5111
4751
|
});
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
var _useState3 = useState(0),
|
|
5124
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
5125
|
-
zIndex = _useState4[0],
|
|
5126
|
-
setZIndex = _useState4[1];
|
|
5127
|
-
|
|
5128
|
-
var _useState5 = useState([]),
|
|
5129
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
5130
|
-
metaData = _useState6[0],
|
|
5131
|
-
setMetaData = _useState6[1];
|
|
5132
|
-
|
|
5133
|
-
var fileupload = useRef(null);
|
|
5134
|
-
var mediaIsMobile = useMediaQuery("(max-width:900px)");
|
|
5135
|
-
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({
|
|
5136
4762
|
closeButton: false,
|
|
5137
4763
|
closeOnClick: true
|
|
5138
4764
|
}));
|
|
5139
|
-
useEffect(
|
|
4765
|
+
useEffect(() => {
|
|
5140
4766
|
if (!mapHook.map || initializedRef.current) return;
|
|
5141
4767
|
initializedRef.current = true;
|
|
5142
4768
|
mapHook.map.addSource(sourceName, {
|
|
@@ -5162,14 +4788,14 @@ var MlGPXViewer = function MlGPXViewer(props) {
|
|
|
5162
4788
|
},
|
|
5163
4789
|
filter: ["==", "$type", "Point"]
|
|
5164
4790
|
}, props.insertBeforeLayer, mapHook.componentId);
|
|
5165
|
-
[layerNameLines, layerNamePoints].forEach(
|
|
4791
|
+
[layerNameLines, layerNamePoints].forEach(layerName => {
|
|
5166
4792
|
mapHook.map.setLayoutProperty(layerName, "visibility", "visible");
|
|
5167
4793
|
});
|
|
5168
|
-
mapHook.map.on("mouseenter", layerNamePoints,
|
|
4794
|
+
mapHook.map.on("mouseenter", layerNamePoints, e => {
|
|
5169
4795
|
// Change the cursor style as a UI indicator.
|
|
5170
|
-
|
|
4796
|
+
const coordinates = e.features[0].geometry.coordinates.slice(); //const description = e.features[0].properties.desc;
|
|
5171
4797
|
|
|
5172
|
-
|
|
4798
|
+
const name = e.features[0].properties.name; // Ensure that if the map is zoomed out such that multiple
|
|
5173
4799
|
// copies of the feature are visible, the popup appears
|
|
5174
4800
|
// over the copy being pointed to.
|
|
5175
4801
|
|
|
@@ -5187,19 +4813,19 @@ var MlGPXViewer = function MlGPXViewer(props) {
|
|
|
5187
4813
|
}, mapHook.componentId);
|
|
5188
4814
|
mapHook.map.setZoom(10);
|
|
5189
4815
|
}, [mapHook.map]);
|
|
5190
|
-
useEffect(
|
|
5191
|
-
|
|
4816
|
+
useEffect(() => {
|
|
4817
|
+
const dropZoneCurrent = dropZone.current;
|
|
5192
4818
|
|
|
5193
|
-
|
|
4819
|
+
const raiseDropZoneAndStopDefault = event => {
|
|
5194
4820
|
setZIndex(1000);
|
|
5195
4821
|
stopDefault(event);
|
|
5196
4822
|
};
|
|
5197
4823
|
|
|
5198
|
-
|
|
4824
|
+
const lowerDropZone = () => {
|
|
5199
4825
|
setZIndex(0);
|
|
5200
4826
|
};
|
|
5201
4827
|
|
|
5202
|
-
|
|
4828
|
+
const lowerDropZoneAndStopDefault = event => {
|
|
5203
4829
|
setZIndex(0);
|
|
5204
4830
|
stopDefault(event);
|
|
5205
4831
|
};
|
|
@@ -5208,7 +4834,7 @@ var MlGPXViewer = function MlGPXViewer(props) {
|
|
|
5208
4834
|
window.addEventListener("dragover", stopDefault);
|
|
5209
4835
|
dropZoneCurrent.addEventListener("dragleave", lowerDropZone);
|
|
5210
4836
|
window.addEventListener("drop", lowerDropZoneAndStopDefault);
|
|
5211
|
-
return
|
|
4837
|
+
return () => {
|
|
5212
4838
|
window.removeEventListener("dragenter", raiseDropZoneAndStopDefault);
|
|
5213
4839
|
window.removeEventListener("dragover", stopDefault);
|
|
5214
4840
|
dropZoneCurrent.removeEventListener("dragleave", lowerDropZone);
|
|
@@ -5216,20 +4842,20 @@ var MlGPXViewer = function MlGPXViewer(props) {
|
|
|
5216
4842
|
};
|
|
5217
4843
|
});
|
|
5218
4844
|
|
|
5219
|
-
|
|
4845
|
+
const stopDefault = event => {
|
|
5220
4846
|
event.preventDefault();
|
|
5221
4847
|
event.stopPropagation();
|
|
5222
4848
|
};
|
|
5223
4849
|
|
|
5224
|
-
useEffect(
|
|
4850
|
+
useEffect(() => {
|
|
5225
4851
|
if (!mapHook.map) return;
|
|
5226
|
-
|
|
5227
|
-
[layerNameLines, layerNamePoints].forEach(
|
|
4852
|
+
const visibility = props.visible ? "visible" : "none";
|
|
4853
|
+
[layerNameLines, layerNamePoints].forEach(layerName => {
|
|
5228
4854
|
mapHook.map.setLayoutProperty(layerName, "visibility", visibility);
|
|
5229
4855
|
});
|
|
5230
4856
|
}, [props.visible]);
|
|
5231
4857
|
|
|
5232
|
-
|
|
4858
|
+
const dropHandler = event => {
|
|
5233
4859
|
event.preventDefault();
|
|
5234
4860
|
|
|
5235
4861
|
if (event.dataTransfer.items) {
|
|
@@ -5239,74 +4865,70 @@ var MlGPXViewer = function MlGPXViewer(props) {
|
|
|
5239
4865
|
|
|
5240
4866
|
|
|
5241
4867
|
if (event.dataTransfer.items[0].kind === "file") {
|
|
5242
|
-
|
|
4868
|
+
const reader = new FileReader();
|
|
5243
4869
|
|
|
5244
|
-
reader.onload =
|
|
4870
|
+
reader.onload = payload => {
|
|
5245
4871
|
addGPXToMap(payload.currentTarget.result);
|
|
5246
4872
|
};
|
|
5247
4873
|
|
|
5248
|
-
|
|
4874
|
+
const file = event.dataTransfer.items[0].getAsFile();
|
|
5249
4875
|
reader.readAsText(file);
|
|
5250
4876
|
}
|
|
5251
4877
|
}
|
|
5252
4878
|
};
|
|
5253
4879
|
|
|
5254
|
-
|
|
4880
|
+
const addGPXToMap = gpxAsString => {
|
|
5255
4881
|
if (!mapHook.map) return;
|
|
5256
4882
|
|
|
5257
4883
|
try {
|
|
5258
4884
|
setMetaData([]);
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
metadata.childNodes.forEach(
|
|
5263
|
-
|
|
5264
|
-
|
|
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;
|
|
5265
4891
|
|
|
5266
4892
|
if (node.nodeName === "link") {
|
|
5267
4893
|
value = node.getAttribute("href");
|
|
5268
4894
|
}
|
|
5269
4895
|
|
|
5270
4896
|
if (!!value.trim().length) {
|
|
5271
|
-
|
|
4897
|
+
const metaDatEntry = {
|
|
5272
4898
|
title: title,
|
|
5273
4899
|
value: value,
|
|
5274
4900
|
id: new Date().getTime()
|
|
5275
4901
|
};
|
|
5276
|
-
setMetaData(
|
|
5277
|
-
return [].concat(_toConsumableArray(prevState), [metaDatEntry]);
|
|
5278
|
-
});
|
|
4902
|
+
setMetaData(prevState => [...prevState, metaDatEntry]);
|
|
5279
4903
|
}
|
|
5280
4904
|
});
|
|
5281
|
-
|
|
4905
|
+
const data = toGeoJSON.gpx(gpxDoc);
|
|
5282
4906
|
dataSource.setData(data);
|
|
5283
4907
|
mapHook.map.getSource(sourceName).setData(data);
|
|
5284
|
-
|
|
4908
|
+
const bounds = bbox(data);
|
|
5285
4909
|
mapHook.map.fitBounds(bounds);
|
|
5286
4910
|
} catch (e) {
|
|
5287
4911
|
console.log(e);
|
|
5288
4912
|
}
|
|
5289
4913
|
};
|
|
5290
4914
|
|
|
5291
|
-
|
|
5292
|
-
setIsOpen(
|
|
5293
|
-
return !prevState;
|
|
5294
|
-
});
|
|
4915
|
+
const toogleDrawer = () => {
|
|
4916
|
+
setIsOpen(prevState => !prevState);
|
|
5295
4917
|
};
|
|
5296
4918
|
|
|
5297
|
-
|
|
5298
|
-
|
|
4919
|
+
const fileUploadOnChange = () => {
|
|
4920
|
+
const file = fileupload.current.files[0];
|
|
5299
4921
|
if (!file) return false;
|
|
5300
|
-
|
|
4922
|
+
const reader = new FileReader();
|
|
5301
4923
|
|
|
5302
|
-
reader.onload =
|
|
4924
|
+
reader.onload = payload => {
|
|
5303
4925
|
addGPXToMap(payload.currentTarget.result);
|
|
5304
4926
|
};
|
|
5305
4927
|
|
|
5306
4928
|
reader.readAsText(file);
|
|
5307
4929
|
};
|
|
5308
4930
|
|
|
5309
|
-
|
|
4931
|
+
const manualUpload = () => {
|
|
5310
4932
|
fileupload.current.click();
|
|
5311
4933
|
};
|
|
5312
4934
|
|
|
@@ -5352,13 +4974,11 @@ var MlGPXViewer = function MlGPXViewer(props) {
|
|
|
5352
4974
|
padding: "1em"
|
|
5353
4975
|
},
|
|
5354
4976
|
noWrap: true
|
|
5355
|
-
}, "Informationen zur Route"), /*#__PURE__*/React__default.createElement(Divider, null), /*#__PURE__*/React__default.createElement(List, null, metaData.map(
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
}));
|
|
5361
|
-
}))), /*#__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", {
|
|
5362
4982
|
onDrop: dropHandler,
|
|
5363
4983
|
ref: dropZone,
|
|
5364
4984
|
style: {
|
|
@@ -5409,28 +5029,26 @@ MlGPXViewer.propTypes = {
|
|
|
5409
5029
|
insertBeforeLayer: PropTypes.string
|
|
5410
5030
|
};
|
|
5411
5031
|
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5032
|
+
const GeoJsonProvider = _ref => {
|
|
5033
|
+
let {
|
|
5034
|
+
children
|
|
5035
|
+
} = _ref;
|
|
5036
|
+
const [data, setData] = useState({
|
|
5416
5037
|
type: "FeatureCollection",
|
|
5417
5038
|
features: []
|
|
5418
|
-
})
|
|
5419
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
5420
|
-
data = _useState2[0],
|
|
5421
|
-
setData = _useState2[1];
|
|
5039
|
+
});
|
|
5422
5040
|
|
|
5423
|
-
|
|
5041
|
+
const getEmptyFeatureCollection = () => {
|
|
5424
5042
|
return {
|
|
5425
5043
|
type: "FeatureCollection",
|
|
5426
5044
|
features: []
|
|
5427
5045
|
};
|
|
5428
5046
|
};
|
|
5429
5047
|
|
|
5430
|
-
|
|
5431
|
-
data
|
|
5432
|
-
setData
|
|
5433
|
-
getEmptyFeatureCollection
|
|
5048
|
+
const value = {
|
|
5049
|
+
data,
|
|
5050
|
+
setData,
|
|
5051
|
+
getEmptyFeatureCollection
|
|
5434
5052
|
};
|
|
5435
5053
|
return /*#__PURE__*/React__default.createElement(GeoJsonContextProvider, {
|
|
5436
5054
|
value: value
|
|
@@ -5447,31 +5065,31 @@ GeoJsonProvider.propTypes = {
|
|
|
5447
5065
|
* @component
|
|
5448
5066
|
*/
|
|
5449
5067
|
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
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) => {
|
|
5459
5077
|
//const summand = 0.0002;
|
|
5460
|
-
|
|
5461
|
-
|
|
5078
|
+
const line = lineString([[x, y], [x2, y2]]);
|
|
5079
|
+
const offsetLine = lineOffset(line, 5, {
|
|
5462
5080
|
units: "meters"
|
|
5463
5081
|
});
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
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];
|
|
5468
5086
|
return polygon([[[x, y], [x2, y2], [x4, y4], [x3, y3], [x, y]]], {
|
|
5469
5087
|
height: z * props.elevationFactor
|
|
5470
5088
|
});
|
|
5471
5089
|
}, [props.elevationFactor]);
|
|
5472
|
-
useEffect(
|
|
5473
|
-
|
|
5474
|
-
return
|
|
5090
|
+
useEffect(() => {
|
|
5091
|
+
let _componentId = componentId.current;
|
|
5092
|
+
return () => {
|
|
5475
5093
|
// This is the cleanup function, it is called when this react component is removed from react-dom
|
|
5476
5094
|
if (mapRef.current) {
|
|
5477
5095
|
mapRef.current.cleanup(_componentId);
|
|
@@ -5479,7 +5097,7 @@ var MlSpatialElevationProfile = function MlSpatialElevationProfile(props) {
|
|
|
5479
5097
|
}
|
|
5480
5098
|
};
|
|
5481
5099
|
}, []);
|
|
5482
|
-
useEffect(
|
|
5100
|
+
useEffect(() => {
|
|
5483
5101
|
if (!mapContext.mapExists(props.mapId) || initializedRef.current) return;
|
|
5484
5102
|
initializedRef.current = true;
|
|
5485
5103
|
mapRef.current = mapContext.getMap(props.mapId);
|
|
@@ -5498,51 +5116,51 @@ var MlSpatialElevationProfile = function MlSpatialElevationProfile(props) {
|
|
|
5498
5116
|
}
|
|
5499
5117
|
}, props.insertBeforeLayer, componentId.current);
|
|
5500
5118
|
}, [mapContext.mapIds, props.insertBeforeLayer, props.mapId, dataSource, mapContext]);
|
|
5501
|
-
useEffect(
|
|
5119
|
+
useEffect(() => {
|
|
5502
5120
|
var _mapRef$current$getSo;
|
|
5503
5121
|
|
|
5504
5122
|
if (!mapRef.current || !mapRef.current.getLayer(layerName.current)) return;
|
|
5505
|
-
|
|
5123
|
+
const {
|
|
5124
|
+
data
|
|
5125
|
+
} = dataSource;
|
|
5506
5126
|
if (!data || !data.features) return;
|
|
5507
|
-
|
|
5127
|
+
const line = data.features.find(element => {
|
|
5508
5128
|
return element.geometry.type === "LineString";
|
|
5509
5129
|
});
|
|
5510
5130
|
if (!line || !line.geometry) return;
|
|
5511
|
-
|
|
5131
|
+
const heights = line.geometry.coordinates.map((coordinate, index) => {
|
|
5512
5132
|
return coordinate[2];
|
|
5513
5133
|
});
|
|
5514
|
-
|
|
5515
|
-
|
|
5134
|
+
const min = Math.min(...heights);
|
|
5135
|
+
let max = Math.max(...heights) - min;
|
|
5516
5136
|
max = max === 0 ? 1 : max;
|
|
5517
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)"]);
|
|
5518
5138
|
|
|
5519
|
-
|
|
5520
|
-
return x * (1 - a) + y * a;
|
|
5521
|
-
};
|
|
5139
|
+
const lerp = (x, y, a) => x * (1 - a) + y * a;
|
|
5522
5140
|
|
|
5523
|
-
|
|
5524
|
-
line.geometry.coordinates.forEach(
|
|
5141
|
+
const points = [];
|
|
5142
|
+
line.geometry.coordinates.forEach((coordinate, index) => {
|
|
5525
5143
|
//const point = createPoint(coordinate[0],coordinate[1],coordinate[2]-min);
|
|
5526
5144
|
//points.push(point);
|
|
5527
5145
|
if (line.geometry.coordinates[index + 1]) {
|
|
5528
|
-
|
|
5146
|
+
const wayLength = distance([coordinate[0], coordinate[1]], [line.geometry.coordinates[index + 1][0], line.geometry.coordinates[index + 1][1]], {
|
|
5529
5147
|
units: "kilometers"
|
|
5530
5148
|
});
|
|
5531
|
-
|
|
5149
|
+
let listLength = ~~(wayLength * 1000 / 10);
|
|
5532
5150
|
listLength = listLength < 1 ? 1 : listLength;
|
|
5533
5151
|
|
|
5534
|
-
for (
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
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);
|
|
5541
5159
|
points.push(point);
|
|
5542
5160
|
}
|
|
5543
5161
|
}
|
|
5544
5162
|
});
|
|
5545
|
-
|
|
5163
|
+
const newData = dataSource.getEmptyFeatureCollection();
|
|
5546
5164
|
newData.features = points;
|
|
5547
5165
|
(_mapRef$current$getSo = mapRef.current.getSource(sourceName.current)) === null || _mapRef$current$getSo === void 0 ? void 0 : _mapRef$current$getSo.setData(newData);
|
|
5548
5166
|
}, [dataSource.data, createStep, dataSource, props.elevationFactor, mapContext]);
|
|
@@ -5575,13 +5193,29 @@ MlSpatialElevationProfile.propTypes = {
|
|
|
5575
5193
|
insertBeforeLayer: PropTypes.string
|
|
5576
5194
|
};
|
|
5577
5195
|
|
|
5578
|
-
|
|
5579
|
-
|
|
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];
|
|
5580
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) {
|
|
5581
5215
|
if (typeof transitionGeojsonDataRef.current[currentTransitionStepRef.current] !== "undefined") {
|
|
5582
5216
|
// if at last transition step set to target geojson
|
|
5583
5217
|
// else to an assembled LineString from common geometry and the current transition step geometry
|
|
5584
|
-
|
|
5218
|
+
let newData = currentTransitionStepRef.current + 1 === transitionGeojsonDataRef.current.length ? props.geojson : lineString$1([...transitionGeojsonCommonDataRef.current, ...transitionGeojsonDataRef.current[currentTransitionStepRef.current].geometry.coordinates]);
|
|
5585
5219
|
setDisplayGeojson(newData);
|
|
5586
5220
|
|
|
5587
5221
|
if (typeof props.onTransitionFrame === "function") {
|
|
@@ -5591,9 +5225,7 @@ var _showNextTransitionSegment = function _showNextTransitionSegment(props, map,
|
|
|
5591
5225
|
currentTransitionStepRef.current++;
|
|
5592
5226
|
|
|
5593
5227
|
if (transitionInProgressRef.current && currentTransitionStepRef.current < transitionGeojsonDataRef.current.length) {
|
|
5594
|
-
transitionTimeoutRef.current = setTimeout(
|
|
5595
|
-
return _showNextTransitionSegment.apply(void 0, _toConsumableArray(_arguments));
|
|
5596
|
-
}, msPerStep);
|
|
5228
|
+
transitionTimeoutRef.current = setTimeout(() => _showNextTransitionSegment(...arguments), msPerStep);
|
|
5597
5229
|
} else {
|
|
5598
5230
|
if (typeof props.onTransitionEnd === "function") {
|
|
5599
5231
|
props.onTransitionEnd(props.geojson);
|
|
@@ -5604,15 +5236,15 @@ var _showNextTransitionSegment = function _showNextTransitionSegment(props, map,
|
|
|
5604
5236
|
}
|
|
5605
5237
|
};
|
|
5606
5238
|
|
|
5607
|
-
|
|
5239
|
+
const _transitionToGeojson = (props, transitionGeojsonCommonDataRef, transitionGeojsonDataRef, transitionInProgressRef, oldGeojsonRef, msPerStep, currentTransitionStepRef, map, transitionTimeoutRef, setDisplayGeojson) => {
|
|
5608
5240
|
// create the transition geojson between oldGeojsonRef.current and props.geojson
|
|
5609
5241
|
// create a geojson that contains no common point between the two line features
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
5242
|
+
let transitionCoordinatesShort = [];
|
|
5243
|
+
let transitionCoordinatesLong = [];
|
|
5244
|
+
let targetCoordinates = [];
|
|
5245
|
+
let srcCoordinates = [];
|
|
5614
5246
|
transitionGeojsonCommonDataRef.current = [];
|
|
5615
|
-
|
|
5247
|
+
let sourceGeojson = oldGeojsonRef.current || {
|
|
5616
5248
|
geometry: {
|
|
5617
5249
|
type: "LineString",
|
|
5618
5250
|
coordinates: []
|
|
@@ -5620,10 +5252,10 @@ var _transitionToGeojson = function _transitionToGeojson(props, transitionGeojso
|
|
|
5620
5252
|
properties: {},
|
|
5621
5253
|
type: "Feature"
|
|
5622
5254
|
};
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
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
|
|
5627
5259
|
|
|
5628
5260
|
if (typeof longerGeojson.geometry === "undefined" && typeof shorterGeojson.geometry !== "undefined" && shorterGeojson.geometry.coordinates.length > 1) {
|
|
5629
5261
|
longerGeojson = lineString$1(shorterGeojson.geometry.coordinates.slice(0, 2));
|
|
@@ -5666,44 +5298,42 @@ var _transitionToGeojson = function _transitionToGeojson(props, transitionGeojso
|
|
|
5666
5298
|
|
|
5667
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
|
|
5668
5300
|
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
|
|
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
|
|
5679
5311
|
|
|
5680
5312
|
|
|
5681
|
-
|
|
5682
|
-
transitionStepData =
|
|
5313
|
+
let transitionStepData;
|
|
5314
|
+
transitionStepData = [...createTransitionSteps(srcCoordinates, srcPerStepDistance, srcTransitionSteps)];
|
|
5683
5315
|
transitionStepData.reverse();
|
|
5684
|
-
transitionStepData = [
|
|
5316
|
+
transitionStepData = [...transitionStepData, ...createTransitionSteps(targetCoordinates, targetPerStepDistance, targetTransitionSteps)];
|
|
5685
5317
|
transitionStepData.push(targetGeojson);
|
|
5686
5318
|
transitionGeojsonDataRef.current = transitionStepData;
|
|
5687
5319
|
currentTransitionStepRef.current = 1;
|
|
5688
5320
|
transitionInProgressRef.current = true;
|
|
5689
|
-
transitionTimeoutRef.current = setTimeout(
|
|
5690
|
-
return _showNextTransitionSegment(props, map, transitionInProgressRef, transitionGeojsonDataRef, transitionGeojsonCommonDataRef, currentTransitionStepRef, msPerStep, transitionTimeoutRef, setDisplayGeojson);
|
|
5691
|
-
}, msPerStep);
|
|
5321
|
+
transitionTimeoutRef.current = setTimeout(() => _showNextTransitionSegment(props, map, transitionInProgressRef, transitionGeojsonDataRef, transitionGeojsonCommonDataRef, currentTransitionStepRef, msPerStep, transitionTimeoutRef, setDisplayGeojson), msPerStep);
|
|
5692
5322
|
};
|
|
5693
5323
|
|
|
5694
|
-
|
|
5695
|
-
|
|
5324
|
+
let createTransitionSteps = (linestringCoordinates, perStepDistance, stepCnt) => {
|
|
5325
|
+
let transitionSteps = [];
|
|
5696
5326
|
|
|
5697
5327
|
if (linestringCoordinates.length > 1) {
|
|
5698
|
-
|
|
5328
|
+
let tmpChunks = lineChunk(lineString$1(linestringCoordinates), perStepDistance); // tmpLineString contains all coordinates of all previous plus current loop iteration
|
|
5699
5329
|
|
|
5700
|
-
|
|
5330
|
+
let tmpLinestring = tmpChunks.features[0];
|
|
5701
5331
|
|
|
5702
|
-
for (
|
|
5332
|
+
for (let i = 0; i < stepCnt; i++) {
|
|
5703
5333
|
transitionSteps.push(tmpLinestring);
|
|
5704
5334
|
|
|
5705
5335
|
if (typeof tmpChunks.features[i] !== "undefined") {
|
|
5706
|
-
tmpLinestring = lineString$1([
|
|
5336
|
+
tmpLinestring = lineString$1([...tmpLinestring.geometry.coordinates, ...tmpChunks.features[i].geometry.coordinates]);
|
|
5707
5337
|
} else {
|
|
5708
5338
|
break;
|
|
5709
5339
|
}
|
|
@@ -5713,49 +5343,44 @@ var createTransitionSteps = function createTransitionSteps(linestringCoordinates
|
|
|
5713
5343
|
return transitionSteps;
|
|
5714
5344
|
};
|
|
5715
5345
|
|
|
5716
|
-
|
|
5717
|
-
var msPerStep = 50;
|
|
5346
|
+
const msPerStep = 50;
|
|
5718
5347
|
/**
|
|
5719
5348
|
* Adds source and layer of types "line", "fill" or "circle" to display GeoJSON data on the map.
|
|
5720
5349
|
*
|
|
5721
5350
|
* @component
|
|
5722
5351
|
*/
|
|
5723
5352
|
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
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
|
|
5727
5358
|
|
|
5728
|
-
|
|
5729
|
-
var mapHook = useMap({
|
|
5359
|
+
const mapHook = useMap({
|
|
5730
5360
|
mapId: props.mapId,
|
|
5731
5361
|
waitForLayer: props.insertBeforeLayer
|
|
5732
5362
|
});
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
displayGeojson = _useState2[0],
|
|
5745
|
-
setDisplayGeojson = _useState2[1];
|
|
5746
|
-
|
|
5747
|
-
useEffect(function () {
|
|
5748
|
-
return function () {
|
|
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 () => {
|
|
5749
5374
|
// This is the cleanup function, it is called when this react component is removed from react-dom
|
|
5750
5375
|
if (transitionTimeoutRef.current) {
|
|
5751
5376
|
clearTimeout(transitionTimeoutRef.current);
|
|
5752
5377
|
}
|
|
5753
5378
|
};
|
|
5754
5379
|
}, []);
|
|
5755
|
-
|
|
5380
|
+
const transitionToGeojson = useCallback(() => {
|
|
5756
5381
|
_transitionToGeojson(props, transitionGeojsonCommonDataRef, transitionGeojsonDataRef, transitionInProgressRef, oldGeojsonRef, msPerStep, currentTransitionStepRef, mapHook.map, transitionTimeoutRef, setDisplayGeojson);
|
|
5757
5382
|
}, [props, mapHook.map]);
|
|
5758
|
-
useEffect(
|
|
5383
|
+
useEffect(() => {
|
|
5759
5384
|
if (!mapHook.map || !initializedRef.current) return;
|
|
5760
5385
|
|
|
5761
5386
|
if (typeof props.transitionTime !== "undefined" && props.type === "line" && oldGeojsonRef.current) {
|
|
@@ -5768,18 +5393,18 @@ var MlTransitionGeoJsonLayer = function MlTransitionGeoJsonLayer(props) {
|
|
|
5768
5393
|
|
|
5769
5394
|
oldGeojsonRef.current = props.geojson;
|
|
5770
5395
|
}, [mapHook.map, transitionToGeojson, props]);
|
|
5771
|
-
|
|
5396
|
+
const startTransition = useCallback(() => {
|
|
5772
5397
|
if (props.type === "line" && typeof props.transitionTime !== "undefined" && props.transitionTime && typeof props.geojson.geometry !== "undefined" && JSON.stringify(oldGeojsonRef.current) !== JSON.stringify(props.geojson)) {
|
|
5773
5398
|
transitionToGeojson(props.geojson);
|
|
5774
5399
|
oldGeojsonRef.current = props.geojson;
|
|
5775
5400
|
}
|
|
5776
5401
|
}, [props, transitionToGeojson]);
|
|
5777
|
-
useEffect(
|
|
5402
|
+
useEffect(() => {
|
|
5778
5403
|
if (!mapHook.mapIsReady || !props.geojson) return;
|
|
5779
5404
|
initializedRef.current = true;
|
|
5780
5405
|
startTransition();
|
|
5781
5406
|
}, [mapHook.mapIsReady, startTransition, props]);
|
|
5782
|
-
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(MlGeoJsonLayer, _extends({}, restProps, {
|
|
5407
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(MlGeoJsonLayer, _extends$3({}, restProps, {
|
|
5783
5408
|
geojson: displayGeojson
|
|
5784
5409
|
})));
|
|
5785
5410
|
};
|
|
@@ -5870,35 +5495,26 @@ MlTransitionGeoJsonLayer.propTypes = {
|
|
|
5870
5495
|
* @component
|
|
5871
5496
|
*/
|
|
5872
5497
|
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5498
|
+
const MlMarker = props => {
|
|
5499
|
+
const mapContext = useContext(MapContext);
|
|
5500
|
+
const mapState = useMapState({
|
|
5876
5501
|
mapId: props.mapId,
|
|
5877
5502
|
watch: {
|
|
5878
5503
|
viewport: true
|
|
5879
5504
|
}
|
|
5880
5505
|
});
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
var _useState = useState({
|
|
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({
|
|
5887
5511
|
width: "400px",
|
|
5888
5512
|
height: "500px"
|
|
5889
|
-
})
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
var _useState3 = useState(undefined),
|
|
5895
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
5896
|
-
markerPixelPos = _useState4[0],
|
|
5897
|
-
setMarkerPixelPos = _useState4[1];
|
|
5898
|
-
|
|
5899
|
-
useEffect(function () {
|
|
5900
|
-
var _componentId = componentId.current;
|
|
5901
|
-
return function () {
|
|
5513
|
+
});
|
|
5514
|
+
const [markerPixelPos, setMarkerPixelPos] = useState(undefined);
|
|
5515
|
+
useEffect(() => {
|
|
5516
|
+
let _componentId = componentId.current;
|
|
5517
|
+
return () => {
|
|
5902
5518
|
// This is the cleanup function, it is called when this react component is removed from react-dom
|
|
5903
5519
|
// try to remove anything this component has added to the MapLibre-gl instance
|
|
5904
5520
|
// e.g.: remove the layer
|
|
@@ -5912,36 +5528,36 @@ var MlMarker = function MlMarker(props) {
|
|
|
5912
5528
|
initializedRef.current = false;
|
|
5913
5529
|
};
|
|
5914
5530
|
}, []);
|
|
5915
|
-
useEffect(
|
|
5531
|
+
useEffect(() => {
|
|
5916
5532
|
if (!mapContext.mapExists(props.mapId) || initializedRef.current) return; // the MapLibre-gl instance (mapContext.getMap(props.mapId)) is accessible here
|
|
5917
5533
|
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
5918
5534
|
|
|
5919
5535
|
initializedRef.current = true;
|
|
5920
5536
|
mapRef.current = mapContext.getMap(props.mapId);
|
|
5921
5537
|
}, [mapContext.mapIds, mapContext, props.mapId]);
|
|
5922
|
-
useEffect(
|
|
5538
|
+
useEffect(() => {
|
|
5923
5539
|
var _mapRef$current;
|
|
5924
5540
|
|
|
5925
5541
|
if (!((_mapRef$current = mapRef.current) !== null && _mapRef$current !== void 0 && _mapRef$current.project)) return;
|
|
5926
5542
|
|
|
5927
|
-
|
|
5543
|
+
const _pixelPos = mapRef.current.project([props.lng, props.lat]);
|
|
5928
5544
|
|
|
5929
5545
|
setMarkerPixelPos(_pixelPos);
|
|
5930
5546
|
}, [props.lng, props.lat, mapState.viewport]);
|
|
5931
|
-
useEffect(
|
|
5547
|
+
useEffect(() => {
|
|
5932
5548
|
var _iframe$current, _iframe$current$conte, _iframe$current$conte2, _iframe$current$conte3;
|
|
5933
5549
|
|
|
5934
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) {
|
|
5935
|
-
setTimeout(
|
|
5551
|
+
setTimeout(() => {
|
|
5936
5552
|
var _iframe$current2, _iframe$current2$cont, _iframe$current2$cont2, _iframe$current2$cont3, _iframe$current3, _iframe$current3$cont, _iframe$current3$cont2, _iframe$current3$cont3;
|
|
5937
5553
|
|
|
5938
|
-
|
|
5554
|
+
let mapHeight = mapRef.current._container.clientHeight;
|
|
5939
5555
|
|
|
5940
|
-
|
|
5556
|
+
const _pixelPos = mapRef.current.project([props.lng, props.lat]);
|
|
5941
5557
|
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
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;
|
|
5945
5561
|
setIframeDimensions({
|
|
5946
5562
|
width: iframeWidth,
|
|
5947
5563
|
height: pixelToBottom < iframeHeight ? pixelToBottom : iframeHeight
|
|
@@ -6019,39 +5635,20 @@ MlMarker.propTypes = {
|
|
|
6019
5635
|
|
|
6020
5636
|
function useWms(props) {
|
|
6021
5637
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
url = _useState4[0],
|
|
6030
|
-
setUrl = _useState4[1];
|
|
6031
|
-
|
|
6032
|
-
var _useState5 = useState(""),
|
|
6033
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
6034
|
-
wmsUrl = _useState6[0],
|
|
6035
|
-
setWmsUrl = _useState6[1];
|
|
6036
|
-
|
|
6037
|
-
var _useState7 = useState(undefined),
|
|
6038
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
6039
|
-
capabilities = _useState8[0],
|
|
6040
|
-
setCapabilities = _useState8[1];
|
|
6041
|
-
|
|
6042
|
-
var _useState9 = useState(undefined),
|
|
6043
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
6044
|
-
error = _useState10[0],
|
|
6045
|
-
setError = _useState10[1];
|
|
6046
|
-
|
|
6047
|
-
var clearState = function clearState() {
|
|
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 = () => {
|
|
6048
5645
|
setGetFeatureInfoUrl(undefined);
|
|
6049
5646
|
setCapabilities(undefined); //setLayers([]);
|
|
6050
5647
|
|
|
6051
5648
|
setWmsUrl("");
|
|
6052
5649
|
};
|
|
6053
5650
|
|
|
6054
|
-
useEffect(
|
|
5651
|
+
useEffect(() => {
|
|
6055
5652
|
var _propsUrlParams2;
|
|
6056
5653
|
|
|
6057
5654
|
// extract URL parameters from the given URL
|
|
@@ -6059,38 +5656,39 @@ function useWms(props) {
|
|
|
6059
5656
|
setError(undefined);
|
|
6060
5657
|
if (!url) return;
|
|
6061
5658
|
|
|
6062
|
-
|
|
5659
|
+
let _propsUrlParams;
|
|
6063
5660
|
|
|
6064
|
-
|
|
5661
|
+
let _wmsUrl = url;
|
|
6065
5662
|
|
|
6066
5663
|
if (url.indexOf("?") !== -1) {
|
|
6067
5664
|
_propsUrlParams = url.split("?");
|
|
6068
5665
|
_wmsUrl = _propsUrlParams[0];
|
|
6069
5666
|
}
|
|
6070
5667
|
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
var urlParamsObj = _objectSpread2(_objectSpread2({}, Object.fromEntries(_urlParamsFromUrl)), props.urlParameters); // create URLSearchParams object to assemble the URL Parameters
|
|
5668
|
+
let _urlParamsFromUrl = new URLSearchParams((_propsUrlParams2 = _propsUrlParams) === null || _propsUrlParams2 === void 0 ? void 0 : _propsUrlParams2[1]);
|
|
6074
5669
|
|
|
5670
|
+
let urlParamsObj = { ...Object.fromEntries(_urlParamsFromUrl),
|
|
5671
|
+
...props.urlParameters
|
|
5672
|
+
}; // create URLSearchParams object to assemble the URL Parameters
|
|
6075
5673
|
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
fetch(_wmsUrl + "?" + urlParamsStr).then(
|
|
5674
|
+
let urlParams = new URLSearchParams(urlParamsObj);
|
|
5675
|
+
let urlParamsStr = decodeURIComponent(urlParams.toString()) + "".replace(/%2F/g, "/").replace(/%3A/g, ":");
|
|
5676
|
+
fetch(_wmsUrl + "?" + urlParamsStr).then(res => {
|
|
6079
5677
|
if (!res.ok) {
|
|
6080
5678
|
throw Error(res.statusText + " (" + res.status + " - " + res.type + ")");
|
|
6081
5679
|
} else {
|
|
6082
5680
|
return res.text();
|
|
6083
5681
|
}
|
|
6084
|
-
}).then(
|
|
5682
|
+
}).then(data => {
|
|
6085
5683
|
setCapabilities(new WMSCapabilities(data).toJSON());
|
|
6086
|
-
}).catch(
|
|
5684
|
+
}).catch(error => {
|
|
6087
5685
|
//reset local state
|
|
6088
5686
|
clearState();
|
|
6089
5687
|
console.log(error);
|
|
6090
5688
|
setError(error.message);
|
|
6091
5689
|
});
|
|
6092
5690
|
}, [url, props.urlParameters]);
|
|
6093
|
-
useEffect(
|
|
5691
|
+
useEffect(() => {
|
|
6094
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;
|
|
6095
5693
|
|
|
6096
5694
|
if (!(capabilities !== null && capabilities !== void 0 && capabilities.Service)) return;
|
|
@@ -6099,11 +5697,11 @@ function useWms(props) {
|
|
|
6099
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);
|
|
6100
5698
|
}, [capabilities]);
|
|
6101
5699
|
return {
|
|
6102
|
-
capabilities
|
|
6103
|
-
getFeatureInfoUrl
|
|
6104
|
-
wmsUrl
|
|
6105
|
-
error
|
|
6106
|
-
setUrl
|
|
5700
|
+
capabilities,
|
|
5701
|
+
getFeatureInfoUrl,
|
|
5702
|
+
wmsUrl,
|
|
5703
|
+
error,
|
|
5704
|
+
setUrl
|
|
6107
5705
|
};
|
|
6108
5706
|
}
|
|
6109
5707
|
|