@mapcomponents/react-maplibre 0.1.22 → 0.1.26
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 +48 -8
- package/coverage/clover.xml +109 -134
- package/coverage/coverage-final.json +6 -6
- package/coverage/lcov-report/index.html +27 -27
- 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 +43 -94
- package/coverage/lcov-report/src/components/MlFollowGps/index.html +18 -18
- 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 +2 -2
- 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/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 +72 -195
- package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +17 -17
- 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 +22 -22
- package/coverage/lcov-report/src/hooks/useMapState.js.html +34 -34
- package/coverage/lcov-report/src/hooks/useWms.js.html +2 -2
- 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/coverage/lcov.info +178 -225
- package/dist/index.esm.js +108 -160
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/MlFollowGps/MlFollowGps.js +29 -46
- package/src/components/MlFollowGps/MlFollowGps.test.js +1 -1
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.js +50 -91
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.test.js +6 -6
- package/src/hooks/useWms.js +1 -1
- package/dist/b556faa3bc6829d2.png +0 -0
- package/src/components/MlFollowGps/assets/marker.png +0 -0
package/dist/index.esm.js
CHANGED
|
@@ -1651,66 +1651,6 @@ MlGeoJsonLayer.propTypes = {
|
|
|
1651
1651
|
transitionTime: PropTypes.number
|
|
1652
1652
|
};
|
|
1653
1653
|
|
|
1654
|
-
var MlImageMarkerLayer = function MlImageMarkerLayer(props) {
|
|
1655
|
-
var mapHook = useMap({
|
|
1656
|
-
mapId: props.mapId,
|
|
1657
|
-
waitForLayer: props.insertBeforeLayer
|
|
1658
|
-
});
|
|
1659
|
-
var layerInitializedRef = useRef(false);
|
|
1660
|
-
var imageIdRef = useRef(props.imageId || "img_" + new Date().getTime());
|
|
1661
|
-
var layerId = useRef(props.layerId || "MlImageMarkerLayer-" + mapHook.componentId);
|
|
1662
|
-
useEffect(function () {
|
|
1663
|
-
if (!mapHook.mapIsReady || mapHook.map && !mapHook.map.getLayer(layerId.current) || !props.options) return; // the MapLibre-gl instance (mapContext.map) is accessible here
|
|
1664
|
-
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
1665
|
-
|
|
1666
|
-
var key;
|
|
1667
|
-
|
|
1668
|
-
if (props.options.layout) {
|
|
1669
|
-
for (key in props.options.layout) {
|
|
1670
|
-
mapHook.map.setLayoutProperty(layerId.current, key, props.options.layout[key]);
|
|
1671
|
-
}
|
|
1672
|
-
}
|
|
1673
|
-
|
|
1674
|
-
if (props.options.paint) {
|
|
1675
|
-
for (key in props.options.paint) {
|
|
1676
|
-
mapHook.map.setPaintProperty(layerId.current, key, props.options.paint[key]);
|
|
1677
|
-
}
|
|
1678
|
-
}
|
|
1679
|
-
}, [props.options, layerId.current, props.mapId]);
|
|
1680
|
-
var addLayer = useCallback(function () {
|
|
1681
|
-
var tmpOptions = _objectSpread2({
|
|
1682
|
-
id: layerId.current,
|
|
1683
|
-
layout: {}
|
|
1684
|
-
}, props.options);
|
|
1685
|
-
|
|
1686
|
-
tmpOptions.layout["icon-image"] = imageIdRef.current;
|
|
1687
|
-
mapHook.map.addLayer(tmpOptions, props.insertBeforeLayer, mapHook.componentId);
|
|
1688
|
-
}, [props, mapHook.mapIsReady, mapHook.map]);
|
|
1689
|
-
useEffect(function () {
|
|
1690
|
-
if (!props.options || !mapHook.mapIsReady || layerInitializedRef.current) return;
|
|
1691
|
-
layerInitializedRef.current = true;
|
|
1692
|
-
|
|
1693
|
-
if (props.imgSrc) {
|
|
1694
|
-
mapHook.map.loadImage(props.imgSrc, function (error, image) {
|
|
1695
|
-
if (error) throw error;
|
|
1696
|
-
mapHook.map.addImage(imageIdRef.current, image, mapHook.componentId);
|
|
1697
|
-
});
|
|
1698
|
-
}
|
|
1699
|
-
|
|
1700
|
-
addLayer();
|
|
1701
|
-
}, [mapHook.mapIsReady, mapHook.map, addLayer, props]);
|
|
1702
|
-
useEffect(function () {
|
|
1703
|
-
if (!mapHook.mapIsReady || mapHook.map && !mapHook.map.getLayer(layerId.current) || !props.options) {
|
|
1704
|
-
return;
|
|
1705
|
-
}
|
|
1706
|
-
|
|
1707
|
-
mapHook.map.getSource(layerId.current).setData(props.options.source.data);
|
|
1708
|
-
}, [props.options.source.data, props]);
|
|
1709
|
-
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
|
|
1710
|
-
};
|
|
1711
|
-
|
|
1712
|
-
var marker = "b556faa3bc6829d2.png";
|
|
1713
|
-
|
|
1714
1654
|
/**
|
|
1715
1655
|
* Adds a button that makes the map follow the users GPS position using
|
|
1716
1656
|
* navigator.geolocation.watchPosition if activated
|
|
@@ -1737,8 +1677,6 @@ var MlFollowGps = function MlFollowGps(props) {
|
|
|
1737
1677
|
geoJson = _useState4[0],
|
|
1738
1678
|
setGeoJson = _useState4[1];
|
|
1739
1679
|
|
|
1740
|
-
var watchIdRef = useRef(undefined);
|
|
1741
|
-
|
|
1742
1680
|
var _useState5 = useState(false),
|
|
1743
1681
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
1744
1682
|
locationAccessDenied = _useState6[0],
|
|
@@ -1749,17 +1687,14 @@ var MlFollowGps = function MlFollowGps(props) {
|
|
|
1749
1687
|
accuracyGeoJson = _useState8[0],
|
|
1750
1688
|
setAccuracyGeoJson = _useState8[1];
|
|
1751
1689
|
|
|
1752
|
-
useEffect(function () {
|
|
1753
|
-
return function () {
|
|
1754
|
-
if (watchIdRef.current) {
|
|
1755
|
-
navigator.geolocation.clearWatch(watchIdRef.current);
|
|
1756
|
-
watchIdRef.current = undefined;
|
|
1757
|
-
}
|
|
1758
|
-
};
|
|
1759
|
-
}, []);
|
|
1760
1690
|
var getLocationSuccess = useCallback(function (pos) {
|
|
1761
1691
|
if (!mapHook.map) return;
|
|
1762
|
-
mapHook.map.
|
|
1692
|
+
mapHook.map.flyTo({
|
|
1693
|
+
center: [pos.coords.longitude, pos.coords.latitude],
|
|
1694
|
+
zoom: 18,
|
|
1695
|
+
speed: 1,
|
|
1696
|
+
curve: 1
|
|
1697
|
+
});
|
|
1763
1698
|
var geoJsonPoint = point([pos.coords.longitude, pos.coords.latitude]);
|
|
1764
1699
|
setGeoJson(geoJsonPoint);
|
|
1765
1700
|
setAccuracyGeoJson(circle(geoJsonPoint, pos.coords.accuracy / 1000));
|
|
@@ -1774,33 +1709,31 @@ var MlFollowGps = function MlFollowGps(props) {
|
|
|
1774
1709
|
if (!mapHook.map) return;
|
|
1775
1710
|
|
|
1776
1711
|
if (isFollowed) {
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1712
|
+
var _watchId = navigator.geolocation.watchPosition(getLocationSuccess, getLocationError);
|
|
1713
|
+
|
|
1714
|
+
return function () {
|
|
1715
|
+
navigator.geolocation.clearWatch(_watchId);
|
|
1716
|
+
};
|
|
1780
1717
|
}
|
|
1781
1718
|
}, [isFollowed, getLocationSuccess]);
|
|
1782
1719
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, isFollowed && geoJson && /*#__PURE__*/React__default.createElement(MlGeoJsonLayer, {
|
|
1783
1720
|
geojson: accuracyGeoJson,
|
|
1784
1721
|
type: "fill",
|
|
1785
1722
|
paint: _objectSpread2({
|
|
1786
|
-
"fill-color": "#
|
|
1787
|
-
"fill-opacity": 0.
|
|
1723
|
+
"fill-color": "#cbd300",
|
|
1724
|
+
"fill-opacity": 0.3
|
|
1788
1725
|
}, props.accuracyPaint),
|
|
1789
|
-
insertBeforeLayer:
|
|
1790
|
-
}), isFollowed && geoJson && /*#__PURE__*/React__default.createElement(
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
"icon-offset": [0, -340]
|
|
1801
|
-
}, props.markerLayout)
|
|
1802
|
-
},
|
|
1803
|
-
imgSrc: props.markerImage || marker
|
|
1726
|
+
insertBeforeLayer: props.insertBeforeLayer
|
|
1727
|
+
}), isFollowed && geoJson && /*#__PURE__*/React__default.createElement(MlGeoJsonLayer, {
|
|
1728
|
+
geojson: geoJson,
|
|
1729
|
+
type: "circle",
|
|
1730
|
+
paint: _objectSpread2({
|
|
1731
|
+
"circle-color": "#009ee0",
|
|
1732
|
+
"circle-radius": 5,
|
|
1733
|
+
"circle-stroke-color": "#fafaff",
|
|
1734
|
+
"circle-stroke-width": 1
|
|
1735
|
+
}, props.circlePaint),
|
|
1736
|
+
insertBeforeLayer: props.insertBeforeLayer
|
|
1804
1737
|
}), /*#__PURE__*/React__default.createElement(Button, {
|
|
1805
1738
|
sx: _objectSpread2({
|
|
1806
1739
|
zIndex: 1002,
|
|
@@ -1865,16 +1798,11 @@ MlFollowGps.propTypes = {
|
|
|
1865
1798
|
accuracyPaint: PropTypes.object,
|
|
1866
1799
|
|
|
1867
1800
|
/**
|
|
1868
|
-
*
|
|
1869
|
-
* Use any available
|
|
1870
|
-
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#
|
|
1871
|
-
*/
|
|
1872
|
-
markerLayout: PropTypes.object,
|
|
1873
|
-
|
|
1874
|
-
/**
|
|
1875
|
-
* Replace the default marker image with a custom one.
|
|
1801
|
+
* position circle paint property object, that is passed to the MlGeoJsonLayer responsible for drawing the accuracy circle.
|
|
1802
|
+
* Use any available paint prop from layer type "fill".
|
|
1803
|
+
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
1876
1804
|
*/
|
|
1877
|
-
|
|
1805
|
+
circlePaint: PropTypes.object
|
|
1878
1806
|
};
|
|
1879
1807
|
|
|
1880
1808
|
var nmMap = {
|
|
@@ -2064,6 +1992,64 @@ MlCreatePdfButton.propTypes = {
|
|
|
2064
1992
|
mapId: PropTypes.string
|
|
2065
1993
|
};
|
|
2066
1994
|
|
|
1995
|
+
var MlImageMarkerLayer = function MlImageMarkerLayer(props) {
|
|
1996
|
+
var mapHook = useMap({
|
|
1997
|
+
mapId: props.mapId,
|
|
1998
|
+
waitForLayer: props.insertBeforeLayer
|
|
1999
|
+
});
|
|
2000
|
+
var layerInitializedRef = useRef(false);
|
|
2001
|
+
var imageIdRef = useRef(props.imageId || "img_" + new Date().getTime());
|
|
2002
|
+
var layerId = useRef(props.layerId || "MlImageMarkerLayer-" + mapHook.componentId);
|
|
2003
|
+
useEffect(function () {
|
|
2004
|
+
if (!mapHook.mapIsReady || mapHook.map && !mapHook.map.getLayer(layerId.current) || !props.options) return; // the MapLibre-gl instance (mapContext.map) is accessible here
|
|
2005
|
+
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
2006
|
+
|
|
2007
|
+
var key;
|
|
2008
|
+
|
|
2009
|
+
if (props.options.layout) {
|
|
2010
|
+
for (key in props.options.layout) {
|
|
2011
|
+
mapHook.map.setLayoutProperty(layerId.current, key, props.options.layout[key]);
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
|
|
2015
|
+
if (props.options.paint) {
|
|
2016
|
+
for (key in props.options.paint) {
|
|
2017
|
+
mapHook.map.setPaintProperty(layerId.current, key, props.options.paint[key]);
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
}, [props.options, layerId.current, props.mapId]);
|
|
2021
|
+
var addLayer = useCallback(function () {
|
|
2022
|
+
var tmpOptions = _objectSpread2({
|
|
2023
|
+
id: layerId.current,
|
|
2024
|
+
layout: {}
|
|
2025
|
+
}, props.options);
|
|
2026
|
+
|
|
2027
|
+
tmpOptions.layout["icon-image"] = imageIdRef.current;
|
|
2028
|
+
mapHook.map.addLayer(tmpOptions, props.insertBeforeLayer, mapHook.componentId);
|
|
2029
|
+
}, [props, mapHook.mapIsReady, mapHook.map]);
|
|
2030
|
+
useEffect(function () {
|
|
2031
|
+
if (!props.options || !mapHook.mapIsReady || layerInitializedRef.current) return;
|
|
2032
|
+
layerInitializedRef.current = true;
|
|
2033
|
+
|
|
2034
|
+
if (props.imgSrc) {
|
|
2035
|
+
mapHook.map.loadImage(props.imgSrc, function (error, image) {
|
|
2036
|
+
if (error) throw error;
|
|
2037
|
+
mapHook.map.addImage(imageIdRef.current, image, mapHook.componentId);
|
|
2038
|
+
});
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2041
|
+
addLayer();
|
|
2042
|
+
}, [mapHook.mapIsReady, mapHook.map, addLayer, props]);
|
|
2043
|
+
useEffect(function () {
|
|
2044
|
+
if (!mapHook.mapIsReady || mapHook.map && !mapHook.map.getLayer(layerId.current) || !props.options) {
|
|
2045
|
+
return;
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
mapHook.map.getSource(layerId.current).setData(props.options.source.data);
|
|
2049
|
+
}, [props.options.source.data, props]);
|
|
2050
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
|
|
2051
|
+
};
|
|
2052
|
+
|
|
2067
2053
|
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); }
|
|
2068
2054
|
|
|
2069
2055
|
function SvgRotateRight(props) {
|
|
@@ -2683,51 +2669,33 @@ MlOsmLayer.propTypes = {
|
|
|
2683
2669
|
*/
|
|
2684
2670
|
|
|
2685
2671
|
var MlVectorTileLayer = function MlVectorTileLayer(props) {
|
|
2686
|
-
var
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2672
|
+
var mapHook = useMap({
|
|
2673
|
+
mapId: props.mapId,
|
|
2674
|
+
waitForLayer: props.insertBeforeLayer
|
|
2675
|
+
});
|
|
2690
2676
|
var layerIdsRef = useRef({});
|
|
2677
|
+
var layerId = useRef(props.layerId || "MlVectorTileLayer-" + mapHook.componentId);
|
|
2691
2678
|
var layerPaintConfsRef = useRef({});
|
|
2692
2679
|
var layerLayoutConfsRef = useRef({});
|
|
2693
2680
|
var initializedRef = useRef(false);
|
|
2694
|
-
var mapRef = useRef(null);
|
|
2695
|
-
|
|
2696
|
-
var cleanup = function cleanup() {
|
|
2697
|
-
if (mapRef.current && mapRef.current.style) {
|
|
2698
|
-
for (var key in layerIdsRef.current) {
|
|
2699
|
-
if (mapRef.current.getLayer(layerIdsRef.current[key])) {
|
|
2700
|
-
mapRef.current.removeLayer(layerIdsRef.current[key]);
|
|
2701
|
-
}
|
|
2702
|
-
}
|
|
2703
|
-
|
|
2704
|
-
if (mapRef.current.getSource(sourceName + idSuffixRef.current)) {
|
|
2705
|
-
mapRef.current.removeSource(sourceName + idSuffixRef.current);
|
|
2706
|
-
}
|
|
2707
|
-
}
|
|
2708
|
-
};
|
|
2709
|
-
|
|
2710
|
-
useEffect(function () {
|
|
2711
|
-
return cleanup;
|
|
2712
|
-
}, []);
|
|
2713
2681
|
useEffect(function () {
|
|
2714
|
-
if (!
|
|
2715
|
-
initializedRef.current = true;
|
|
2716
|
-
mapRef.current = mapContext.getMap(props.mapId); // Add the new layer to the openlayers instance once it is available
|
|
2682
|
+
if (!mapHook.map || initializedRef.current) return;
|
|
2683
|
+
initializedRef.current = true; // Add the new layer to the openlayers instance once it is available
|
|
2717
2684
|
|
|
2718
|
-
|
|
2685
|
+
mapHook.map.addSource(layerId.current, _objectSpread2({
|
|
2719
2686
|
type: "vector",
|
|
2720
2687
|
tiles: [props.url],
|
|
2721
2688
|
tileSize: 512,
|
|
2722
2689
|
attribution: ""
|
|
2723
|
-
}, props.sourceOptions));
|
|
2690
|
+
}, props.sourceOptions), mapHook.componentId);
|
|
2724
2691
|
|
|
2725
2692
|
for (var key in props.layers) {
|
|
2726
|
-
var
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2693
|
+
var _layerId = layerId.current + "_" + key;
|
|
2694
|
+
|
|
2695
|
+
layerIdsRef.current[key] = _layerId;
|
|
2696
|
+
mapHook.map.addLayer(_objectSpread2({
|
|
2697
|
+
id: _layerId,
|
|
2698
|
+
source: layerId.current,
|
|
2731
2699
|
type: "line",
|
|
2732
2700
|
minzoom: 0,
|
|
2733
2701
|
maxzoom: 22,
|
|
@@ -2737,23 +2705,22 @@ var MlVectorTileLayer = function MlVectorTileLayer(props) {
|
|
|
2737
2705
|
"line-color": "rgb(80, 80, 80)",
|
|
2738
2706
|
"line-width": 2
|
|
2739
2707
|
}
|
|
2740
|
-
}, props.layers[key]));
|
|
2708
|
+
}, props.layers[key]), props.insertBeforeLayer, mapHook.componentId);
|
|
2741
2709
|
layerPaintConfsRef.current[key] = JSON.stringify(props.layers[key].paint);
|
|
2742
2710
|
layerLayoutConfsRef.current[key] = JSON.stringify(props.layers[key].layout);
|
|
2743
2711
|
}
|
|
2744
|
-
}, [
|
|
2712
|
+
}, [mapHook.map, props]);
|
|
2745
2713
|
useEffect(function () {
|
|
2746
|
-
if (!
|
|
2747
|
-
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
2714
|
+
if (!mapHook.map || !initializedRef.current) return; // initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
2748
2715
|
|
|
2749
2716
|
for (var key in props.layers) {
|
|
2750
|
-
if (
|
|
2717
|
+
if (mapHook.map.getLayer(layerIdsRef.current[key])) {
|
|
2751
2718
|
// update changed paint property
|
|
2752
2719
|
var layerPaintConfString = JSON.stringify(props.layers[key].paint);
|
|
2753
2720
|
|
|
2754
2721
|
if (layerPaintConfString !== layerPaintConfsRef.current[key]) {
|
|
2755
2722
|
for (var paintKey in props.layers[key].paint) {
|
|
2756
|
-
|
|
2723
|
+
mapHook.map.setPaintProperty(layerIdsRef.current[key], paintKey, props.layers[key].paint[paintKey]);
|
|
2757
2724
|
}
|
|
2758
2725
|
}
|
|
2759
2726
|
|
|
@@ -2763,28 +2730,14 @@ var MlVectorTileLayer = function MlVectorTileLayer(props) {
|
|
|
2763
2730
|
|
|
2764
2731
|
if (layerLayoutConfString !== layerLayoutConfsRef.current[key]) {
|
|
2765
2732
|
for (var layoutKey in props.layers[key].layout) {
|
|
2766
|
-
|
|
2733
|
+
mapHook.map.setLayoutProperty(layerIdsRef.current[key], layoutKey, props.layers[key].layout[layoutKey]);
|
|
2767
2734
|
}
|
|
2768
2735
|
}
|
|
2769
2736
|
|
|
2770
2737
|
layerLayoutConfsRef.current[key] = layerLayoutConfString;
|
|
2771
2738
|
}
|
|
2772
2739
|
}
|
|
2773
|
-
}, [props.layers,
|
|
2774
|
-
useEffect(function () {
|
|
2775
|
-
if (!mapRef.current) return;
|
|
2776
|
-
|
|
2777
|
-
for (var key in props.layers) {
|
|
2778
|
-
if (mapRef.current.getLayer(layerIdsRef.current[key])) {
|
|
2779
|
-
// toggle layer visibility by changing the layout object's visibility property
|
|
2780
|
-
if (props.visible) {
|
|
2781
|
-
mapContext.getMap(props.mapId).setLayoutProperty(layerIdsRef.current[key], "visibility", "visible");
|
|
2782
|
-
} else {
|
|
2783
|
-
mapContext.getMap(props.mapId).setLayoutProperty(layerIdsRef.current[key], "visibility", "none");
|
|
2784
|
-
}
|
|
2785
|
-
}
|
|
2786
|
-
}
|
|
2787
|
-
}, [props.visible]);
|
|
2740
|
+
}, [props.layers, mapHook.map]);
|
|
2788
2741
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
|
|
2789
2742
|
};
|
|
2790
2743
|
|
|
@@ -2804,11 +2757,6 @@ MlVectorTileLayer.propTypes = {
|
|
|
2804
2757
|
*/
|
|
2805
2758
|
layers: PropTypes.object,
|
|
2806
2759
|
|
|
2807
|
-
/**
|
|
2808
|
-
* Boolean value to control the visibility of this layer
|
|
2809
|
-
*/
|
|
2810
|
-
visible: PropTypes.bool,
|
|
2811
|
-
|
|
2812
2760
|
/**
|
|
2813
2761
|
* String of the URL of a wms layer
|
|
2814
2762
|
*/
|