@mapcomponents/react-maplibre 0.1.70 → 0.1.72
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 +14 -0
- package/dist/components/MapLibreMap/lib/MapLibreGlWrapper.d.ts +1 -0
- package/dist/components/MlComponentTemplate/MlComponentTemplate.d.ts +1 -6
- package/dist/components/MlSketchTool/LayerList/ColorPicker.d.ts +1 -1
- package/dist/index.esm.js +141 -80
- package/dist/index.esm.js.map +1 -1
- package/dist/ui_components/ColorPicker/ColorPicker.d.ts +17 -0
- package/dist/ui_components/ColorPicker/transformers.d.ts +10 -0
- package/dist/ui_components/LayerList/LayerList.stories.d.ts +3 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## [v0.1.72] - 2023-03-08
|
|
5
|
+
|
|
6
|
+
### Fixed
|
|
7
|
+
- Fix/maplibremap registration react 18 (#89) …
|
|
8
|
+
- remove mui-color dependency
|
|
9
|
+
### Added
|
|
10
|
+
- add new ColorPicker ui component
|
|
11
|
+
- add MlWmsLayer support to LayerList component
|
|
12
|
+
|
|
13
|
+
## [v0.1.71] - 2023-03-04
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
- e3178b5: fix Topbar sidebar defaults
|
|
17
|
+
|
|
4
18
|
## [v0.1.70] - 2023-03-03
|
|
5
19
|
|
|
6
20
|
### Fixed
|
|
@@ -39,6 +39,7 @@ interface MapLibreGlWrapper extends MapType {
|
|
|
39
39
|
}) | (CustomLayerInterface & {
|
|
40
40
|
source?: string | SourceSpecification | undefined;
|
|
41
41
|
}), beforeId?: string | undefined, componentId?: string | undefined) => this;
|
|
42
|
+
cancelled: boolean;
|
|
42
43
|
}
|
|
43
44
|
declare class MapLibreGlWrapper {
|
|
44
45
|
registeredElements: {
|
|
@@ -4,14 +4,9 @@ export interface MlComponentTemplateProps {
|
|
|
4
4
|
* Id of the target MapLibre instance in mapContext
|
|
5
5
|
*/
|
|
6
6
|
mapId?: string;
|
|
7
|
-
/**
|
|
8
|
-
* Id of an existing layer in the mapLibre instance to help specify the layer order
|
|
9
|
-
* This layer will be visually beneath the layer with the "insertBeforeLayer" id.
|
|
10
|
-
*/
|
|
11
|
-
insertBeforeLayer?: string;
|
|
12
7
|
}
|
|
13
8
|
/**
|
|
14
|
-
* Component
|
|
9
|
+
* Component description
|
|
15
10
|
*
|
|
16
11
|
*/
|
|
17
12
|
declare const MlComponentTemplate: {
|
package/dist/index.esm.js
CHANGED
|
@@ -41,7 +41,7 @@ var ListItemText = require('@mui/material/ListItemText');
|
|
|
41
41
|
var IconButton = require('@mui/material/IconButton');
|
|
42
42
|
var d3 = require('d3');
|
|
43
43
|
var TuneIcon = require('@mui/icons-material/Tune');
|
|
44
|
-
var
|
|
44
|
+
var reactColor = require('react-color');
|
|
45
45
|
var iconsMaterial = require('@mui/icons-material');
|
|
46
46
|
var system = require('@mui/system');
|
|
47
47
|
var AppBar = require('@mui/material/AppBar');
|
|
@@ -392,6 +392,7 @@ var MapLibreGlWrapper = /** @class */ (function () {
|
|
|
392
392
|
self.wrapper.viewportState = self.wrapper.getViewport();
|
|
393
393
|
},
|
|
394
394
|
};
|
|
395
|
+
this.cancelled = false;
|
|
395
396
|
/**
|
|
396
397
|
* Initializes an empty registered elements object for the given componentId
|
|
397
398
|
*
|
|
@@ -868,12 +869,11 @@ var MapComponentsProvider = function (_a) {
|
|
|
868
869
|
mapIds_raw.current.splice(mapIdIndex, 1);
|
|
869
870
|
}
|
|
870
871
|
setMapIds(__spreadArray([], mapIds_raw.current, true));
|
|
871
|
-
if (
|
|
872
|
+
if (mapIds_raw.current.length === 0 && map) {
|
|
872
873
|
setMap(undefined);
|
|
873
874
|
}
|
|
874
875
|
}
|
|
875
876
|
else {
|
|
876
|
-
setMap(undefined);
|
|
877
877
|
removeMap('anonymous_map');
|
|
878
878
|
}
|
|
879
879
|
};
|
|
@@ -895,7 +895,7 @@ var MapComponentsProvider = function (_a) {
|
|
|
895
895
|
maps.current[mapId] = mapInstance;
|
|
896
896
|
mapIds_raw.current.push(mapId);
|
|
897
897
|
setMapIds(__spreadArray([], mapIds_raw.current, true));
|
|
898
|
-
if (!map) {
|
|
898
|
+
if (!map || (map === null || map === void 0 ? void 0 : map.cancelled) === true) {
|
|
899
899
|
setMap(mapInstance);
|
|
900
900
|
}
|
|
901
901
|
}
|
|
@@ -962,7 +962,7 @@ var defaultProps$1 = {
|
|
|
962
962
|
*/
|
|
963
963
|
var MapLibreMap = function (props) {
|
|
964
964
|
var _a, _b;
|
|
965
|
-
var
|
|
965
|
+
var mapRef = React.useRef();
|
|
966
966
|
var mapContainer = React.useRef();
|
|
967
967
|
var mapContext = React.useContext(MapContext);
|
|
968
968
|
var mapIdRef = React.useRef(props.mapId);
|
|
@@ -971,11 +971,14 @@ var MapLibreMap = function (props) {
|
|
|
971
971
|
React.useEffect(function () {
|
|
972
972
|
var mapId = mapIdRef.current;
|
|
973
973
|
return function () {
|
|
974
|
-
var _a, _b
|
|
974
|
+
var _a, _b;
|
|
975
975
|
initializedRef.current = false;
|
|
976
976
|
mapContext.removeMap(mapId);
|
|
977
|
-
|
|
978
|
-
|
|
977
|
+
if (mapRef.current) {
|
|
978
|
+
(_b = (_a = mapRef.current.map) === null || _a === void 0 ? void 0 : _a.remove) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
979
|
+
mapRef.current.cancelled = true;
|
|
980
|
+
mapRef.current = undefined;
|
|
981
|
+
}
|
|
979
982
|
};
|
|
980
983
|
}, []);
|
|
981
984
|
React.useEffect(function () {
|
|
@@ -984,15 +987,20 @@ var MapLibreMap = function (props) {
|
|
|
984
987
|
return;
|
|
985
988
|
if (mapContainer.current) {
|
|
986
989
|
initializedRef.current = true;
|
|
987
|
-
|
|
990
|
+
mapRef.current = new MapLibreGlWrapper({
|
|
988
991
|
mapOptions: __assign(__assign(__assign({ style: '' }, props.options), (((_a = props === null || props === void 0 ? void 0 : props.options) === null || _a === void 0 ? void 0 : _a.style) ? {} : { style: (_b = defaultProps$1 === null || defaultProps$1 === void 0 ? void 0 : defaultProps$1.options) === null || _b === void 0 ? void 0 : _b.style })), { container: mapContainer.current }),
|
|
989
992
|
onReady: function (map, wrapper) {
|
|
990
993
|
map.once('load', function () {
|
|
991
|
-
if (
|
|
992
|
-
|
|
994
|
+
if (!(wrapper === null || wrapper === void 0 ? void 0 : wrapper.cancelled)) {
|
|
995
|
+
if (props.mapId) {
|
|
996
|
+
mapContext.registerMap(props.mapId, wrapper);
|
|
997
|
+
}
|
|
998
|
+
else {
|
|
999
|
+
mapContext.setMap(wrapper);
|
|
1000
|
+
}
|
|
993
1001
|
}
|
|
994
1002
|
else {
|
|
995
|
-
|
|
1003
|
+
map.remove();
|
|
996
1004
|
}
|
|
997
1005
|
});
|
|
998
1006
|
},
|
|
@@ -1001,10 +1009,11 @@ var MapLibreMap = function (props) {
|
|
|
1001
1009
|
}, [props.options, props.mapId]);
|
|
1002
1010
|
React.useEffect(function () {
|
|
1003
1011
|
var _a, _b;
|
|
1004
|
-
if (((_a =
|
|
1005
|
-
|
|
1012
|
+
if (((_a = mapRef.current) === null || _a === void 0 ? void 0 : _a.map) &&
|
|
1013
|
+
((_b = props === null || props === void 0 ? void 0 : props.options) === null || _b === void 0 ? void 0 : _b.style) &&
|
|
1014
|
+
currentStyle.current !== props.options.style) {
|
|
1006
1015
|
currentStyle.current = props.options.style;
|
|
1007
|
-
|
|
1016
|
+
mapRef.current.map.setStyle(props.options.style);
|
|
1008
1017
|
}
|
|
1009
1018
|
}, [(_b = props === null || props === void 0 ? void 0 : props.options) === null || _b === void 0 ? void 0 : _b.style]);
|
|
1010
1019
|
return (React__default["default"].createElement("div", { ref: mapContainer, className: "mapContainer", style: props.style }));
|
|
@@ -1142,7 +1151,6 @@ useMapState.propTypes = {
|
|
|
1142
1151
|
};
|
|
1143
1152
|
|
|
1144
1153
|
function useMap(props) {
|
|
1145
|
-
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
1146
1154
|
var mapContext = React.useContext(MapContext);
|
|
1147
1155
|
var _a = React.useState(), map = _a[0], setMap = _a[1];
|
|
1148
1156
|
var mapState = useMapState({
|
|
@@ -1156,7 +1164,6 @@ function useMap(props) {
|
|
|
1156
1164
|
includeBaseLayers: true,
|
|
1157
1165
|
},
|
|
1158
1166
|
});
|
|
1159
|
-
var initializedRef = React.useRef(false);
|
|
1160
1167
|
var mapRef = React.useRef();
|
|
1161
1168
|
var componentId = React.useRef(uuid.v4());
|
|
1162
1169
|
var _b = React.useState(false), mapIsReady = _b[0], setMapIsReady = _b[1];
|
|
@@ -1164,7 +1171,6 @@ function useMap(props) {
|
|
|
1164
1171
|
if (mapRef.current) {
|
|
1165
1172
|
mapRef.current.cleanup(componentId.current);
|
|
1166
1173
|
}
|
|
1167
|
-
initializedRef.current = false;
|
|
1168
1174
|
};
|
|
1169
1175
|
React.useEffect(function () {
|
|
1170
1176
|
return function () {
|
|
@@ -1175,7 +1181,12 @@ function useMap(props) {
|
|
|
1175
1181
|
}, []);
|
|
1176
1182
|
React.useEffect(function () {
|
|
1177
1183
|
var _a;
|
|
1178
|
-
if (
|
|
1184
|
+
if (mapRef.current && mapRef.current.cancelled === true) {
|
|
1185
|
+
mapRef.current = undefined;
|
|
1186
|
+
setMap(undefined);
|
|
1187
|
+
setMapIsReady(false);
|
|
1188
|
+
}
|
|
1189
|
+
if (mapRef.current || !mapContext.mapExists(props === null || props === void 0 ? void 0 : props.mapId))
|
|
1179
1190
|
return;
|
|
1180
1191
|
// check if waitForLayer (string, layer id of the layer this hook is supposed to wait for)
|
|
1181
1192
|
// exists as layer in the MapLibre instance
|
|
@@ -1190,9 +1201,6 @@ function useMap(props) {
|
|
|
1190
1201
|
return;
|
|
1191
1202
|
}
|
|
1192
1203
|
}
|
|
1193
|
-
// the MapLibre-gl instance (mapContext.getMap(props.mapId)) is accessible here
|
|
1194
|
-
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
1195
|
-
initializedRef.current = true;
|
|
1196
1204
|
mapRef.current = mapContext.getMap(props === null || props === void 0 ? void 0 : props.mapId);
|
|
1197
1205
|
setMap(mapRef.current);
|
|
1198
1206
|
setMapIsReady(true);
|
|
@@ -1241,23 +1249,14 @@ MlCenterPosition.defaultProps = {
|
|
|
1241
1249
|
};
|
|
1242
1250
|
|
|
1243
1251
|
/**
|
|
1244
|
-
* Component
|
|
1252
|
+
* Component description
|
|
1245
1253
|
*
|
|
1246
1254
|
*/
|
|
1247
1255
|
var MlComponentTemplate = function (props) {
|
|
1248
1256
|
var mapHook = useMap({
|
|
1249
1257
|
mapId: props.mapId,
|
|
1250
|
-
waitForLayer: props.insertBeforeLayer,
|
|
1251
1258
|
});
|
|
1252
|
-
|
|
1253
|
-
React.useEffect(function () {
|
|
1254
|
-
if (!mapHook.map || initializedRef.current)
|
|
1255
|
-
return;
|
|
1256
|
-
// the MapLibre-gl instance (mapHook.map) is accessible here
|
|
1257
|
-
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
1258
|
-
initializedRef.current = true;
|
|
1259
|
-
mapHook.map.map.setCenter([7.132122000552613, 50.716405378037706]);
|
|
1260
|
-
}, [mapHook.map, props.mapId]);
|
|
1259
|
+
console.log(mapHook.componentId + " remove this log");
|
|
1261
1260
|
return React__default["default"].createElement(React__default["default"].Fragment, null);
|
|
1262
1261
|
};
|
|
1263
1262
|
MlComponentTemplate.defaultProps = {
|
|
@@ -3341,7 +3340,7 @@ function useLayer(props) {
|
|
|
3341
3340
|
var layerId = React.useRef(props.layerId || (props.idPrefix ? props.idPrefix : 'Layer-') + mapHook.componentId);
|
|
3342
3341
|
var createLayer = React.useCallback(function () {
|
|
3343
3342
|
var _a, _b;
|
|
3344
|
-
if (!mapHook.map)
|
|
3343
|
+
if (!mapHook.map || (mapHook === null || mapHook === void 0 ? void 0 : mapHook.map.cancelled))
|
|
3345
3344
|
return;
|
|
3346
3345
|
if (mapHook.map.map.getLayer(layerId.current)) {
|
|
3347
3346
|
mapHook.cleanup();
|
|
@@ -3397,9 +3396,12 @@ function useLayer(props) {
|
|
|
3397
3396
|
layerTypeRef.current = props.options.type;
|
|
3398
3397
|
}, [props, mapHook.map]);
|
|
3399
3398
|
React.useEffect(function () {
|
|
3399
|
+
var _a, _b, _c, _d;
|
|
3400
3400
|
if (!mapHook.map)
|
|
3401
3401
|
return;
|
|
3402
|
-
if (
|
|
3402
|
+
if (((_a = mapHook.map) === null || _a === void 0 ? void 0 : _a.cancelled) === false &&
|
|
3403
|
+
initializedRef.current &&
|
|
3404
|
+
((_d = (_c = (_b = mapHook === null || mapHook === void 0 ? void 0 : mapHook.map) === null || _b === void 0 ? void 0 : _b.map) === null || _c === void 0 ? void 0 : _c.getLayer) === null || _d === void 0 ? void 0 : _d.call(_c, layerId.current)) &&
|
|
3403
3405
|
(legalLayerTypes.indexOf(props.options.type) === -1 ||
|
|
3404
3406
|
(legalLayerTypes.indexOf(props.options.type) !== -1 &&
|
|
3405
3407
|
props.options.type === layerTypeRef.current))) {
|
|
@@ -3408,17 +3410,20 @@ function useLayer(props) {
|
|
|
3408
3410
|
createLayer();
|
|
3409
3411
|
}, [mapHook.map, props.options, createLayer]);
|
|
3410
3412
|
React.useEffect(function () {
|
|
3411
|
-
var _a, _b, _c, _d;
|
|
3412
|
-
if (
|
|
3413
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3414
|
+
if (((_a = mapHook.map) === null || _a === void 0 ? void 0 : _a.cancelled) === true ||
|
|
3415
|
+
!initializedRef.current ||
|
|
3416
|
+
!((_d = (_c = (_b = mapHook.map) === null || _b === void 0 ? void 0 : _b.map) === null || _c === void 0 ? void 0 : _c.getSource) === null || _d === void 0 ? void 0 : _d.call(_c, layerId.current)))
|
|
3413
3417
|
return;
|
|
3414
3418
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3415
3419
|
//@ts-ignore setData only exists on GeoJsonSource
|
|
3416
|
-
(
|
|
3420
|
+
(_f = (_e = mapHook.map.map.getSource(layerId.current)) === null || _e === void 0 ? void 0 : _e.setData) === null || _f === void 0 ? void 0 : _f.call(_e, props.geojson);
|
|
3417
3421
|
}, [props.geojson, mapHook.map, props.options.type]);
|
|
3418
3422
|
React.useEffect(function () {
|
|
3419
|
-
var _a, _b, _c, _d, _e;
|
|
3420
|
-
if (
|
|
3421
|
-
!
|
|
3423
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3424
|
+
if (((_a = mapHook.map) === null || _a === void 0 ? void 0 : _a.cancelled) === true ||
|
|
3425
|
+
!mapHook.map ||
|
|
3426
|
+
!((_d = (_c = (_b = mapHook.map) === null || _b === void 0 ? void 0 : _b.map) === null || _c === void 0 ? void 0 : _c.getLayer) === null || _d === void 0 ? void 0 : _d.call(_c, layerId.current)) ||
|
|
3422
3427
|
!initializedRef.current ||
|
|
3423
3428
|
props.options.type !== layerTypeRef.current)
|
|
3424
3429
|
return;
|
|
@@ -3427,7 +3432,7 @@ function useLayer(props) {
|
|
|
3427
3432
|
if (props.options.layout && layoutString !== layerLayoutConfRef.current) {
|
|
3428
3433
|
var oldLayout = JSON.parse(layerLayoutConfRef.current);
|
|
3429
3434
|
for (key in props.options.layout) {
|
|
3430
|
-
if (((
|
|
3435
|
+
if (((_e = props.options.layout) === null || _e === void 0 ? void 0 : _e[key]) && props.options.layout[key] !== oldLayout[key]) {
|
|
3431
3436
|
mapHook.map.map.setLayoutProperty(layerId.current, key, props.options.layout[key]);
|
|
3432
3437
|
}
|
|
3433
3438
|
}
|
|
@@ -3437,7 +3442,7 @@ function useLayer(props) {
|
|
|
3437
3442
|
if (paintString !== layerPaintConfRef.current) {
|
|
3438
3443
|
var oldPaint = JSON.parse(layerPaintConfRef.current);
|
|
3439
3444
|
for (key in props.options.paint) {
|
|
3440
|
-
if (((
|
|
3445
|
+
if (((_f = props.options.paint) === null || _f === void 0 ? void 0 : _f[key]) && props.options.paint[key] !== oldPaint[key]) {
|
|
3441
3446
|
mapHook.map.map.setPaintProperty(layerId.current, key, props.options.paint[key]);
|
|
3442
3447
|
}
|
|
3443
3448
|
}
|
|
@@ -3504,6 +3509,7 @@ var getDefaultPaintPropsByType = function (type, defaultPaintOverrides) {
|
|
|
3504
3509
|
}
|
|
3505
3510
|
return {
|
|
3506
3511
|
'fill-color': 'rgba(10,240,256,0.6)',
|
|
3512
|
+
'fill-outline-color': 'rgba(20,230,256,0.8)',
|
|
3507
3513
|
};
|
|
3508
3514
|
case 'line':
|
|
3509
3515
|
if (defaultPaintOverrides === null || defaultPaintOverrides === void 0 ? void 0 : defaultPaintOverrides.line) {
|
|
@@ -3523,6 +3529,7 @@ var getDefaultPaintPropsByType = function (type, defaultPaintOverrides) {
|
|
|
3523
3529
|
'circle-color': 'rgba(10,240,256,0.8)',
|
|
3524
3530
|
'circle-stroke-color': '#fff',
|
|
3525
3531
|
'circle-stroke-width': 2,
|
|
3532
|
+
'circle-radius': 4,
|
|
3526
3533
|
};
|
|
3527
3534
|
}
|
|
3528
3535
|
};
|
|
@@ -3928,21 +3935,21 @@ var MlNavigationTools = function (props) {
|
|
|
3928
3935
|
}, mapHook.componentId);
|
|
3929
3936
|
setPitch(mapHook.map.map.getPitch());
|
|
3930
3937
|
}, [mapHook.map, props.mapId]);
|
|
3931
|
-
var zoomIn = function () {
|
|
3938
|
+
var zoomIn = React.useCallback(function () {
|
|
3932
3939
|
if (!mapHook.map)
|
|
3933
3940
|
return;
|
|
3934
3941
|
if (mapHook.map.map.transform._zoom + 0.5 <= mapHook.map.map.transform._maxZoom) {
|
|
3935
3942
|
mapHook.map.map.easeTo({ zoom: mapHook.map.map.transform._zoom + 0.5 });
|
|
3936
3943
|
}
|
|
3937
|
-
};
|
|
3938
|
-
var zoomOut = function () {
|
|
3944
|
+
}, [mapHook.map]);
|
|
3945
|
+
var zoomOut = React.useCallback(function () {
|
|
3939
3946
|
if (!mapHook.map)
|
|
3940
3947
|
return;
|
|
3941
3948
|
if (mapHook.map.map.transform._zoom - 0.5 >= mapHook.map.map.transform._minZoom) {
|
|
3942
3949
|
mapHook.map.map.easeTo({ zoom: mapHook.map.map.transform._zoom - 0.5 });
|
|
3943
3950
|
}
|
|
3944
|
-
};
|
|
3945
|
-
var adjustPitch = function () {
|
|
3951
|
+
}, [mapHook.map]);
|
|
3952
|
+
var adjustPitch = React.useCallback(function () {
|
|
3946
3953
|
if (!mapHook.map)
|
|
3947
3954
|
return;
|
|
3948
3955
|
var targetPitch = 60;
|
|
@@ -3950,7 +3957,7 @@ var MlNavigationTools = function (props) {
|
|
|
3950
3957
|
targetPitch = 0;
|
|
3951
3958
|
}
|
|
3952
3959
|
mapHook.map.map.easeTo({ pitch: targetPitch });
|
|
3953
|
-
};
|
|
3960
|
+
}, [mapHook.map]);
|
|
3954
3961
|
return (React__default["default"].createElement(Box__default["default"], { sx: __assign(__assign({ zIndex: 501, position: 'absolute', display: 'flex', flexDirection: 'column' }, (mediaIsMobile ? { margin: '20px 10px 20px 10px' } : {})), props.sx) },
|
|
3955
3962
|
React__default["default"].createElement(MlNavigationCompass, { style: {
|
|
3956
3963
|
width: '31px',
|
|
@@ -6331,17 +6338,17 @@ var MlWmsLoader = function (props) {
|
|
|
6331
6338
|
};
|
|
6332
6339
|
}, [getFeatureInfo]);
|
|
6333
6340
|
React.useEffect(function () {
|
|
6334
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
6341
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
6335
6342
|
if (!(capabilities === null || capabilities === void 0 ? void 0 : capabilities.Service))
|
|
6336
6343
|
return;
|
|
6337
|
-
if (((_d = (_c = (_b = (_a = capabilities === null || capabilities === void 0 ? void 0 : capabilities.Capability) === null || _a === void 0 ? void 0 : _a.Layer) === null || _b === void 0 ? void 0 : _b.CRS) === null || _c === void 0 ? void 0 : _c.indexOf) === null || _d === void 0 ? void 0 : _d.call(_c, 'EPSG:3857')) === -1) {
|
|
6344
|
+
if (((_d = (_c = (_b = (_a = capabilities === null || capabilities === void 0 ? void 0 : capabilities.Capability) === null || _a === void 0 ? void 0 : _a.Layer) === null || _b === void 0 ? void 0 : _b.CRS) === null || _c === void 0 ? void 0 : _c.indexOf) === null || _d === void 0 ? void 0 : _d.call(_c, 'EPSG:3857')) === -1 && ((_h = (_g = (_f = (_e = capabilities === null || capabilities === void 0 ? void 0 : capabilities.Capability) === null || _e === void 0 ? void 0 : _e.Layer) === null || _f === void 0 ? void 0 : _f.CRS) === null || _g === void 0 ? void 0 : _g.indexOf) === null || _h === void 0 ? void 0 : _h.call(_g, 'CRS:84')) === -1) {
|
|
6338
6345
|
console.log('MlWmsLoader (' + capabilities.Service.Title + '): No WGS 84/Pseudo-Mercator support');
|
|
6339
6346
|
}
|
|
6340
6347
|
else {
|
|
6341
6348
|
console.log('MlWmsLoader (' + capabilities.Service.Title + '): WGS 84/Pseudo-Mercator supported');
|
|
6342
6349
|
var _LatLonBoundingBox_1 = [];
|
|
6343
6350
|
// collect aueriable Layer2 layers
|
|
6344
|
-
var _layers_1 = (
|
|
6351
|
+
var _layers_1 = (_k = (_j = capabilities === null || capabilities === void 0 ? void 0 : capabilities.Capability) === null || _j === void 0 ? void 0 : _j.Layer) === null || _k === void 0 ? void 0 : _k.Layer.filter(function (el) { var _a; return !((_a = el.Layer) === null || _a === void 0 ? void 0 : _a.length); }).map(function (layer, idx) {
|
|
6345
6352
|
var _a, _b, _c;
|
|
6346
6353
|
if (idx === 0) {
|
|
6347
6354
|
_LatLonBoundingBox_1 = layer.EX_GeographicBoundingBox;
|
|
@@ -6349,7 +6356,7 @@ var MlWmsLoader = function (props) {
|
|
|
6349
6356
|
return __assign({ visible: ((_c = (_b = (_a = capabilities === null || capabilities === void 0 ? void 0 : capabilities.Capability) === null || _a === void 0 ? void 0 : _a.Layer) === null || _b === void 0 ? void 0 : _b.Layer) === null || _c === void 0 ? void 0 : _c.length) > 2 ? idx > 1 : true, Attribution: { Title: '' } }, layer);
|
|
6350
6357
|
});
|
|
6351
6358
|
// collect aueriable Layer3 layers
|
|
6352
|
-
(
|
|
6359
|
+
(_m = (_l = capabilities === null || capabilities === void 0 ? void 0 : capabilities.Capability) === null || _l === void 0 ? void 0 : _l.Layer) === null || _m === void 0 ? void 0 : _m.Layer.forEach(function (el) {
|
|
6353
6360
|
var _a;
|
|
6354
6361
|
var tmpLayers = (_a = el === null || el === void 0 ? void 0 : el.Layer) === null || _a === void 0 ? void 0 : _a.filter(function (el) { return el.CRS.length; }).map(function (layer, idx) {
|
|
6355
6362
|
if (idx === 0) {
|
|
@@ -6719,37 +6726,81 @@ function LayerList(_a) {
|
|
|
6719
6726
|
return React__default["default"].createElement(material.List, { sx: { marginTop: '15px' } }, children);
|
|
6720
6727
|
}
|
|
6721
6728
|
|
|
6729
|
+
var converters = {
|
|
6730
|
+
rgba: function (c) { return "rgba(".concat(c.rgb.r, ", ").concat(c.rgb.g, ", ").concat(c.rgb.b, ", ").concat(c.rgb.a, ")"); },
|
|
6731
|
+
rgb: function (c) { return "rgb(".concat(c.rgb.r, ", ").concat(c.rgb.g, ", ").concat(c.rgb.b, ")"); },
|
|
6732
|
+
hex: function (c) { return c.hex; },
|
|
6733
|
+
rgba_rgb: function (c) { return c.rgb.a === 1 ? converters.rgb(c) : converters.rgba(c); },
|
|
6734
|
+
rgba_hex: function (c) { return c.rgb.a === 1 ? converters.hex(c) : converters.rgba(c); }
|
|
6735
|
+
};
|
|
6736
|
+
|
|
6737
|
+
var ColorPicker = function (_a) {
|
|
6738
|
+
var convert = _a.convert, props = __rest(_a, ["convert"]);
|
|
6739
|
+
var _b = React.useState(false), showPicker = _b[0], setShowPicker = _b[1];
|
|
6740
|
+
var _c = React.useState((props === null || props === void 0 ? void 0 : props.value) || ''), value = _c[0], setValue = _c[1];
|
|
6741
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
6742
|
+
React__default["default"].createElement(material.Grid, { container: true, sx: { flexWrap: 'nowrap' } },
|
|
6743
|
+
React__default["default"].createElement(material.Grid, { xs: 2, item: true },
|
|
6744
|
+
React__default["default"].createElement(material.Button, { variant: "outlined", onClick: function () { return setShowPicker(true); }, sx: {
|
|
6745
|
+
minWidth: 'initial',
|
|
6746
|
+
padding: '5px',
|
|
6747
|
+
borderColor: function (theme) { return theme.palette.text.primary; },
|
|
6748
|
+
} },
|
|
6749
|
+
React__default["default"].createElement("div", { style: { width: '25px', height: '25px', backgroundColor: value } }))),
|
|
6750
|
+
React__default["default"].createElement(material.Grid, { xs: 10, item: true },
|
|
6751
|
+
React__default["default"].createElement(material.TextField, { onClick: function () { return setShowPicker(true); }, value: value, variant: "outlined", disabled: true }))),
|
|
6752
|
+
showPicker && (React__default["default"].createElement("div", { style: { position: 'relative', marginTop: 0 } },
|
|
6753
|
+
React__default["default"].createElement("div", { style: { position: 'absolute', zIndex: 1000 } },
|
|
6754
|
+
React__default["default"].createElement("div", { style: { position: 'fixed', top: '0px', right: '0px', bottom: '0px', left: '0px' }, onClick: function () {
|
|
6755
|
+
setShowPicker(false);
|
|
6756
|
+
} }),
|
|
6757
|
+
React__default["default"].createElement(reactColor.ChromePicker, { color: value, onChange: function (c) {
|
|
6758
|
+
var _a;
|
|
6759
|
+
var newValue = converters[convert](c);
|
|
6760
|
+
setValue(newValue);
|
|
6761
|
+
(_a = props === null || props === void 0 ? void 0 : props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, newValue);
|
|
6762
|
+
} }))))));
|
|
6763
|
+
};
|
|
6764
|
+
ColorPicker.defaultProps = {
|
|
6765
|
+
convert: 'rgba_hex',
|
|
6766
|
+
label: 'Color',
|
|
6767
|
+
name: 'color',
|
|
6768
|
+
};
|
|
6769
|
+
|
|
6722
6770
|
function PaintPropsColorPicker(_a) {
|
|
6723
6771
|
var propKey = _a.propKey, value = _a.value, setPaintProps = _a.setPaintProps;
|
|
6724
|
-
return (React__default["default"].createElement(
|
|
6772
|
+
return (React__default["default"].createElement(ColorPicker, { value: value, label: "Color", onChange: function (value) {
|
|
6725
6773
|
setPaintProps(function (current) {
|
|
6726
6774
|
var _a;
|
|
6727
|
-
var
|
|
6728
|
-
if (!((_b = value === null || value === void 0 ? void 0 : value.rgb) === null || _b === void 0 ? void 0 : _b[0])) {
|
|
6729
|
-
return current;
|
|
6730
|
-
}
|
|
6731
|
-
var newProps = __assign(__assign({}, current), (_a = {}, _a[propKey] = 'rgba(' +
|
|
6732
|
-
value.rgb[0] +
|
|
6733
|
-
',' +
|
|
6734
|
-
value.rgb[1] +
|
|
6735
|
-
',' +
|
|
6736
|
-
value.rgb[2] +
|
|
6737
|
-
',' +
|
|
6738
|
-
value.alpha +
|
|
6739
|
-
')', _a));
|
|
6775
|
+
var newProps = __assign(__assign({}, current), (_a = {}, _a[propKey] = value, _a));
|
|
6740
6776
|
return newProps;
|
|
6741
6777
|
});
|
|
6742
6778
|
} }));
|
|
6743
6779
|
}
|
|
6744
6780
|
|
|
6745
6781
|
var mapPropKeyToFormInputType = {
|
|
6782
|
+
'circle-color': 'colorpicker',
|
|
6783
|
+
'circle-radius': 'slider',
|
|
6784
|
+
'circle-stroke-color': 'colorpicker',
|
|
6785
|
+
'circle-stroke-width': 'slider',
|
|
6746
6786
|
'fill-color': 'colorpicker',
|
|
6787
|
+
'fill-outline-color': 'colorpicker',
|
|
6747
6788
|
'line-color': 'colorpicker',
|
|
6748
6789
|
'line-width': 'slider',
|
|
6749
6790
|
'line-blur': 'slider',
|
|
6750
6791
|
};
|
|
6751
6792
|
var mapPropKeyToFormInputTypeKeys = Object.keys(mapPropKeyToFormInputType);
|
|
6752
6793
|
var inputPropsByPropKey = {
|
|
6794
|
+
'circle-stroke-width': {
|
|
6795
|
+
step: 1,
|
|
6796
|
+
min: 1,
|
|
6797
|
+
max: 20,
|
|
6798
|
+
},
|
|
6799
|
+
'circle-radius': {
|
|
6800
|
+
step: 1,
|
|
6801
|
+
min: 1,
|
|
6802
|
+
max: 100,
|
|
6803
|
+
},
|
|
6753
6804
|
'line-blur': {
|
|
6754
6805
|
step: 1,
|
|
6755
6806
|
min: 1,
|
|
@@ -6772,7 +6823,7 @@ function LayerPropertyForm(_a) {
|
|
|
6772
6823
|
case 'slider':
|
|
6773
6824
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
6774
6825
|
label,
|
|
6775
|
-
React__default["default"].createElement(material.Slider, __assign({}, inputPropsByPropKey[key], { inputProps: { inputMode: 'decimal', pattern: '[0-9]*' }, value: paintProps[key], onChange: function (_ev, value) {
|
|
6826
|
+
React__default["default"].createElement(material.Slider, __assign({}, inputPropsByPropKey[key], { inputProps: { inputMode: 'decimal', pattern: '[0-9]*' }, value: paintProps[key], valueLabelDisplay: "auto", onChange: function (_ev, value) {
|
|
6776
6827
|
if (value) {
|
|
6777
6828
|
setPaintProps(function (current) {
|
|
6778
6829
|
var _a;
|
|
@@ -6807,6 +6858,7 @@ function LayerPropertyForm(_a) {
|
|
|
6807
6858
|
padding: '15px',
|
|
6808
6859
|
boxShadow: 'inset 0px 0px 10px rgb(50 50 50 / 10%)',
|
|
6809
6860
|
borderRadius: '5px',
|
|
6861
|
+
width: '100%',
|
|
6810
6862
|
} }, Object.keys(paintProps).map(function (el) { return getFormInputByType(el); })))));
|
|
6811
6863
|
}
|
|
6812
6864
|
|
|
@@ -6942,15 +6994,18 @@ function LayerListItem(_a) {
|
|
|
6942
6994
|
setLayerState(__assign(__assign({}, layerComponent.props), { paint: paintProps }));
|
|
6943
6995
|
}, [paintProps, setLayerState]);
|
|
6944
6996
|
var _layerComponent = React.useMemo(function () {
|
|
6945
|
-
var _a
|
|
6997
|
+
var _a;
|
|
6946
6998
|
if (layerComponent && type === 'layer') {
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
|
|
6952
|
-
|
|
6953
|
-
|
|
6999
|
+
switch (layerComponent.type.displayName) {
|
|
7000
|
+
case 'MlWmsLayer':
|
|
7001
|
+
return React__default["default"].cloneElement(layerComponent, __assign(__assign({}, layerComponent === null || layerComponent === void 0 ? void 0 : layerComponent.props), { visible: _visible }));
|
|
7002
|
+
case 'MlVectorTileLayer':
|
|
7003
|
+
return React__default["default"].cloneElement(layerComponent, __assign(__assign({}, layerComponent === null || layerComponent === void 0 ? void 0 : layerComponent.props), { layers: (_a = layerComponent === null || layerComponent === void 0 ? void 0 : layerComponent.props) === null || _a === void 0 ? void 0 : _a.layers }));
|
|
7004
|
+
default:
|
|
7005
|
+
case 'MlGeoJsonLayer':
|
|
7006
|
+
return React__default["default"].cloneElement(layerComponent, __assign({ layout: {
|
|
7007
|
+
visibility: _visible ? 'visible' : 'none',
|
|
7008
|
+
} }, (setLayerState ? {} : { paint: paintProps })));
|
|
6954
7009
|
}
|
|
6955
7010
|
}
|
|
6956
7011
|
return React__default["default"].createElement(React__default["default"].Fragment, null);
|
|
@@ -6992,9 +7047,10 @@ LayerListItem.defaultProps = {
|
|
|
6992
7047
|
visible: true,
|
|
6993
7048
|
};
|
|
6994
7049
|
|
|
6995
|
-
var
|
|
6996
|
-
var
|
|
6997
|
-
var
|
|
7050
|
+
var ghPagesUrl = 'https://mapcomponents.github.io/react-map-components-maplibre/';
|
|
7051
|
+
var logoUrl = ghPagesUrl + 'assets/WG-MapComponents-Logo_rgb.svg';
|
|
7052
|
+
var logoUrl_dark = ghPagesUrl + 'assets/WG-MapComponents-Logo_rgb-weisse-schrift.svg';
|
|
7053
|
+
var logoUrl_mobile = ghPagesUrl + 'assets/mapcomponents_logo.png';
|
|
6998
7054
|
function TopToolbar(props) {
|
|
6999
7055
|
var theme = styles.useTheme();
|
|
7000
7056
|
var _a = React.useState(null), anchorElNav = _a[0], setAnchorElNav = _a[1];
|
|
@@ -7070,7 +7126,12 @@ function Sidebar(_a) {
|
|
|
7070
7126
|
var _b = React.useState(false), drawerOpen = _b[0], setDrawerOpen = _b[1];
|
|
7071
7127
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
7072
7128
|
!mediaIsMobile ? (React__default["default"].createElement(Box__default["default"], { sx: { display: { xs: 'none', sm: 'flex' }, mr: 1 } },
|
|
7073
|
-
React__default["default"].createElement(material.Drawer, __assign({ transitionDuration: 0, variant: "persistent", anchor: "left", open: typeof props.open === 'undefined' ? drawerOpen : props.open, PaperProps: __assign(__assign({}, drawerPaperProps), { sx: __assign({ maxWidth: { lg: '30%', md: '40%', sm: '50%', xs: '78%' }, padding: {
|
|
7129
|
+
React__default["default"].createElement(material.Drawer, __assign({ transitionDuration: 0, variant: "persistent", anchor: "left", open: typeof props.open === 'undefined' ? drawerOpen : props.open, PaperProps: __assign(__assign({}, drawerPaperProps), { sx: __assign({ maxWidth: { lg: '30%', md: '40%', sm: '50%', xs: '78%' }, padding: { sm: '84px 20px 20px 20px', xs: '74px 10px 10px 10px' }, width: {
|
|
7130
|
+
xs: '80%',
|
|
7131
|
+
sm: '60%',
|
|
7132
|
+
md: '350px',
|
|
7133
|
+
lg: '350px',
|
|
7134
|
+
}, boxSizing: 'border-box' }, drawerPaperProps === null || drawerPaperProps === void 0 ? void 0 : drawerPaperProps.sx) }), sx: __assign({ flexGrow: 1, zIndex: 105, position: 'absolute', bottom: 0, display: 'flex', flexDirection: 'column', maxWidth: { lg: '30%', md: '40%', sm: '50%', xs: '78%' } }, (drawerOpen ? {} : { left: mediaIsMobile ? '-90vw' : '-20vw' })) }, props),
|
|
7074
7135
|
React__default["default"].createElement(DrawerHeader, __assign({}, drawerHeaderProps),
|
|
7075
7136
|
React__default["default"].createElement(_.Typography, { variant: "h6" }, props.name),
|
|
7076
7137
|
React__default["default"].createElement(material.IconButton, { onClick: props.setOpen
|