@mapcomponents/react-maplibre 0.1.71 → 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 +10 -1
- package/dist/components/MapLibreMap/lib/MapLibreGlWrapper.d.ts +1 -0
- package/dist/components/MlSketchTool/LayerList/ColorPicker.d.ts +1 -1
- package/dist/index.esm.js +130 -66
- 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,7 +1,16 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
## [v0.1.
|
|
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
|
|
5
14
|
|
|
6
15
|
### Fixed
|
|
7
16
|
- e3178b5: fix Topbar sidebar defaults
|
|
@@ -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: {
|
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);
|
|
@@ -3332,7 +3340,7 @@ function useLayer(props) {
|
|
|
3332
3340
|
var layerId = React.useRef(props.layerId || (props.idPrefix ? props.idPrefix : 'Layer-') + mapHook.componentId);
|
|
3333
3341
|
var createLayer = React.useCallback(function () {
|
|
3334
3342
|
var _a, _b;
|
|
3335
|
-
if (!mapHook.map)
|
|
3343
|
+
if (!mapHook.map || (mapHook === null || mapHook === void 0 ? void 0 : mapHook.map.cancelled))
|
|
3336
3344
|
return;
|
|
3337
3345
|
if (mapHook.map.map.getLayer(layerId.current)) {
|
|
3338
3346
|
mapHook.cleanup();
|
|
@@ -3388,9 +3396,12 @@ function useLayer(props) {
|
|
|
3388
3396
|
layerTypeRef.current = props.options.type;
|
|
3389
3397
|
}, [props, mapHook.map]);
|
|
3390
3398
|
React.useEffect(function () {
|
|
3399
|
+
var _a, _b, _c, _d;
|
|
3391
3400
|
if (!mapHook.map)
|
|
3392
3401
|
return;
|
|
3393
|
-
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)) &&
|
|
3394
3405
|
(legalLayerTypes.indexOf(props.options.type) === -1 ||
|
|
3395
3406
|
(legalLayerTypes.indexOf(props.options.type) !== -1 &&
|
|
3396
3407
|
props.options.type === layerTypeRef.current))) {
|
|
@@ -3399,17 +3410,20 @@ function useLayer(props) {
|
|
|
3399
3410
|
createLayer();
|
|
3400
3411
|
}, [mapHook.map, props.options, createLayer]);
|
|
3401
3412
|
React.useEffect(function () {
|
|
3402
|
-
var _a, _b, _c, _d;
|
|
3403
|
-
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)))
|
|
3404
3417
|
return;
|
|
3405
3418
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3406
3419
|
//@ts-ignore setData only exists on GeoJsonSource
|
|
3407
|
-
(
|
|
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);
|
|
3408
3421
|
}, [props.geojson, mapHook.map, props.options.type]);
|
|
3409
3422
|
React.useEffect(function () {
|
|
3410
|
-
var _a, _b, _c, _d, _e;
|
|
3411
|
-
if (
|
|
3412
|
-
!
|
|
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)) ||
|
|
3413
3427
|
!initializedRef.current ||
|
|
3414
3428
|
props.options.type !== layerTypeRef.current)
|
|
3415
3429
|
return;
|
|
@@ -3418,7 +3432,7 @@ function useLayer(props) {
|
|
|
3418
3432
|
if (props.options.layout && layoutString !== layerLayoutConfRef.current) {
|
|
3419
3433
|
var oldLayout = JSON.parse(layerLayoutConfRef.current);
|
|
3420
3434
|
for (key in props.options.layout) {
|
|
3421
|
-
if (((
|
|
3435
|
+
if (((_e = props.options.layout) === null || _e === void 0 ? void 0 : _e[key]) && props.options.layout[key] !== oldLayout[key]) {
|
|
3422
3436
|
mapHook.map.map.setLayoutProperty(layerId.current, key, props.options.layout[key]);
|
|
3423
3437
|
}
|
|
3424
3438
|
}
|
|
@@ -3428,7 +3442,7 @@ function useLayer(props) {
|
|
|
3428
3442
|
if (paintString !== layerPaintConfRef.current) {
|
|
3429
3443
|
var oldPaint = JSON.parse(layerPaintConfRef.current);
|
|
3430
3444
|
for (key in props.options.paint) {
|
|
3431
|
-
if (((
|
|
3445
|
+
if (((_f = props.options.paint) === null || _f === void 0 ? void 0 : _f[key]) && props.options.paint[key] !== oldPaint[key]) {
|
|
3432
3446
|
mapHook.map.map.setPaintProperty(layerId.current, key, props.options.paint[key]);
|
|
3433
3447
|
}
|
|
3434
3448
|
}
|
|
@@ -3495,6 +3509,7 @@ var getDefaultPaintPropsByType = function (type, defaultPaintOverrides) {
|
|
|
3495
3509
|
}
|
|
3496
3510
|
return {
|
|
3497
3511
|
'fill-color': 'rgba(10,240,256,0.6)',
|
|
3512
|
+
'fill-outline-color': 'rgba(20,230,256,0.8)',
|
|
3498
3513
|
};
|
|
3499
3514
|
case 'line':
|
|
3500
3515
|
if (defaultPaintOverrides === null || defaultPaintOverrides === void 0 ? void 0 : defaultPaintOverrides.line) {
|
|
@@ -3514,6 +3529,7 @@ var getDefaultPaintPropsByType = function (type, defaultPaintOverrides) {
|
|
|
3514
3529
|
'circle-color': 'rgba(10,240,256,0.8)',
|
|
3515
3530
|
'circle-stroke-color': '#fff',
|
|
3516
3531
|
'circle-stroke-width': 2,
|
|
3532
|
+
'circle-radius': 4,
|
|
3517
3533
|
};
|
|
3518
3534
|
}
|
|
3519
3535
|
};
|
|
@@ -3919,21 +3935,21 @@ var MlNavigationTools = function (props) {
|
|
|
3919
3935
|
}, mapHook.componentId);
|
|
3920
3936
|
setPitch(mapHook.map.map.getPitch());
|
|
3921
3937
|
}, [mapHook.map, props.mapId]);
|
|
3922
|
-
var zoomIn = function () {
|
|
3938
|
+
var zoomIn = React.useCallback(function () {
|
|
3923
3939
|
if (!mapHook.map)
|
|
3924
3940
|
return;
|
|
3925
3941
|
if (mapHook.map.map.transform._zoom + 0.5 <= mapHook.map.map.transform._maxZoom) {
|
|
3926
3942
|
mapHook.map.map.easeTo({ zoom: mapHook.map.map.transform._zoom + 0.5 });
|
|
3927
3943
|
}
|
|
3928
|
-
};
|
|
3929
|
-
var zoomOut = function () {
|
|
3944
|
+
}, [mapHook.map]);
|
|
3945
|
+
var zoomOut = React.useCallback(function () {
|
|
3930
3946
|
if (!mapHook.map)
|
|
3931
3947
|
return;
|
|
3932
3948
|
if (mapHook.map.map.transform._zoom - 0.5 >= mapHook.map.map.transform._minZoom) {
|
|
3933
3949
|
mapHook.map.map.easeTo({ zoom: mapHook.map.map.transform._zoom - 0.5 });
|
|
3934
3950
|
}
|
|
3935
|
-
};
|
|
3936
|
-
var adjustPitch = function () {
|
|
3951
|
+
}, [mapHook.map]);
|
|
3952
|
+
var adjustPitch = React.useCallback(function () {
|
|
3937
3953
|
if (!mapHook.map)
|
|
3938
3954
|
return;
|
|
3939
3955
|
var targetPitch = 60;
|
|
@@ -3941,7 +3957,7 @@ var MlNavigationTools = function (props) {
|
|
|
3941
3957
|
targetPitch = 0;
|
|
3942
3958
|
}
|
|
3943
3959
|
mapHook.map.map.easeTo({ pitch: targetPitch });
|
|
3944
|
-
};
|
|
3960
|
+
}, [mapHook.map]);
|
|
3945
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) },
|
|
3946
3962
|
React__default["default"].createElement(MlNavigationCompass, { style: {
|
|
3947
3963
|
width: '31px',
|
|
@@ -6322,17 +6338,17 @@ var MlWmsLoader = function (props) {
|
|
|
6322
6338
|
};
|
|
6323
6339
|
}, [getFeatureInfo]);
|
|
6324
6340
|
React.useEffect(function () {
|
|
6325
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
6341
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
6326
6342
|
if (!(capabilities === null || capabilities === void 0 ? void 0 : capabilities.Service))
|
|
6327
6343
|
return;
|
|
6328
|
-
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) {
|
|
6329
6345
|
console.log('MlWmsLoader (' + capabilities.Service.Title + '): No WGS 84/Pseudo-Mercator support');
|
|
6330
6346
|
}
|
|
6331
6347
|
else {
|
|
6332
6348
|
console.log('MlWmsLoader (' + capabilities.Service.Title + '): WGS 84/Pseudo-Mercator supported');
|
|
6333
6349
|
var _LatLonBoundingBox_1 = [];
|
|
6334
6350
|
// collect aueriable Layer2 layers
|
|
6335
|
-
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) {
|
|
6336
6352
|
var _a, _b, _c;
|
|
6337
6353
|
if (idx === 0) {
|
|
6338
6354
|
_LatLonBoundingBox_1 = layer.EX_GeographicBoundingBox;
|
|
@@ -6340,7 +6356,7 @@ var MlWmsLoader = function (props) {
|
|
|
6340
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);
|
|
6341
6357
|
});
|
|
6342
6358
|
// collect aueriable Layer3 layers
|
|
6343
|
-
(
|
|
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) {
|
|
6344
6360
|
var _a;
|
|
6345
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) {
|
|
6346
6362
|
if (idx === 0) {
|
|
@@ -6710,37 +6726,81 @@ function LayerList(_a) {
|
|
|
6710
6726
|
return React__default["default"].createElement(material.List, { sx: { marginTop: '15px' } }, children);
|
|
6711
6727
|
}
|
|
6712
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
|
+
|
|
6713
6770
|
function PaintPropsColorPicker(_a) {
|
|
6714
6771
|
var propKey = _a.propKey, value = _a.value, setPaintProps = _a.setPaintProps;
|
|
6715
|
-
return (React__default["default"].createElement(
|
|
6772
|
+
return (React__default["default"].createElement(ColorPicker, { value: value, label: "Color", onChange: function (value) {
|
|
6716
6773
|
setPaintProps(function (current) {
|
|
6717
6774
|
var _a;
|
|
6718
|
-
var
|
|
6719
|
-
if (!((_b = value === null || value === void 0 ? void 0 : value.rgb) === null || _b === void 0 ? void 0 : _b[0])) {
|
|
6720
|
-
return current;
|
|
6721
|
-
}
|
|
6722
|
-
var newProps = __assign(__assign({}, current), (_a = {}, _a[propKey] = 'rgba(' +
|
|
6723
|
-
value.rgb[0] +
|
|
6724
|
-
',' +
|
|
6725
|
-
value.rgb[1] +
|
|
6726
|
-
',' +
|
|
6727
|
-
value.rgb[2] +
|
|
6728
|
-
',' +
|
|
6729
|
-
value.alpha +
|
|
6730
|
-
')', _a));
|
|
6775
|
+
var newProps = __assign(__assign({}, current), (_a = {}, _a[propKey] = value, _a));
|
|
6731
6776
|
return newProps;
|
|
6732
6777
|
});
|
|
6733
6778
|
} }));
|
|
6734
6779
|
}
|
|
6735
6780
|
|
|
6736
6781
|
var mapPropKeyToFormInputType = {
|
|
6782
|
+
'circle-color': 'colorpicker',
|
|
6783
|
+
'circle-radius': 'slider',
|
|
6784
|
+
'circle-stroke-color': 'colorpicker',
|
|
6785
|
+
'circle-stroke-width': 'slider',
|
|
6737
6786
|
'fill-color': 'colorpicker',
|
|
6787
|
+
'fill-outline-color': 'colorpicker',
|
|
6738
6788
|
'line-color': 'colorpicker',
|
|
6739
6789
|
'line-width': 'slider',
|
|
6740
6790
|
'line-blur': 'slider',
|
|
6741
6791
|
};
|
|
6742
6792
|
var mapPropKeyToFormInputTypeKeys = Object.keys(mapPropKeyToFormInputType);
|
|
6743
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
|
+
},
|
|
6744
6804
|
'line-blur': {
|
|
6745
6805
|
step: 1,
|
|
6746
6806
|
min: 1,
|
|
@@ -6763,7 +6823,7 @@ function LayerPropertyForm(_a) {
|
|
|
6763
6823
|
case 'slider':
|
|
6764
6824
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
6765
6825
|
label,
|
|
6766
|
-
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) {
|
|
6767
6827
|
if (value) {
|
|
6768
6828
|
setPaintProps(function (current) {
|
|
6769
6829
|
var _a;
|
|
@@ -6798,6 +6858,7 @@ function LayerPropertyForm(_a) {
|
|
|
6798
6858
|
padding: '15px',
|
|
6799
6859
|
boxShadow: 'inset 0px 0px 10px rgb(50 50 50 / 10%)',
|
|
6800
6860
|
borderRadius: '5px',
|
|
6861
|
+
width: '100%',
|
|
6801
6862
|
} }, Object.keys(paintProps).map(function (el) { return getFormInputByType(el); })))));
|
|
6802
6863
|
}
|
|
6803
6864
|
|
|
@@ -6933,15 +6994,18 @@ function LayerListItem(_a) {
|
|
|
6933
6994
|
setLayerState(__assign(__assign({}, layerComponent.props), { paint: paintProps }));
|
|
6934
6995
|
}, [paintProps, setLayerState]);
|
|
6935
6996
|
var _layerComponent = React.useMemo(function () {
|
|
6936
|
-
var _a
|
|
6997
|
+
var _a;
|
|
6937
6998
|
if (layerComponent && type === 'layer') {
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
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 })));
|
|
6945
7009
|
}
|
|
6946
7010
|
}
|
|
6947
7011
|
return React__default["default"].createElement(React__default["default"].Fragment, null);
|
|
@@ -7062,7 +7126,7 @@ function Sidebar(_a) {
|
|
|
7062
7126
|
var _b = React.useState(false), drawerOpen = _b[0], setDrawerOpen = _b[1];
|
|
7063
7127
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
7064
7128
|
!mediaIsMobile ? (React__default["default"].createElement(Box__default["default"], { sx: { display: { xs: 'none', sm: 'flex' }, mr: 1 } },
|
|
7065
|
-
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: {
|
|
7066
7130
|
xs: '80%',
|
|
7067
7131
|
sm: '60%',
|
|
7068
7132
|
md: '350px',
|