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