@mapcomponents/react-maplibre 0.1.31 → 0.1.32
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 +4 -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 +261 -1
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- 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/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.meta.json +1 -1
- package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.doc.de.md +1 -3
- package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.meta.json +1 -1
- package/src/components/MlFollowGps/MlFollowGps.doc.de.md +1 -3
- package/src/components/MlGPXViewer/MlGPXViewer.doc.de.md +1 -3
- package/src/components/MlGPXViewer/MlGPXViewer.meta.json +1 -1
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.doc.de.md +1 -3
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.meta.json +1 -1
- package/src/components/MlLayerMagnify/MlLayerMagnify.doc.de.md +1 -3
- package/src/components/MlLayerSwipe/MlLayerSwipe.doc.de.md +1 -3
- package/src/components/MlNavigationCompass/MlNavigationCompass.doc.de.md +1 -3
- package/src/components/MlNavigationTools/MlNavigationTools.doc.de.md +1 -3
- package/src/components/MlScaleReference/MlScaleReference.doc.de.md +1 -3
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.doc.de.md +1 -4
- package/src/components/MlThreeJsLayer/MlThreeJsLayer.doc.de.md +1 -3
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.doc.de.md +1 -3
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.meta.json +1 -1
- package/src/components/MlWmsLoader/MlWmsLoader.doc.de.md +1 -3
- package/src/components/MlWmsLoader/MlWmsLoader.meta.json +1 -1
- package/src/index.js +2 -0
|
@@ -964,7 +964,7 @@ export default MlWmsLoader;
|
|
|
964
964
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
965
965
|
Code coverage generated by
|
|
966
966
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
967
|
-
at
|
|
967
|
+
at Tue Mar 15 2022 11:25:03 GMT+0000 (Coordinated Universal Time)
|
|
968
968
|
</div>
|
|
969
969
|
<script src="../../../prettify.js"></script>
|
|
970
970
|
<script>
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
102
102
|
Code coverage generated by
|
|
103
103
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
104
|
-
at
|
|
104
|
+
at Tue Mar 15 2022 11:25:03 GMT+0000 (Coordinated Universal Time)
|
|
105
105
|
</div>
|
|
106
106
|
<script src="../../../prettify.js"></script>
|
|
107
107
|
<script>
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
132
132
|
Code coverage generated by
|
|
133
133
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
134
|
-
at
|
|
134
|
+
at Tue Mar 15 2022 11:25:03 GMT+0000 (Coordinated Universal Time)
|
|
135
135
|
</div>
|
|
136
136
|
<script src="../../prettify.js"></script>
|
|
137
137
|
<script>
|
|
@@ -292,7 +292,7 @@ export default useMap;
|
|
|
292
292
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
293
293
|
Code coverage generated by
|
|
294
294
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
295
|
-
at
|
|
295
|
+
at Tue Mar 15 2022 11:25:03 GMT+0000 (Coordinated Universal Time)
|
|
296
296
|
</div>
|
|
297
297
|
<script src="../../prettify.js"></script>
|
|
298
298
|
<script>
|
|
@@ -532,7 +532,7 @@ export default useMapState;
|
|
|
532
532
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
533
533
|
Code coverage generated by
|
|
534
534
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
535
|
-
at
|
|
535
|
+
at Tue Mar 15 2022 11:25:03 GMT+0000 (Coordinated Universal Time)
|
|
536
536
|
</div>
|
|
537
537
|
<script src="../../prettify.js"></script>
|
|
538
538
|
<script>
|
|
@@ -343,7 +343,7 @@ export default useWms;
|
|
|
343
343
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
344
344
|
Code coverage generated by
|
|
345
345
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
346
|
-
at
|
|
346
|
+
at Tue Mar 15 2022 11:25:03 GMT+0000 (Coordinated Universal Time)
|
|
347
347
|
</div>
|
|
348
348
|
<script src="../../prettify.js"></script>
|
|
349
349
|
<script>
|
|
@@ -151,7 +151,7 @@ export default i18n;</pre></td></tr></table></pre>
|
|
|
151
151
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
152
152
|
Code coverage generated by
|
|
153
153
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
154
|
-
at
|
|
154
|
+
at Tue Mar 15 2022 11:25:03 GMT+0000 (Coordinated Universal Time)
|
|
155
155
|
</div>
|
|
156
156
|
<script src="../prettify.js"></script>
|
|
157
157
|
<script>
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
102
102
|
Code coverage generated by
|
|
103
103
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
104
|
-
at
|
|
104
|
+
at Tue Mar 15 2022 11:25:03 GMT+0000 (Coordinated Universal Time)
|
|
105
105
|
</div>
|
|
106
106
|
<script src="../prettify.js"></script>
|
|
107
107
|
<script>
|
|
@@ -79,7 +79,7 @@ export default english;</pre></td></tr></table></pre>
|
|
|
79
79
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
80
80
|
Code coverage generated by
|
|
81
81
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
82
|
-
at
|
|
82
|
+
at Tue Mar 15 2022 11:25:03 GMT+0000 (Coordinated Universal Time)
|
|
83
83
|
</div>
|
|
84
84
|
<script src="../../prettify.js"></script>
|
|
85
85
|
<script>
|
|
@@ -79,7 +79,7 @@ export default german;</pre></td></tr></table></pre>
|
|
|
79
79
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
80
80
|
Code coverage generated by
|
|
81
81
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
82
|
-
at
|
|
82
|
+
at Tue Mar 15 2022 11:25:03 GMT+0000 (Coordinated Universal Time)
|
|
83
83
|
</div>
|
|
84
84
|
<script src="../../prettify.js"></script>
|
|
85
85
|
<script>
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
117
117
|
Code coverage generated by
|
|
118
118
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
119
|
-
at
|
|
119
|
+
at Tue Mar 15 2022 11:25:03 GMT+0000 (Coordinated Universal Time)
|
|
120
120
|
</div>
|
|
121
121
|
<script src="../../prettify.js"></script>
|
|
122
122
|
<script>
|
package/dist/index.esm.js
CHANGED
|
@@ -31,6 +31,8 @@ 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
37
|
function ownKeys(object, enumerableOnly) {
|
|
36
38
|
var keys = Object.keys(object);
|
|
@@ -5856,5 +5858,263 @@ MlTransitionGeoJsonLayer.propTypes = {
|
|
|
5856
5858
|
transitionTime: PropTypes.number
|
|
5857
5859
|
};
|
|
5858
5860
|
|
|
5859
|
-
|
|
5861
|
+
/**
|
|
5862
|
+
* Adds a marker to the map and displays a marker description next to it
|
|
5863
|
+
*
|
|
5864
|
+
* @param {object} props
|
|
5865
|
+
* @param {string} props.mapId Id of the target MapLibre instance in mapContext
|
|
5866
|
+
* @param {number} props.lng
|
|
5867
|
+
* @param {number} props.lat
|
|
5868
|
+
* @param {string} props.content
|
|
5869
|
+
*
|
|
5870
|
+
* @component
|
|
5871
|
+
*/
|
|
5872
|
+
|
|
5873
|
+
var MlMarker = function MlMarker(props) {
|
|
5874
|
+
var mapContext = useContext(MapContext);
|
|
5875
|
+
var mapState = useMapState({
|
|
5876
|
+
mapId: props.mapId,
|
|
5877
|
+
watch: {
|
|
5878
|
+
viewport: true
|
|
5879
|
+
}
|
|
5880
|
+
});
|
|
5881
|
+
var iframe = useRef(undefined);
|
|
5882
|
+
var initializedRef = useRef(false);
|
|
5883
|
+
var mapRef = useRef(undefined);
|
|
5884
|
+
var componentId = useRef((props.idPrefix ? props.idPrefix : "MlMarker-") + v4());
|
|
5885
|
+
|
|
5886
|
+
var _useState = useState({
|
|
5887
|
+
width: "400px",
|
|
5888
|
+
height: "500px"
|
|
5889
|
+
}),
|
|
5890
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
5891
|
+
iframeDimensions = _useState2[0],
|
|
5892
|
+
setIframeDimensions = _useState2[1];
|
|
5893
|
+
|
|
5894
|
+
var _useState3 = useState(undefined),
|
|
5895
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
5896
|
+
markerPixelPos = _useState4[0],
|
|
5897
|
+
setMarkerPixelPos = _useState4[1];
|
|
5898
|
+
|
|
5899
|
+
useEffect(function () {
|
|
5900
|
+
var _componentId = componentId.current;
|
|
5901
|
+
return function () {
|
|
5902
|
+
// This is the cleanup function, it is called when this react component is removed from react-dom
|
|
5903
|
+
// try to remove anything this component has added to the MapLibre-gl instance
|
|
5904
|
+
// e.g.: remove the layer
|
|
5905
|
+
// mapContext.getMap(props.mapId).removeLayer(layerRef.current);
|
|
5906
|
+
// check for the existence of map.style before calling getLayer or getSource
|
|
5907
|
+
if (mapRef.current) {
|
|
5908
|
+
mapRef.current.cleanup(_componentId);
|
|
5909
|
+
mapRef.current = undefined;
|
|
5910
|
+
}
|
|
5911
|
+
|
|
5912
|
+
initializedRef.current = false;
|
|
5913
|
+
};
|
|
5914
|
+
}, []);
|
|
5915
|
+
useEffect(function () {
|
|
5916
|
+
if (!mapContext.mapExists(props.mapId) || initializedRef.current) return; // the MapLibre-gl instance (mapContext.getMap(props.mapId)) is accessible here
|
|
5917
|
+
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
5918
|
+
|
|
5919
|
+
initializedRef.current = true;
|
|
5920
|
+
mapRef.current = mapContext.getMap(props.mapId);
|
|
5921
|
+
}, [mapContext.mapIds, mapContext, props.mapId]);
|
|
5922
|
+
useEffect(function () {
|
|
5923
|
+
var _mapRef$current;
|
|
5924
|
+
|
|
5925
|
+
if (!((_mapRef$current = mapRef.current) !== null && _mapRef$current !== void 0 && _mapRef$current.project)) return;
|
|
5926
|
+
|
|
5927
|
+
var _pixelPos = mapRef.current.project([props.lng, props.lat]);
|
|
5928
|
+
|
|
5929
|
+
setMarkerPixelPos(_pixelPos);
|
|
5930
|
+
}, [props.lng, props.lat, mapState.viewport]);
|
|
5931
|
+
useEffect(function () {
|
|
5932
|
+
var _iframe$current, _iframe$current$conte, _iframe$current$conte2, _iframe$current$conte3;
|
|
5933
|
+
|
|
5934
|
+
if (mapRef.current && (_iframe$current = iframe.current) !== null && _iframe$current !== void 0 && (_iframe$current$conte = _iframe$current.contentWindow) !== null && _iframe$current$conte !== void 0 && (_iframe$current$conte2 = _iframe$current$conte.document) !== null && _iframe$current$conte2 !== void 0 && (_iframe$current$conte3 = _iframe$current$conte2.body) !== null && _iframe$current$conte3 !== void 0 && _iframe$current$conte3.scrollHeight) {
|
|
5935
|
+
setTimeout(function () {
|
|
5936
|
+
var _iframe$current2, _iframe$current2$cont, _iframe$current2$cont2, _iframe$current2$cont3, _iframe$current3, _iframe$current3$cont, _iframe$current3$cont2, _iframe$current3$cont3;
|
|
5937
|
+
|
|
5938
|
+
var mapHeight = mapRef.current._container.clientHeight;
|
|
5939
|
+
|
|
5940
|
+
var _pixelPos = mapRef.current.project([props.lng, props.lat]);
|
|
5941
|
+
|
|
5942
|
+
var pixelToBottom = mapHeight - _pixelPos.y;
|
|
5943
|
+
var 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;
|
|
5944
|
+
var iframeWidth = (_iframe$current3 = iframe.current) === null || _iframe$current3 === void 0 ? void 0 : (_iframe$current3$cont = _iframe$current3.contentWindow) === null || _iframe$current3$cont === void 0 ? void 0 : (_iframe$current3$cont2 = _iframe$current3$cont.document) === null || _iframe$current3$cont2 === void 0 ? void 0 : (_iframe$current3$cont3 = _iframe$current3$cont2.body) === null || _iframe$current3$cont3 === void 0 ? void 0 : _iframe$current3$cont3.scrollWidth;
|
|
5945
|
+
setIframeDimensions({
|
|
5946
|
+
width: iframeWidth,
|
|
5947
|
+
height: pixelToBottom < iframeHeight ? pixelToBottom : iframeHeight
|
|
5948
|
+
});
|
|
5949
|
+
}, 100);
|
|
5950
|
+
}
|
|
5951
|
+
}, [props.lng, props.lat, props.content]);
|
|
5952
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(MlGeoJsonLayer, {
|
|
5953
|
+
geojson: {
|
|
5954
|
+
type: "Feature",
|
|
5955
|
+
geometry: {
|
|
5956
|
+
type: "Point",
|
|
5957
|
+
coordinates: [props.lng, props.lat]
|
|
5958
|
+
},
|
|
5959
|
+
properties: {}
|
|
5960
|
+
},
|
|
5961
|
+
paint: {
|
|
5962
|
+
"circle-radius": 14,
|
|
5963
|
+
"circle-color": "rgba(40,200,20,0.5)"
|
|
5964
|
+
},
|
|
5965
|
+
type: "circle",
|
|
5966
|
+
mapId: props.mapId
|
|
5967
|
+
}), markerPixelPos && /*#__PURE__*/React__default.createElement(Paper, {
|
|
5968
|
+
sx: {
|
|
5969
|
+
opacity: 0.7,
|
|
5970
|
+
position: "fixed",
|
|
5971
|
+
display: "flex",
|
|
5972
|
+
|
|
5973
|
+
/** TODO: fix positioning delay when moving the map */
|
|
5974
|
+
left: markerPixelPos.x,
|
|
5975
|
+
top: markerPixelPos.y,
|
|
5976
|
+
width: iframeDimensions.width,
|
|
5977
|
+
height: iframeDimensions.height,
|
|
5978
|
+
"&:hover": {
|
|
5979
|
+
opacity: 1
|
|
5980
|
+
},
|
|
5981
|
+
zIndex: -1
|
|
5982
|
+
}
|
|
5983
|
+
}, /*#__PURE__*/React__default.createElement("iframe", {
|
|
5984
|
+
style: {
|
|
5985
|
+
width: "100%"
|
|
5986
|
+
},
|
|
5987
|
+
srcDoc: props.content,
|
|
5988
|
+
ref: iframe,
|
|
5989
|
+
sandbox: "allow-same-origin allow-popups-to-escape-sandbox",
|
|
5990
|
+
frameBorder: "0",
|
|
5991
|
+
title: componentId.current
|
|
5992
|
+
})));
|
|
5993
|
+
};
|
|
5994
|
+
|
|
5995
|
+
MlMarker.defaultProps = {
|
|
5996
|
+
mapId: undefined
|
|
5997
|
+
};
|
|
5998
|
+
MlMarker.propTypes = {
|
|
5999
|
+
/**
|
|
6000
|
+
* Id of the target MapLibre instance in mapContext
|
|
6001
|
+
*/
|
|
6002
|
+
mapId: PropTypes.string,
|
|
6003
|
+
|
|
6004
|
+
/**
|
|
6005
|
+
* Longitude of the marker position
|
|
6006
|
+
*/
|
|
6007
|
+
lng: PropTypes.number,
|
|
6008
|
+
|
|
6009
|
+
/**
|
|
6010
|
+
* Latitude of the marker position
|
|
6011
|
+
*/
|
|
6012
|
+
lat: PropTypes.number,
|
|
6013
|
+
|
|
6014
|
+
/**
|
|
6015
|
+
* Content of the description popup
|
|
6016
|
+
*/
|
|
6017
|
+
content: PropTypes.string
|
|
6018
|
+
};
|
|
6019
|
+
|
|
6020
|
+
function useWms(props) {
|
|
6021
|
+
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
6022
|
+
var _useState = useState(undefined),
|
|
6023
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
6024
|
+
getFeatureInfoUrl = _useState2[0],
|
|
6025
|
+
setGetFeatureInfoUrl = _useState2[1];
|
|
6026
|
+
|
|
6027
|
+
var _useState3 = useState(props.url),
|
|
6028
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
6029
|
+
url = _useState4[0],
|
|
6030
|
+
setUrl = _useState4[1];
|
|
6031
|
+
|
|
6032
|
+
var _useState5 = useState(""),
|
|
6033
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
6034
|
+
wmsUrl = _useState6[0],
|
|
6035
|
+
setWmsUrl = _useState6[1];
|
|
6036
|
+
|
|
6037
|
+
var _useState7 = useState(undefined),
|
|
6038
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
6039
|
+
capabilities = _useState8[0],
|
|
6040
|
+
setCapabilities = _useState8[1];
|
|
6041
|
+
|
|
6042
|
+
var _useState9 = useState(undefined),
|
|
6043
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
6044
|
+
error = _useState10[0],
|
|
6045
|
+
setError = _useState10[1];
|
|
6046
|
+
|
|
6047
|
+
var clearState = function clearState() {
|
|
6048
|
+
setGetFeatureInfoUrl(undefined);
|
|
6049
|
+
setCapabilities(undefined); //setLayers([]);
|
|
6050
|
+
|
|
6051
|
+
setWmsUrl("");
|
|
6052
|
+
};
|
|
6053
|
+
|
|
6054
|
+
useEffect(function () {
|
|
6055
|
+
var _propsUrlParams2;
|
|
6056
|
+
|
|
6057
|
+
// extract URL parameters from the given URL
|
|
6058
|
+
clearState();
|
|
6059
|
+
setError(undefined);
|
|
6060
|
+
if (!url) return;
|
|
6061
|
+
|
|
6062
|
+
var _propsUrlParams;
|
|
6063
|
+
|
|
6064
|
+
var _wmsUrl = url;
|
|
6065
|
+
|
|
6066
|
+
if (url.indexOf("?") !== -1) {
|
|
6067
|
+
_propsUrlParams = url.split("?");
|
|
6068
|
+
_wmsUrl = _propsUrlParams[0];
|
|
6069
|
+
}
|
|
6070
|
+
|
|
6071
|
+
var _urlParamsFromUrl = new URLSearchParams((_propsUrlParams2 = _propsUrlParams) === null || _propsUrlParams2 === void 0 ? void 0 : _propsUrlParams2[1]);
|
|
6072
|
+
|
|
6073
|
+
var urlParamsObj = _objectSpread2(_objectSpread2({}, Object.fromEntries(_urlParamsFromUrl)), props.urlParameters); // create URLSearchParams object to assemble the URL Parameters
|
|
6074
|
+
|
|
6075
|
+
|
|
6076
|
+
var urlParams = new URLSearchParams(urlParamsObj);
|
|
6077
|
+
var urlParamsStr = decodeURIComponent(urlParams.toString()) + "".replace(/%2F/g, "/").replace(/%3A/g, ":");
|
|
6078
|
+
fetch(_wmsUrl + "?" + urlParamsStr).then(function (res) {
|
|
6079
|
+
if (!res.ok) {
|
|
6080
|
+
throw Error(res.statusText + " (" + res.status + " - " + res.type + ")");
|
|
6081
|
+
} else {
|
|
6082
|
+
return res.text();
|
|
6083
|
+
}
|
|
6084
|
+
}).then(function (data) {
|
|
6085
|
+
setCapabilities(new WMSCapabilities(data).toJSON());
|
|
6086
|
+
}).catch(function (error) {
|
|
6087
|
+
//reset local state
|
|
6088
|
+
clearState();
|
|
6089
|
+
console.log(error);
|
|
6090
|
+
setError(error.message);
|
|
6091
|
+
});
|
|
6092
|
+
}, [url, props.urlParameters]);
|
|
6093
|
+
useEffect(function () {
|
|
6094
|
+
var _capabilities$Capabil, _capabilities$Capabil2, _capabilities$Capabil3, _capabilities$Capabil4, _capabilities$Capabil5, _capabilities$Capabil6, _capabilities$Capabil7, _capabilities$Capabil8, _capabilities$Capabil9, _capabilities$Capabil10, _capabilities$Capabil11, _capabilities$Capabil12, _capabilities$Capabil13, _capabilities$Capabil14;
|
|
6095
|
+
|
|
6096
|
+
if (!(capabilities !== null && capabilities !== void 0 && capabilities.Service)) return;
|
|
6097
|
+
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
|
|
6098
|
+
|
|
6099
|
+
setGetFeatureInfoUrl((_capabilities$Capabil8 = capabilities.Capability) === null || _capabilities$Capabil8 === void 0 ? void 0 : (_capabilities$Capabil9 = _capabilities$Capabil8.Request) === null || _capabilities$Capabil9 === void 0 ? void 0 : (_capabilities$Capabil10 = _capabilities$Capabil9.GetFeatureInfo) === null || _capabilities$Capabil10 === void 0 ? void 0 : (_capabilities$Capabil11 = _capabilities$Capabil10.DCPType) === null || _capabilities$Capabil11 === void 0 ? void 0 : (_capabilities$Capabil12 = _capabilities$Capabil11[0]) === null || _capabilities$Capabil12 === void 0 ? void 0 : (_capabilities$Capabil13 = _capabilities$Capabil12.HTTP) === null || _capabilities$Capabil13 === void 0 ? void 0 : (_capabilities$Capabil14 = _capabilities$Capabil13.Get) === null || _capabilities$Capabil14 === void 0 ? void 0 : _capabilities$Capabil14.OnlineResource);
|
|
6100
|
+
}, [capabilities]);
|
|
6101
|
+
return {
|
|
6102
|
+
capabilities: capabilities,
|
|
6103
|
+
getFeatureInfoUrl: getFeatureInfoUrl,
|
|
6104
|
+
wmsUrl: wmsUrl,
|
|
6105
|
+
error: error,
|
|
6106
|
+
setUrl: setUrl
|
|
6107
|
+
};
|
|
6108
|
+
}
|
|
6109
|
+
|
|
6110
|
+
useWms.defaultProps = {
|
|
6111
|
+
url: "",
|
|
6112
|
+
urlParameters: {
|
|
6113
|
+
SERVICE: "WMS",
|
|
6114
|
+
VERSION: "1.3.0",
|
|
6115
|
+
REQUEST: "getCapabilities"
|
|
6116
|
+
}
|
|
6117
|
+
};
|
|
6118
|
+
|
|
6119
|
+
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
6120
|
//# sourceMappingURL=index.esm.js.map
|