@orioro/react-maplibre-util 0.6.0 → 0.7.0
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 -0
- package/dist/index.mjs +35 -17
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -912,26 +912,35 @@ function makeSyncedMaps(_a) {
|
|
|
912
912
|
var _c = useState(initialViewState),
|
|
913
913
|
viewState = _c[0],
|
|
914
914
|
setViewState = _c[1];
|
|
915
|
-
var
|
|
916
|
-
|
|
917
|
-
|
|
915
|
+
var syncedOnMove = useCallback(function (evt) {
|
|
916
|
+
setViewState(evt.viewState);
|
|
917
|
+
if (typeof baseMapProps.onMove === 'function') {
|
|
918
|
+
baseMapProps.onMove(evt);
|
|
919
|
+
}
|
|
920
|
+
}, [baseMapProps.onMove]);
|
|
918
921
|
var _d = useState(false),
|
|
919
922
|
isDragging = _d[0],
|
|
920
923
|
setIsDragging = _d[1];
|
|
921
|
-
var
|
|
922
|
-
|
|
923
|
-
|
|
924
|
+
var syncedOnDragEnd = useCallback(function (e) {
|
|
925
|
+
setIsDragging(false);
|
|
926
|
+
if (typeof baseMapProps.onDragEnd === 'function') {
|
|
927
|
+
baseMapProps.onDragEnd(e);
|
|
928
|
+
}
|
|
929
|
+
}, [setIsDragging, baseMapProps.onDragEnd]);
|
|
924
930
|
var _e = useState(null),
|
|
925
931
|
hoverInfo = _e[0],
|
|
926
932
|
setHoverInfo = _e[1];
|
|
927
933
|
var _f = useState(null),
|
|
928
934
|
tooltips = _f[0],
|
|
929
935
|
setTooltips = _f[1];
|
|
930
|
-
var
|
|
936
|
+
var syncedOnDragStart = useCallback(function (e) {
|
|
931
937
|
setIsDragging(true);
|
|
932
938
|
setTooltips(null);
|
|
933
|
-
|
|
934
|
-
|
|
939
|
+
if (typeof baseMapProps.onDragStart === 'function') {
|
|
940
|
+
baseMapProps.onDragStart(e);
|
|
941
|
+
}
|
|
942
|
+
}, [baseMapProps.onDragStart]);
|
|
943
|
+
var syncedOnMouseMove = useCallback(function (event, index) {
|
|
935
944
|
var nextHoverInfo = parseHoverInfo(index, event);
|
|
936
945
|
setHoverInfo(function (prevHoverInfo) {
|
|
937
946
|
mapSetFeaturesState(event.target, prevHoverInfo === null || prevHoverInfo === void 0 ? void 0 : prevHoverInfo.features, {
|
|
@@ -950,7 +959,13 @@ function makeSyncedMaps(_a) {
|
|
|
950
959
|
}
|
|
951
960
|
return getTooltip(nextHoverInfo, mapInstanceRefs[index]) || null;
|
|
952
961
|
}) : null);
|
|
953
|
-
|
|
962
|
+
if (typeof baseMapProps.onMouseMove === 'function') {
|
|
963
|
+
//
|
|
964
|
+
// Allow onMouseMove to be composed with base
|
|
965
|
+
//
|
|
966
|
+
baseMapProps.onMouseMove(event);
|
|
967
|
+
}
|
|
968
|
+
}, [maps, baseMapProps.onMouseMove]);
|
|
954
969
|
//
|
|
955
970
|
// There is no notion of mouseenter/mouseleave
|
|
956
971
|
// in maplibre.gl.
|
|
@@ -960,7 +975,7 @@ function makeSyncedMaps(_a) {
|
|
|
960
975
|
// https://github.com/mapbox/mapbox-gl-js/issues/10594
|
|
961
976
|
// https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/MapEventType/#mouseout
|
|
962
977
|
//
|
|
963
|
-
var
|
|
978
|
+
var syncedOnMouseOut = useCallback(function (event) {
|
|
964
979
|
setHoverInfo(null);
|
|
965
980
|
setTooltips(null);
|
|
966
981
|
if (Array.isArray(hoverInfo === null || hoverInfo === void 0 ? void 0 : hoverInfo.features)) {
|
|
@@ -968,7 +983,10 @@ function makeSyncedMaps(_a) {
|
|
|
968
983
|
hover: false
|
|
969
984
|
});
|
|
970
985
|
}
|
|
971
|
-
|
|
986
|
+
if (typeof baseMapProps.onMouseOut === 'function') {
|
|
987
|
+
baseMapProps.onMouseOut(event);
|
|
988
|
+
}
|
|
989
|
+
}, [setHoverInfo, setTooltips, hoverInfo, baseMapProps.onMouseOut]);
|
|
972
990
|
//
|
|
973
991
|
// Expose map instances
|
|
974
992
|
//
|
|
@@ -1021,11 +1039,11 @@ function makeSyncedMaps(_a) {
|
|
|
1021
1039
|
width: '100%',
|
|
1022
1040
|
height: '100%'
|
|
1023
1041
|
}),
|
|
1024
|
-
onMove:
|
|
1025
|
-
onDragStart:
|
|
1026
|
-
onDragEnd:
|
|
1042
|
+
onMove: syncedOnMove,
|
|
1043
|
+
onDragStart: syncedOnDragStart,
|
|
1044
|
+
onDragEnd: syncedOnDragEnd,
|
|
1027
1045
|
onMouseMove: function onMouseMove(event) {
|
|
1028
|
-
return
|
|
1046
|
+
return syncedOnMouseMove(event, index);
|
|
1029
1047
|
},
|
|
1030
1048
|
//
|
|
1031
1049
|
// There is no notion of mouseenter/mouseleave
|
|
@@ -1036,7 +1054,7 @@ function makeSyncedMaps(_a) {
|
|
|
1036
1054
|
// https://github.com/mapbox/mapbox-gl-js/issues/10594
|
|
1037
1055
|
// https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/MapEventType/#mouseout
|
|
1038
1056
|
//
|
|
1039
|
-
onMouseOut:
|
|
1057
|
+
onMouseOut: syncedOnMouseOut
|
|
1040
1058
|
})));
|
|
1041
1059
|
}), children);
|
|
1042
1060
|
});
|