@mapcomponents/react-maplibre 0.1.49 → 0.1.51
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 +22 -1
- package/coverage/clover.xml +86 -86
- package/coverage/coverage-final.json +3 -3
- package/coverage/lcov-report/index.html +1 -1
- package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MapLibreMap/index.html +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlFollowGps/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGPXViewer/MlGPXViewer.tsx.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.tsx.html +26 -11
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayer/MlLayer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.tsx.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.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlMarker/index.html +1 -1
- package/coverage/lcov-report/src/components/MlMeasureTool/MlMeasureTool.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlMeasureTool/index.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.tsx.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/MlOsmLayer.stories_.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.tsx.html +22 -19
- 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.tsx.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.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLoader/index.html +1 -1
- package/coverage/lcov-report/src/contexts/MapContext.tsx.html +1 -1
- package/coverage/lcov-report/src/contexts/SimpleDataContext.js.html +1 -1
- package/coverage/lcov-report/src/contexts/SimpleDataProvider.js.html +1 -1
- package/coverage/lcov-report/src/contexts/index.html +1 -1
- package/coverage/lcov-report/src/hooks/index.html +1 -1
- package/coverage/lcov-report/src/hooks/useLayer.ts.html +19 -10
- package/coverage/lcov-report/src/hooks/useMap.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useMapState.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useWms.js.html +1 -1
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.ts.html +1 -1
- package/coverage/lcov.info +185 -185
- package/dist/components/MapLibreMap/lib/MapLibreGlWrapper.d.ts +3 -2
- package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.d.ts +15 -8
- package/dist/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.d.ts +22 -17
- package/dist/hooks/useLayer.d.ts +7 -5
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.ts +4 -3
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx +14 -9
- package/src/components/MlGeoJsonLayer/util/getDefaultLayerTypeByGeometry.ts +2 -1
- package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx +18 -17
- package/src/hooks/useLayer.ts +11 -8
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Map, IControl, MapOptions as MapOptionsType
|
|
1
|
+
import { Map, IControl, MapOptions as MapOptionsType, } from "!maplibre-gl";
|
|
2
|
+
import { Map as MapType } from "maplibre-gl";
|
|
2
3
|
|
|
3
4
|
type EventArgArray = [string, string | Function, Function?];
|
|
4
5
|
type LayerState = {
|
|
@@ -53,7 +54,7 @@ class MapLibreGlWrapper {
|
|
|
53
54
|
};
|
|
54
55
|
initRegisteredElements: Function;
|
|
55
56
|
addNativeMaplibreFunctionsAndProps: Function;
|
|
56
|
-
map:
|
|
57
|
+
map: MapType;
|
|
57
58
|
style: object;
|
|
58
59
|
|
|
59
60
|
styleJson: object;
|
|
@@ -603,7 +604,7 @@ class MapLibreGlWrapper {
|
|
|
603
604
|
});
|
|
604
605
|
}
|
|
605
606
|
|
|
606
|
-
self.map = new Map(props.mapOptions);
|
|
607
|
+
self.map = new Map(props.mapOptions) as MapType;
|
|
607
608
|
//@ts-ignore
|
|
608
609
|
window._map = self.map;
|
|
609
610
|
|
|
@@ -8,6 +8,9 @@ import getDefaultPaintPropsByType from "./util/getDefaultPaintPropsByType";
|
|
|
8
8
|
import getDefaulLayerTypeByGeometry from "./util/getDefaultLayerTypeByGeometry";
|
|
9
9
|
import { Feature, FeatureCollection } from "@turf/turf";
|
|
10
10
|
|
|
11
|
+
|
|
12
|
+
import { LineLayerSpecification, CircleLayerSpecification, FillLayerSpecification,MapLayerMouseEvent, LayerSpecification } from "maplibre-gl";
|
|
13
|
+
|
|
11
14
|
type MlGeoJsonLayerProps = {
|
|
12
15
|
/**
|
|
13
16
|
* Id of the target MapLibre instance in mapContext
|
|
@@ -16,6 +19,8 @@ type MlGeoJsonLayerProps = {
|
|
|
16
19
|
/**
|
|
17
20
|
* Id of an existing layer in the mapLibre instance to help specify the layer order
|
|
18
21
|
* This layer will be visually beneath the layer with the "insertBeforeLayer" id.
|
|
22
|
+
* This layer will not be added to the maplibre-gl instance until a layer with an
|
|
23
|
+
* id that matches the value of insertBeforeLayer is created.
|
|
19
24
|
*/
|
|
20
25
|
insertBeforeLayer?: string;
|
|
21
26
|
/**
|
|
@@ -30,7 +35,7 @@ type MlGeoJsonLayerProps = {
|
|
|
30
35
|
* Type of the layer that will be added to the MapLibre instance.
|
|
31
36
|
* Possible values: "line", "circle", "fill"
|
|
32
37
|
*/
|
|
33
|
-
type?:
|
|
38
|
+
type?: "fill" | "line" | "circle";
|
|
34
39
|
/**
|
|
35
40
|
* Paint property object, that is passed to the addLayer call.
|
|
36
41
|
* Possible props depend on the layer type.
|
|
@@ -38,7 +43,7 @@ type MlGeoJsonLayerProps = {
|
|
|
38
43
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
|
|
39
44
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
40
45
|
*/
|
|
41
|
-
paint?:
|
|
46
|
+
paint?: CircleLayerSpecification['paint'] | FillLayerSpecification['paint'] | LineLayerSpecification['layout'];
|
|
42
47
|
/**
|
|
43
48
|
* Layout property object, that is passed to the addLayer call.
|
|
44
49
|
* Possible props depend on the layer type.
|
|
@@ -46,28 +51,28 @@ type MlGeoJsonLayerProps = {
|
|
|
46
51
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
|
|
47
52
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
48
53
|
*/
|
|
49
|
-
layout?:
|
|
54
|
+
layout?: CircleLayerSpecification['layout'] | FillLayerSpecification['layout'] | LineLayerSpecification['layout'];
|
|
50
55
|
/**
|
|
51
56
|
* Javascript object that is spread into the addLayer commands first parameter.
|
|
52
57
|
*/
|
|
53
|
-
options?:
|
|
58
|
+
options?: CircleLayerSpecification | FillLayerSpecification | LineLayerSpecification;
|
|
54
59
|
/**
|
|
55
60
|
* Javascript object with optional properties "fill", "line", "circle" to override implicit layer type default paint properties.
|
|
56
61
|
*/
|
|
57
|
-
defaultPaintOverrides?:
|
|
62
|
+
defaultPaintOverrides?: { circle?: CircleLayerSpecification['paint'], fill?: FillLayerSpecification['paint'], line?: LineLayerSpecification['paint'] };
|
|
58
63
|
/**
|
|
59
64
|
* Hover event handler that is executed whenever a geometry rendered by this component is hovered.
|
|
60
65
|
*/
|
|
61
|
-
onHover?:
|
|
66
|
+
onHover?: MapLayerMouseEvent;
|
|
62
67
|
/**
|
|
63
68
|
* Click event handler that is executed whenever a geometry rendered by this component is clicked.
|
|
64
69
|
*/
|
|
65
|
-
onClick?:
|
|
70
|
+
onClick?: MapLayerMouseEvent;
|
|
66
71
|
/**
|
|
67
72
|
* Leave event handler that is executed whenever a geometry rendered by this component is
|
|
68
73
|
* left/unhovered.
|
|
69
74
|
*/
|
|
70
|
-
onLeave?:
|
|
75
|
+
onLeave?: MapLayerMouseEvent;
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
/**
|
|
@@ -91,7 +96,7 @@ const MlGeoJsonLayer = (props: MlGeoJsonLayerProps) => {
|
|
|
91
96
|
),
|
|
92
97
|
layout: props.layout || {},
|
|
93
98
|
...props.options,
|
|
94
|
-
type: layerType,
|
|
99
|
+
type: layerType as LayerSpecification['type'],
|
|
95
100
|
},
|
|
96
101
|
insertBeforeLayer: props.insertBeforeLayer,
|
|
97
102
|
onHover: props.onHover,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Feature, FeatureCollection } from "@turf/turf";
|
|
2
|
+
import { LayerSpecification } from "maplibre-gl";
|
|
2
3
|
|
|
3
4
|
const mapGeometryTypesToLayerTypes = {
|
|
4
5
|
Position: "circle",
|
|
@@ -13,7 +14,7 @@ const mapGeometryTypesToLayerTypes = {
|
|
|
13
14
|
|
|
14
15
|
const getDefaulLayerTypeByGeometry: Function = (
|
|
15
16
|
geojson: Feature | FeatureCollection
|
|
16
|
-
):
|
|
17
|
+
): LayerSpecification['type'] => {
|
|
17
18
|
if (geojson?.type === "Feature") {
|
|
18
19
|
return mapGeometryTypesToLayerTypes?.[geojson?.geometry?.type]
|
|
19
20
|
? mapGeometryTypesToLayerTypes[geojson.geometry.type]
|
|
@@ -7,6 +7,7 @@ import useMap from "../../hooks/useMap";
|
|
|
7
7
|
import { _transitionToGeojson } from "./util/transitionFunctions";
|
|
8
8
|
import MlGeoJsonLayer from "../MlGeoJsonLayer/MlGeoJsonLayer";
|
|
9
9
|
import { Feature, FeatureCollection } from "@turf/turf";
|
|
10
|
+
import { CircleLayerSpecification, FillLayerSpecification, LineLayerSpecification, MapLayerMouseEvent } from "maplibre-gl";
|
|
10
11
|
|
|
11
12
|
const msPerStep = 50;
|
|
12
13
|
|
|
@@ -15,57 +16,57 @@ interface MlTransitionGeoJsonLayerProps {
|
|
|
15
16
|
* Id of the target MapLibre instance in mapContext
|
|
16
17
|
*/
|
|
17
18
|
mapId: string;
|
|
19
|
+
/**
|
|
20
|
+
* GeoJSON data that is supposed to be rendered by this component.
|
|
21
|
+
*/
|
|
22
|
+
geojson: Feature | FeatureCollection | undefined;
|
|
18
23
|
/**
|
|
19
24
|
* Type of the layer that will be added to the MapLibre instance.
|
|
20
25
|
* Possible values: "line", "circle", "fill"
|
|
21
26
|
*/
|
|
22
|
-
type
|
|
27
|
+
type?: "fill" | "line" | "circle";
|
|
23
28
|
/**
|
|
24
|
-
*
|
|
29
|
+
* Paint property object, that is passed to the addLayer call.
|
|
25
30
|
* Possible props depend on the layer type.
|
|
26
31
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#line
|
|
27
32
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
|
|
28
33
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
29
34
|
*/
|
|
30
|
-
layout
|
|
35
|
+
paint?: CircleLayerSpecification['paint'] | FillLayerSpecification['paint'] | LineLayerSpecification['layout'];
|
|
31
36
|
/**
|
|
32
|
-
*
|
|
37
|
+
* Layout property object, that is passed to the addLayer call.
|
|
33
38
|
* Possible props depend on the layer type.
|
|
34
39
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#line
|
|
35
40
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
|
|
36
41
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
37
42
|
*/
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Javascript object with optional properties "fill", "line", "circle" to override implicit layer type default paint properties.
|
|
41
|
-
*/
|
|
42
|
-
defaultPaintOverrides: any;
|
|
43
|
+
layout?: CircleLayerSpecification['layout'] | FillLayerSpecification['layout'] | LineLayerSpecification['layout'];
|
|
43
44
|
/**
|
|
44
45
|
* Javascript object that is spread into the addLayer commands first parameter.
|
|
45
46
|
*/
|
|
46
|
-
options
|
|
47
|
+
options?: CircleLayerSpecification | FillLayerSpecification | LineLayerSpecification;
|
|
47
48
|
/**
|
|
48
|
-
*
|
|
49
|
+
* Javascript object with optional properties "fill", "line", "circle" to override implicit layer type default paint properties.
|
|
49
50
|
*/
|
|
50
|
-
|
|
51
|
+
defaultPaintOverrides?: { circle?: CircleLayerSpecification['paint'], fill?: FillLayerSpecification['paint'], line?: LineLayerSpecification['paint'] };
|
|
51
52
|
/**
|
|
52
53
|
* Id of an existing layer in the mapLibre instance to help specify the layer order
|
|
53
54
|
* This layer will be visually beneath the layer with the "insertBeforeLayer" id.
|
|
54
55
|
*/
|
|
55
56
|
insertBeforeLayer: string;
|
|
56
57
|
/**
|
|
57
|
-
*
|
|
58
|
+
* Hover event handler that is executed whenever a geometry rendered by this component is hovered.
|
|
58
59
|
*/
|
|
59
|
-
|
|
60
|
+
onHover?: MapLayerMouseEvent;
|
|
60
61
|
/**
|
|
61
|
-
*
|
|
62
|
+
* Click event handler that is executed whenever a geometry rendered by this component is clicked.
|
|
62
63
|
*/
|
|
63
|
-
|
|
64
|
+
onClick?: MapLayerMouseEvent;
|
|
64
65
|
/**
|
|
65
66
|
* Leave event handler that is executed whenever a geometry rendered by this component is
|
|
66
67
|
* left/unhovered.
|
|
67
68
|
*/
|
|
68
|
-
onLeave
|
|
69
|
+
onLeave?: MapLayerMouseEvent;
|
|
69
70
|
/**
|
|
70
71
|
* Creates transition animation whenever the geojson prop changes.
|
|
71
72
|
* Only works with layer type "line" and LineString GeoJSON data.
|
package/src/hooks/useLayer.ts
CHANGED
|
@@ -6,6 +6,9 @@ import { LayerSpecification } from "maplibre-gl";
|
|
|
6
6
|
|
|
7
7
|
import MapLibreGlWrapper from "../components/MapLibreMap/lib/MapLibreGlWrapper";
|
|
8
8
|
|
|
9
|
+
import { MapLayerMouseEvent } from "maplibre-gl";
|
|
10
|
+
import { GeoJSONObject } from "@turf/turf";
|
|
11
|
+
|
|
9
12
|
type useLayerType = {
|
|
10
13
|
map: MapLibreGlWrapper | undefined;
|
|
11
14
|
layer: LayerSpecification;
|
|
@@ -20,11 +23,11 @@ interface useLayerProps {
|
|
|
20
23
|
idPrefix?: string;
|
|
21
24
|
insertBeforeLayer?: string;
|
|
22
25
|
insertBeforeFirstSymbolLayer?: boolean;
|
|
23
|
-
geojson?:
|
|
24
|
-
options: LayerSpecification
|
|
25
|
-
onHover?:
|
|
26
|
-
onClick?:
|
|
27
|
-
onLeave?:
|
|
26
|
+
geojson?: GeoJSONObject;
|
|
27
|
+
options: Partial<LayerSpecification>;
|
|
28
|
+
onHover?: MapLayerMouseEvent;
|
|
29
|
+
onClick?: MapLayerMouseEvent;
|
|
30
|
+
onLeave?: MapLayerMouseEvent;
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
const legalLayerTypes = [
|
|
@@ -116,7 +119,7 @@ function useLayer(props: useLayerProps): useLayerType {
|
|
|
116
119
|
|
|
117
120
|
layerPaintConfRef.current = JSON.stringify(props.options?.paint);
|
|
118
121
|
layerLayoutConfRef.current = JSON.stringify(props.options?.layout);
|
|
119
|
-
layerTypeRef.current = props.options.type;
|
|
122
|
+
layerTypeRef.current = props.options.type as LayerSpecification['type'];
|
|
120
123
|
}, [props, mapHook.map]);
|
|
121
124
|
|
|
122
125
|
useEffect(() => {
|
|
@@ -124,8 +127,8 @@ function useLayer(props: useLayerProps): useLayerType {
|
|
|
124
127
|
|
|
125
128
|
if (
|
|
126
129
|
initializedRef.current &&
|
|
127
|
-
(legalLayerTypes.indexOf(props.options.type) === -1 ||
|
|
128
|
-
(legalLayerTypes.indexOf(props.options.type) !== -1 &&
|
|
130
|
+
(legalLayerTypes.indexOf(props.options.type as LayerSpecification['type']) === -1 ||
|
|
131
|
+
(legalLayerTypes.indexOf(props.options.type as LayerSpecification['type']) !== -1 &&
|
|
129
132
|
props.options.type === layerTypeRef.current))
|
|
130
133
|
) {
|
|
131
134
|
return;
|