react-bkoi-gl 1.0.7 → 2.0.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/README.md +163 -18
- package/dist/components/attribution-control.d.ts +4 -6
- package/dist/components/attribution-control.js +6 -5
- package/dist/components/attribution-control.js.map +1 -1
- package/dist/components/fullscreen-control.d.ts +4 -6
- package/dist/components/fullscreen-control.js +4 -4
- package/dist/components/fullscreen-control.js.map +1 -1
- package/dist/components/geolocate-control.d.ts +10 -26
- package/dist/components/geolocate-control.js +11 -11
- package/dist/components/geolocate-control.js.map +1 -1
- package/dist/components/layer.d.ts +7 -6
- package/dist/components/layer.js +8 -9
- package/dist/components/layer.js.map +1 -1
- package/dist/components/logo-control.d.ts +9 -0
- package/dist/components/logo-control.js +28 -0
- package/dist/components/logo-control.js.map +1 -0
- package/dist/components/map.d.ts +20 -16
- package/dist/components/map.js +38 -32
- package/dist/components/map.js.map +1 -1
- package/dist/components/marker.d.ts +10 -33
- package/dist/components/marker.js +22 -15
- package/dist/components/marker.js.map +1 -1
- package/dist/components/navigation-control.d.ts +4 -6
- package/dist/components/navigation-control.js +4 -4
- package/dist/components/navigation-control.js.map +1 -1
- package/dist/components/popup.d.ts +7 -25
- package/dist/components/popup.js +17 -28
- package/dist/components/popup.js.map +1 -1
- package/dist/components/scale-control.d.ts +4 -6
- package/dist/components/scale-control.js +4 -4
- package/dist/components/scale-control.js.map +1 -1
- package/dist/components/source.d.ts +3 -4
- package/dist/components/source.js +20 -22
- package/dist/components/source.js.map +1 -1
- package/dist/components/terrain-control.d.ts +10 -0
- package/dist/components/terrain-control.js +19 -0
- package/dist/components/terrain-control.js.map +1 -0
- package/dist/components/use-control.d.ts +6 -6
- package/dist/components/use-control.js +4 -5
- package/dist/components/use-control.js.map +1 -1
- package/dist/components/use-map.d.ts +8 -9
- package/dist/components/use-map.js +5 -5
- package/dist/components/use-map.js.map +1 -1
- package/dist/exports-maplibre-gl.d.ts +33 -0
- package/dist/exports-maplibre-gl.js +21 -0
- package/dist/exports-maplibre-gl.js.map +1 -0
- package/dist/index.cjs +590 -681
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/{mapbox → maplibre}/create-ref.d.ts +6 -6
- package/dist/maplibre/create-ref.js +30 -0
- package/dist/maplibre/create-ref.js.map +1 -0
- package/dist/maplibre/maplibre.d.ts +81 -0
- package/dist/maplibre/maplibre.js +387 -0
- package/dist/maplibre/maplibre.js.map +1 -0
- package/dist/styles/index.d.ts +4 -0
- package/dist/styles/react-bkoi-gl.css +1 -1
- package/dist/styles.d.js +2 -0
- package/dist/styles.d.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/common.d.ts +2 -60
- package/dist/types/common.js.map +1 -1
- package/dist/types/events.d.ts +64 -23
- package/dist/types/events.js.map +1 -1
- package/dist/types/internal.d.ts +14 -0
- package/dist/types/internal.js +2 -0
- package/dist/types/internal.js.map +1 -0
- package/dist/types/lib.d.ts +16 -200
- package/dist/types/lib.js.map +1 -1
- package/dist/types/style-spec.d.ts +1 -0
- package/dist/types/style-spec.js +2 -0
- package/dist/types/style-spec.js.map +1 -0
- package/dist/utils/apply-react-style.d.ts +1 -1
- package/dist/utils/apply-react-style.js.map +1 -1
- package/dist/utils/compare-class-names.d.ts +2 -0
- package/dist/utils/compare-class-names.js +23 -0
- package/dist/utils/compare-class-names.js.map +1 -0
- package/dist/utils/deep-equal.d.ts +1 -1
- package/dist/utils/deep-equal.js +1 -1
- package/dist/utils/deep-equal.js.map +1 -1
- package/dist/utils/set-globals.d.ts +6 -8
- package/dist/utils/set-globals.js +22 -10
- package/dist/utils/set-globals.js.map +1 -1
- package/dist/utils/style-utils.d.ts +3 -2
- package/dist/utils/style-utils.js +4 -4
- package/dist/utils/style-utils.js.map +1 -1
- package/dist/utils/transform.d.ts +11 -19
- package/dist/utils/transform.js +13 -36
- package/dist/utils/transform.js.map +1 -1
- package/dist/utils/use-isomorphic-layout-effect.d.ts +1 -1
- package/dist/utils/use-isomorphic-layout-effect.js +2 -2
- package/dist/utils/use-isomorphic-layout-effect.js.map +1 -1
- package/package.json +42 -26
- package/src/components/attribution-control.ts +40 -16
- package/src/components/fullscreen-control.ts +40 -0
- package/src/components/geolocate-control.ts +45 -39
- package/src/components/layer.ts +37 -29
- package/src/components/logo-control.ts +44 -0
- package/src/components/map.tsx +86 -75
- package/src/components/marker.ts +141 -123
- package/src/components/navigation-control.ts +11 -12
- package/src/components/popup.ts +94 -97
- package/src/components/scale-control.ts +12 -14
- package/src/components/source.ts +58 -57
- package/src/components/terrain-control.ts +29 -0
- package/src/components/use-control.ts +21 -17
- package/src/components/use-map.tsx +26 -24
- package/src/exports-maplibre-gl.ts +37 -0
- package/src/index.ts +3 -2
- package/src/maplibre/create-ref.ts +70 -0
- package/src/maplibre/maplibre.ts +624 -0
- package/src/styles.d.ts +4 -0
- package/src/types/common.ts +12 -72
- package/src/types/events.ts +102 -42
- package/src/types/internal.ts +26 -0
- package/src/types/lib.ts +65 -260
- package/src/types/style-spec.ts +34 -0
- package/src/utils/apply-react-style.ts +7 -3
- package/src/utils/compare-class-names.ts +29 -0
- package/src/utils/deep-equal.ts +2 -2
- package/src/utils/set-globals.ts +22 -28
- package/src/utils/style-utils.ts +18 -9
- package/src/utils/transform.ts +32 -60
- package/src/utils/use-isomorphic-layout-effect.ts +3 -2
- package/bkoi-gl/package.json +0 -6
- package/dist/exports-bkoi-gl.cjs +0 -1512
- package/dist/exports-bkoi-gl.d.ts +0 -89
- package/dist/exports-bkoi-gl.js +0 -36
- package/dist/exports-bkoi-gl.js.map +0 -1
- package/dist/exports-mapbox.d.ts +0 -139
- package/dist/exports-mapbox.js +0 -36
- package/dist/exports-mapbox.js.map +0 -1
- package/dist/mapbox/create-ref.js +0 -64
- package/dist/mapbox/create-ref.js.map +0 -1
- package/dist/mapbox/mapbox.d.ts +0 -81
- package/dist/mapbox/mapbox.js +0 -476
- package/dist/mapbox/mapbox.js.map +0 -1
- package/dist/types/events-bkoi-gl.d.ts +0 -49
- package/dist/types/events-bkoi-gl.js +0 -2
- package/dist/types/events-bkoi-gl.js.map +0 -1
- package/dist/types/events-mapbox.d.ts +0 -49
- package/dist/types/events-mapbox.js +0 -2
- package/dist/types/events-mapbox.js.map +0 -1
- package/dist/types/index.d.ts +0 -70
- package/dist/types/index.js +0 -5
- package/dist/types/index.js.map +0 -1
- package/dist/types/public.d.ts +0 -2
- package/dist/types/public.js +0 -2
- package/dist/types/public.js.map +0 -1
- package/dist/types/style-spec-bkoi-gl.d.ts +0 -9
- package/dist/types/style-spec-bkoi-gl.js +0 -2
- package/dist/types/style-spec-bkoi-gl.js.map +0 -1
- package/dist/types/style-spec-mapbox.d.ts +0 -7
- package/dist/types/style-spec-mapbox.js +0 -2
- package/dist/types/style-spec-mapbox.js.map +0 -1
- package/src/components/fullscreen-control.tsx +0 -37
- package/src/exports-bkoi-gl.ts +0 -156
- package/src/exports-mapbox.ts +0 -159
- package/src/mapbox/create-ref.ts +0 -118
- package/src/mapbox/mapbox.ts +0 -742
- package/src/types/events-bkoi-gl.ts +0 -78
- package/src/types/events-mapbox.ts +0 -76
- package/src/types/index.ts +0 -93
- package/src/types/public.ts +0 -9
- package/src/types/style-spec-bkoi-gl.ts +0 -81
- package/src/types/style-spec-mapbox.ts +0 -80
package/src/types/common.ts
CHANGED
|
@@ -1,73 +1,15 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
lng: number;
|
|
14
|
-
lat: number;
|
|
15
|
-
|
|
16
|
-
wrap(): LngLat;
|
|
17
|
-
/** Return a LngLat as an array */
|
|
18
|
-
toArray(): number[];
|
|
19
|
-
/** Return a LngLat as a string */
|
|
20
|
-
toString(): string;
|
|
21
|
-
/** Returns the approximate distance between a pair of coordinates in meters
|
|
22
|
-
* Uses the Haversine Formula (from R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159) */
|
|
23
|
-
distanceTo(lngLat: LngLat): number;
|
|
24
|
-
}
|
|
25
|
-
export type LngLatLike =
|
|
26
|
-
| [number, number]
|
|
27
|
-
| LngLat
|
|
28
|
-
| {lng: number; lat: number}
|
|
29
|
-
| {lon: number; lat: number};
|
|
30
|
-
|
|
31
|
-
export interface LngLatBounds {
|
|
32
|
-
contains(lnglat: LngLatLike): boolean;
|
|
33
|
-
setNorthEast(ne: LngLatLike): this;
|
|
34
|
-
setSouthWest(sw: LngLatLike): this;
|
|
35
|
-
extend(obj: LngLatLike | LngLatBoundsLike): this;
|
|
36
|
-
|
|
37
|
-
getCenter(): LngLat;
|
|
38
|
-
getSouthWest(): LngLat;
|
|
39
|
-
getNorthEast(): LngLat;
|
|
40
|
-
getNorthWest(): LngLat;
|
|
41
|
-
getSouthEast(): LngLat;
|
|
42
|
-
|
|
43
|
-
getWest(): number;
|
|
44
|
-
getSouth(): number;
|
|
45
|
-
getEast(): number;
|
|
46
|
-
getNorth(): number;
|
|
47
|
-
|
|
48
|
-
toArray(): number[][];
|
|
49
|
-
toString(): string;
|
|
50
|
-
isEmpty(): boolean;
|
|
51
|
-
}
|
|
52
|
-
export type LngLatBoundsLike =
|
|
53
|
-
| LngLatBounds
|
|
54
|
-
| [LngLatLike, LngLatLike]
|
|
55
|
-
| [number, number, number, number]
|
|
56
|
-
| LngLatLike;
|
|
57
|
-
|
|
58
|
-
export type MapGeoJSONFeature = GeoJSON.Feature<GeoJSON.Geometry> & {
|
|
59
|
-
layer: any;
|
|
60
|
-
source: string;
|
|
61
|
-
sourceLayer: string;
|
|
62
|
-
state: {[key: string]: any};
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export type PaddingOptions = {
|
|
66
|
-
top: number;
|
|
67
|
-
bottom: number;
|
|
68
|
-
left: number;
|
|
69
|
-
right: number;
|
|
70
|
-
};
|
|
1
|
+
import type { PaddingOptions } from "maplibre-gl";
|
|
2
|
+
|
|
3
|
+
export type {
|
|
4
|
+
Point,
|
|
5
|
+
PointLike,
|
|
6
|
+
LngLat,
|
|
7
|
+
LngLatLike,
|
|
8
|
+
LngLatBounds,
|
|
9
|
+
LngLatBoundsLike,
|
|
10
|
+
PaddingOptions,
|
|
11
|
+
MapGeoJSONFeature,
|
|
12
|
+
} from "maplibre-gl";
|
|
71
13
|
|
|
72
14
|
/* Public */
|
|
73
15
|
|
|
@@ -87,8 +29,6 @@ export type ViewState = {
|
|
|
87
29
|
padding: PaddingOptions;
|
|
88
30
|
};
|
|
89
31
|
|
|
90
|
-
export type ControlPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
|
|
91
|
-
|
|
92
32
|
export interface ImmutableLike<T> {
|
|
93
33
|
toJS: () => T;
|
|
94
34
|
}
|
package/src/types/events.ts
CHANGED
|
@@ -1,73 +1,133 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Point, LngLat, MapGeoJSONFeature, ViewState } from "./common";
|
|
2
|
+
|
|
2
3
|
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
Map,
|
|
5
|
+
Marker,
|
|
6
|
+
Popup,
|
|
7
|
+
GeolocateControl,
|
|
8
|
+
MapLibreEvent,
|
|
9
|
+
MapMouseEvent as _MapMouseEvent,
|
|
10
|
+
MapLayerMouseEvent,
|
|
11
|
+
MapTouchEvent,
|
|
12
|
+
MapLayerTouchEvent,
|
|
13
|
+
MapStyleDataEvent,
|
|
14
|
+
MapSourceDataEvent,
|
|
15
|
+
MapWheelEvent,
|
|
16
|
+
MapLibreZoomEvent as MapBoxZoomEvent,
|
|
17
|
+
} from "maplibre-gl";
|
|
18
|
+
|
|
19
|
+
export type {
|
|
20
|
+
MapLibreEvent as MapEvent,
|
|
21
|
+
MapLayerMouseEvent,
|
|
22
|
+
MapTouchEvent,
|
|
23
|
+
MapLayerTouchEvent,
|
|
24
|
+
MapStyleDataEvent,
|
|
25
|
+
MapSourceDataEvent,
|
|
26
|
+
MapWheelEvent,
|
|
27
|
+
MapBoxZoomEvent,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type MapCallbacks = {
|
|
31
|
+
onMouseDown?: (e: MapLayerMouseEvent) => void;
|
|
32
|
+
onMouseUp?: (e: MapLayerMouseEvent) => void;
|
|
33
|
+
onMouseOver?: (e: MapLayerMouseEvent) => void;
|
|
34
|
+
onMouseMove?: (e: MapLayerMouseEvent) => void;
|
|
35
|
+
onClick?: (e: MapLayerMouseEvent) => void;
|
|
36
|
+
onDblClick?: (e: MapLayerMouseEvent) => void;
|
|
37
|
+
onMouseEnter?: (e: MapLayerMouseEvent) => void;
|
|
38
|
+
onMouseLeave?: (e: MapLayerMouseEvent) => void;
|
|
39
|
+
onMouseOut?: (e: MapLayerMouseEvent) => void;
|
|
40
|
+
onContextMenu?: (e: MapLayerMouseEvent) => void;
|
|
41
|
+
onTouchStart?: (e: MapLayerTouchEvent) => void;
|
|
42
|
+
onTouchEnd?: (e: MapLayerTouchEvent) => void;
|
|
43
|
+
onTouchMove?: (e: MapLayerTouchEvent) => void;
|
|
44
|
+
onTouchCancel?: (e: MapLayerTouchEvent) => void;
|
|
45
|
+
|
|
46
|
+
onMoveStart?: (e: ViewStateChangeEvent) => void;
|
|
47
|
+
onMove?: (e: ViewStateChangeEvent) => void;
|
|
48
|
+
onMoveEnd?: (e: ViewStateChangeEvent) => void;
|
|
49
|
+
onDragStart?: (e: ViewStateChangeEvent) => void;
|
|
50
|
+
onDrag?: (e: ViewStateChangeEvent) => void;
|
|
51
|
+
onDragEnd?: (e: ViewStateChangeEvent) => void;
|
|
52
|
+
onZoomStart?: (e: ViewStateChangeEvent) => void;
|
|
53
|
+
onZoom?: (e: ViewStateChangeEvent) => void;
|
|
54
|
+
onZoomEnd?: (e: ViewStateChangeEvent) => void;
|
|
55
|
+
onRotateStart?: (e: ViewStateChangeEvent) => void;
|
|
56
|
+
onRotate?: (e: ViewStateChangeEvent) => void;
|
|
57
|
+
onRotateEnd?: (e: ViewStateChangeEvent) => void;
|
|
58
|
+
onPitchStart?: (e: ViewStateChangeEvent) => void;
|
|
59
|
+
onPitch?: (e: ViewStateChangeEvent) => void;
|
|
60
|
+
onPitchEnd?: (e: ViewStateChangeEvent) => void;
|
|
61
|
+
|
|
62
|
+
onWheel?: (e: MapWheelEvent) => void;
|
|
63
|
+
onBoxZoomStart?: (e: MapBoxZoomEvent) => void;
|
|
64
|
+
onBoxZoomEnd?: (e: MapBoxZoomEvent) => void;
|
|
65
|
+
onBoxZoomCancel?: (e: MapBoxZoomEvent) => void;
|
|
66
|
+
|
|
67
|
+
onResize?: (e: MapLibreEvent) => void;
|
|
68
|
+
onLoad?: (e: MapLibreEvent) => void;
|
|
69
|
+
onRender?: (e: MapLibreEvent) => void;
|
|
70
|
+
onIdle?: (e: MapLibreEvent) => void;
|
|
71
|
+
onError?: (e: ErrorEvent) => void;
|
|
72
|
+
onRemove?: (e: MapLibreEvent) => void;
|
|
73
|
+
onData?: (e: MapStyleDataEvent | MapSourceDataEvent) => void;
|
|
74
|
+
onStyleData?: (e: MapStyleDataEvent) => void;
|
|
75
|
+
onSourceData?: (e: MapSourceDataEvent) => void;
|
|
76
|
+
};
|
|
13
77
|
|
|
14
|
-
|
|
78
|
+
interface MapEvent<SourceT, OriginalEventT = undefined> {
|
|
15
79
|
type: string;
|
|
16
80
|
target: SourceT;
|
|
17
81
|
originalEvent: OriginalEventT;
|
|
18
82
|
}
|
|
19
83
|
|
|
20
|
-
export type ErrorEvent
|
|
21
|
-
type:
|
|
84
|
+
export type ErrorEvent = MapEvent<Map> & {
|
|
85
|
+
type: "error";
|
|
22
86
|
error: Error;
|
|
23
87
|
};
|
|
24
88
|
|
|
25
|
-
export type MapMouseEvent
|
|
89
|
+
export type MapMouseEvent = _MapMouseEvent & {
|
|
26
90
|
point: Point;
|
|
27
91
|
lngLat: LngLat;
|
|
28
92
|
features?: MapGeoJSONFeature[];
|
|
29
93
|
};
|
|
30
94
|
|
|
31
|
-
export type ViewStateChangeEvent
|
|
32
|
-
| (MapEvent<
|
|
33
|
-
type:
|
|
95
|
+
export type ViewStateChangeEvent =
|
|
96
|
+
| (MapEvent<Map, MouseEvent | TouchEvent | WheelEvent | undefined> & {
|
|
97
|
+
type: "movestart" | "move" | "moveend" | "zoomstart" | "zoom" | "zoomend";
|
|
34
98
|
viewState: ViewState;
|
|
35
99
|
})
|
|
36
|
-
| (MapEvent<
|
|
100
|
+
| (MapEvent<Map, MouseEvent | TouchEvent | undefined> & {
|
|
37
101
|
type:
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
102
|
+
| "rotatestart"
|
|
103
|
+
| "rotate"
|
|
104
|
+
| "rotateend"
|
|
105
|
+
| "dragstart"
|
|
106
|
+
| "drag"
|
|
107
|
+
| "dragend"
|
|
108
|
+
| "pitchstart"
|
|
109
|
+
| "pitch"
|
|
110
|
+
| "pitchend";
|
|
47
111
|
viewState: ViewState;
|
|
48
112
|
});
|
|
49
113
|
|
|
50
|
-
export type PopupEvent
|
|
51
|
-
type:
|
|
52
|
-
target:
|
|
114
|
+
export type PopupEvent = {
|
|
115
|
+
type: "open" | "close";
|
|
116
|
+
target: Popup;
|
|
53
117
|
};
|
|
54
118
|
|
|
55
|
-
export type MarkerEvent<
|
|
56
|
-
|
|
119
|
+
export type MarkerEvent<OriginalEventT = undefined> = MapEvent<
|
|
120
|
+
Marker,
|
|
57
121
|
OriginalEventT
|
|
58
122
|
>;
|
|
59
123
|
|
|
60
|
-
export type MarkerDragEvent
|
|
61
|
-
type:
|
|
62
|
-
target: MarkerT;
|
|
124
|
+
export type MarkerDragEvent = MarkerEvent & {
|
|
125
|
+
type: "dragstart" | "drag" | "dragend";
|
|
63
126
|
lngLat: LngLat;
|
|
64
127
|
};
|
|
65
128
|
|
|
66
|
-
export type GeolocateEvent
|
|
67
|
-
MapEvent<GeolocateControlT>;
|
|
129
|
+
export type GeolocateEvent = MapEvent<GeolocateControl>;
|
|
68
130
|
|
|
69
|
-
export type GeolocateResultEvent
|
|
70
|
-
GeolocateEvent<GeolocateControlT> & GeolocationPosition;
|
|
131
|
+
export type GeolocateResultEvent = GeolocateEvent & GeolocationPosition;
|
|
71
132
|
|
|
72
|
-
export type GeolocateErrorEvent
|
|
73
|
-
GeolocateEvent<GeolocateControlT> & GeolocationPositionError;
|
|
133
|
+
export type GeolocateErrorEvent = GeolocateEvent & GeolocationPositionError;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Internal types
|
|
2
|
+
import type { LngLat, PaddingOptions } from "maplibre-gl";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* maplibre's Transform interface / CameraUpdateTransformFunction argument
|
|
6
|
+
*/
|
|
7
|
+
export type TransformLike = {
|
|
8
|
+
center: LngLat;
|
|
9
|
+
zoom: number;
|
|
10
|
+
roll?: number;
|
|
11
|
+
pitch: number;
|
|
12
|
+
bearing: number;
|
|
13
|
+
elevation: number;
|
|
14
|
+
padding?: PaddingOptions;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type {
|
|
18
|
+
GeoJSONSource as GeoJSONSourceImplementation,
|
|
19
|
+
ImageSource as ImageSourceImplementation,
|
|
20
|
+
CanvasSource as CanvasSourceImplementation,
|
|
21
|
+
VectorTileSource as VectorSourceImplementation,
|
|
22
|
+
RasterTileSource as RasterSourceImplementation,
|
|
23
|
+
RasterDEMTileSource as RasterDemSourceImplementation,
|
|
24
|
+
VideoSource as VideoSourceImplementation,
|
|
25
|
+
Source as AnySourceImplementation,
|
|
26
|
+
} from "maplibre-gl";
|
package/src/types/lib.ts
CHANGED
|
@@ -1,279 +1,84 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
addSource(id: string, source: any);
|
|
49
|
-
|
|
50
|
-
removeSource(id: string): this;
|
|
51
|
-
|
|
52
|
-
getSource(id: string): any;
|
|
53
|
-
|
|
54
|
-
addLayer(layer: any, before?: string);
|
|
55
|
-
|
|
56
|
-
moveLayer(id: string, beforeId?: string);
|
|
57
|
-
|
|
58
|
-
removeLayer(id: string);
|
|
59
|
-
|
|
60
|
-
getLayer(id: string): any;
|
|
61
|
-
|
|
62
|
-
setFilter(layer: string, filter?: any[] | boolean | null);
|
|
63
|
-
|
|
64
|
-
setLayerZoomRange(layerId: string, minzoom: number, maxzoom: number);
|
|
65
|
-
|
|
66
|
-
setPaintProperty(layer: string, name: string, value: any);
|
|
67
|
-
|
|
68
|
-
setLayoutProperty(layer: string, name: string, value: any);
|
|
69
|
-
|
|
70
|
-
project(lnglat: any): Point;
|
|
71
|
-
|
|
72
|
-
unproject(point: any): LngLat;
|
|
73
|
-
|
|
74
|
-
queryTerrainElevation?(lngLat: any, options?: any): number | null;
|
|
75
|
-
|
|
76
|
-
getContainer(): HTMLElement;
|
|
77
|
-
|
|
78
|
-
getCanvas(): HTMLCanvasElement;
|
|
79
|
-
|
|
80
|
-
remove(): void;
|
|
81
|
-
|
|
82
|
-
triggerRepaint(): void;
|
|
83
|
-
|
|
84
|
-
setPadding(padding: PaddingOptions);
|
|
85
|
-
|
|
86
|
-
fitBounds(bounds: any, options?: any);
|
|
87
|
-
|
|
88
|
-
setFog?(fog: any);
|
|
89
|
-
|
|
90
|
-
setLight?(options: any, lightOptions?: any);
|
|
91
|
-
|
|
92
|
-
setTerrain?(terrain?: any);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export interface MarkerInstance extends Evented {
|
|
96
|
-
addTo(map: MapInstance): this;
|
|
97
|
-
remove(): this;
|
|
98
|
-
|
|
99
|
-
getLngLat(): LngLat;
|
|
100
|
-
setLngLat(lngLat: LngLatLike): this;
|
|
101
|
-
|
|
102
|
-
getElement(): HTMLElement;
|
|
103
|
-
|
|
104
|
-
setPopup(popup?: any): this;
|
|
105
|
-
getPopup(): any;
|
|
106
|
-
|
|
107
|
-
getOffset(): PointLike;
|
|
108
|
-
setOffset(offset: PointLike): this;
|
|
109
|
-
|
|
110
|
-
setDraggable(value: boolean): this;
|
|
111
|
-
isDraggable(): boolean;
|
|
112
|
-
|
|
113
|
-
getRotation(): number;
|
|
114
|
-
setRotation(rotation: number): this;
|
|
115
|
-
|
|
116
|
-
getRotationAlignment(): any;
|
|
117
|
-
setRotationAlignment(alignment: any): this;
|
|
118
|
-
|
|
119
|
-
getPitchAlignment(): any;
|
|
120
|
-
setPitchAlignment(alignment: any): this;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export interface PopupInstance extends Evented {
|
|
124
|
-
options?: any;
|
|
125
|
-
|
|
126
|
-
addTo(map: MapInstance): this;
|
|
127
|
-
remove(): this;
|
|
128
|
-
|
|
129
|
-
isOpen(): boolean;
|
|
130
|
-
|
|
131
|
-
getLngLat(): LngLat;
|
|
132
|
-
setLngLat(lnglat: LngLatLike): this;
|
|
133
|
-
|
|
134
|
-
getElement(): HTMLElement;
|
|
135
|
-
|
|
136
|
-
setDOMContent(htmlNode: any): this;
|
|
137
|
-
|
|
138
|
-
getMaxWidth(): any;
|
|
139
|
-
setMaxWidth(maxWidth: any): this;
|
|
140
|
-
|
|
141
|
-
addClassName(className: string): void;
|
|
142
|
-
removeClassName(className: string): void;
|
|
143
|
-
|
|
144
|
-
setOffset(offset?: any): this;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export interface AttributionControlInstance extends IControl {
|
|
148
|
-
_container?: HTMLElement;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export interface FullscreenControlInstance extends IControl {
|
|
152
|
-
_controlContainer?: HTMLElement;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export interface GeolocateControlInstance extends IControl, Evented {
|
|
156
|
-
_container?: HTMLElement;
|
|
157
|
-
trigger();
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export interface NavigationControlInstance extends IControl {
|
|
161
|
-
_container?: HTMLElement;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export interface ScaleControlInstance extends IControl {
|
|
165
|
-
_container?: HTMLElement;
|
|
166
|
-
options?: any;
|
|
167
|
-
setUnit(unit: any): void;
|
|
168
|
-
}
|
|
1
|
+
import type {
|
|
2
|
+
Map,
|
|
3
|
+
MapOptions,
|
|
4
|
+
Marker,
|
|
5
|
+
MarkerOptions,
|
|
6
|
+
Popup,
|
|
7
|
+
PopupOptions,
|
|
8
|
+
AttributionControl,
|
|
9
|
+
AttributionControlOptions,
|
|
10
|
+
FullscreenControl,
|
|
11
|
+
FullscreenControlOptions,
|
|
12
|
+
GeolocateControl,
|
|
13
|
+
GeolocateControlOptions,
|
|
14
|
+
NavigationControl,
|
|
15
|
+
NavigationControlOptions,
|
|
16
|
+
ScaleControl,
|
|
17
|
+
ScaleControlOptions,
|
|
18
|
+
TerrainControl,
|
|
19
|
+
TerrainSpecification,
|
|
20
|
+
LogoControl,
|
|
21
|
+
LogoControlOptions,
|
|
22
|
+
} from "maplibre-gl";
|
|
23
|
+
|
|
24
|
+
export type {
|
|
25
|
+
ControlPosition,
|
|
26
|
+
IControl,
|
|
27
|
+
Map,
|
|
28
|
+
MapOptions,
|
|
29
|
+
Marker,
|
|
30
|
+
MarkerOptions,
|
|
31
|
+
Popup,
|
|
32
|
+
PopupOptions,
|
|
33
|
+
AttributionControl,
|
|
34
|
+
AttributionControlOptions,
|
|
35
|
+
FullscreenControl,
|
|
36
|
+
FullscreenControlOptions,
|
|
37
|
+
GeolocateControl,
|
|
38
|
+
GeolocateControlOptions,
|
|
39
|
+
NavigationControl,
|
|
40
|
+
NavigationControlOptions,
|
|
41
|
+
ScaleControl,
|
|
42
|
+
ScaleControlOptions,
|
|
43
|
+
TerrainControl,
|
|
44
|
+
LogoControl,
|
|
45
|
+
LogoControlOptions,
|
|
46
|
+
CustomLayerInterface,
|
|
47
|
+
} from "maplibre-gl";
|
|
169
48
|
|
|
170
49
|
/**
|
|
171
50
|
* A user-facing type that represents the minimal intersection between Mapbox and Maplibre
|
|
172
51
|
* User provided `mapLib` is supposed to implement this interface
|
|
173
52
|
* Only losely typed for compatibility
|
|
174
53
|
*/
|
|
175
|
-
export interface MapLib
|
|
54
|
+
export interface MapLib {
|
|
176
55
|
supported?: (options: any) => boolean;
|
|
177
56
|
|
|
178
|
-
Map: {new (options:
|
|
179
|
-
|
|
180
|
-
Marker: {new (...options: any[]): MarkerInstance};
|
|
181
|
-
|
|
182
|
-
Popup: {new (options: any): PopupInstance};
|
|
57
|
+
Map: { new (options: MapOptions): Map };
|
|
183
58
|
|
|
184
|
-
|
|
59
|
+
Marker: { new (options: MarkerOptions): Marker };
|
|
185
60
|
|
|
186
|
-
|
|
61
|
+
Popup: { new (options: PopupOptions): Popup };
|
|
187
62
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
NavigationControl: {new (options: any): NavigationControlInstance};
|
|
191
|
-
|
|
192
|
-
ScaleControl: {new (options: any): ScaleControlInstance};
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Stub for mapbox's Transform class
|
|
197
|
-
* https://github.com/mapbox/mapbox-gl-js/blob/main/src/geo/transform.js
|
|
198
|
-
*/
|
|
199
|
-
export type Transform = {
|
|
200
|
-
width: number;
|
|
201
|
-
height: number;
|
|
202
|
-
center: LngLat;
|
|
203
|
-
zoom: number;
|
|
204
|
-
bearing: number;
|
|
205
|
-
pitch: number;
|
|
206
|
-
padding: PaddingOptions;
|
|
207
|
-
elevation: any;
|
|
208
|
-
pixelsToGLUnits: [number, number];
|
|
209
|
-
cameraElevationReference: 'ground' | 'sea';
|
|
210
|
-
|
|
211
|
-
clone: () => Transform;
|
|
212
|
-
resize: (width: number, height: number) => void;
|
|
213
|
-
isPaddingEqual: (value: PaddingOptions) => boolean;
|
|
214
|
-
getBounds: () => any;
|
|
215
|
-
locationPoint: (lngLat: LngLat) => Point;
|
|
216
|
-
pointLocation: (p: Point) => LngLat;
|
|
217
|
-
|
|
218
|
-
// Mapbox only
|
|
219
|
-
getProjection?: () => any;
|
|
220
|
-
setProjection?: (projection: any) => void;
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
export type MapInstanceInternal<MapT extends MapInstance> = MapT & {
|
|
224
|
-
transform: Transform;
|
|
225
|
-
|
|
226
|
-
_render: Function;
|
|
227
|
-
|
|
228
|
-
_renderTaskQueue: {
|
|
229
|
-
run: Function;
|
|
63
|
+
AttributionControl: {
|
|
64
|
+
new (options: AttributionControlOptions): AttributionControl;
|
|
230
65
|
};
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
// Custom layer
|
|
234
|
-
export interface CustomLayerInterface {
|
|
235
|
-
id: string;
|
|
236
|
-
type: 'custom';
|
|
237
|
-
renderingMode?: '2d' | '3d';
|
|
238
66
|
|
|
239
|
-
|
|
240
|
-
|
|
67
|
+
FullscreenControl: {
|
|
68
|
+
new (options: FullscreenControlOptions): FullscreenControl;
|
|
69
|
+
};
|
|
241
70
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
71
|
+
GeolocateControl: {
|
|
72
|
+
new (options: GeolocateControlOptions): GeolocateControl;
|
|
73
|
+
};
|
|
245
74
|
|
|
246
|
-
|
|
75
|
+
NavigationControl: {
|
|
76
|
+
new (options: NavigationControlOptions): NavigationControl;
|
|
77
|
+
};
|
|
247
78
|
|
|
248
|
-
|
|
249
|
-
id: string;
|
|
250
|
-
type: 'custom';
|
|
251
|
-
dataType: 'raster';
|
|
252
|
-
minzoom?: number;
|
|
253
|
-
maxzoom?: number;
|
|
254
|
-
scheme?: string;
|
|
255
|
-
tileSize?: number;
|
|
256
|
-
attribution?: string;
|
|
257
|
-
bounds?: [number, number, number, number];
|
|
258
|
-
hasTile?: (tileID: {z: number; x: number; y: number}) => boolean;
|
|
259
|
-
loadTile: (
|
|
260
|
-
tileID: {z: number; x: number; y: number},
|
|
261
|
-
options: {signal: AbortSignal}
|
|
262
|
-
) => Promise<TileDataT>;
|
|
263
|
-
prepareTile?: (tileID: {z: number; x: number; y: number}) => TileDataT | undefined;
|
|
264
|
-
unloadTile?: (tileID: {z: number; x: number; y: number}) => void;
|
|
265
|
-
onAdd?: (map: MapInstance) => void;
|
|
266
|
-
onRemove?: (map: MapInstance) => void;
|
|
267
|
-
}
|
|
79
|
+
ScaleControl: { new (options: ScaleControlOptions): ScaleControl };
|
|
268
80
|
|
|
269
|
-
|
|
270
|
-
id: string;
|
|
271
|
-
type: 'custom';
|
|
272
|
-
scheme: string;
|
|
273
|
-
minzoom: number;
|
|
274
|
-
maxzoom: number;
|
|
275
|
-
tileSize: number;
|
|
276
|
-
attribution: string;
|
|
81
|
+
TerrainControl: { new (options: TerrainSpecification): TerrainControl };
|
|
277
82
|
|
|
278
|
-
|
|
83
|
+
LogoControl: { new (options: LogoControlOptions): LogoControl };
|
|
279
84
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Maplibre Style Specification types
|
|
3
|
+
* Type names are aligned with mapbox
|
|
4
|
+
*/
|
|
5
|
+
export type {
|
|
6
|
+
// Layers
|
|
7
|
+
LayerSpecification,
|
|
8
|
+
FillLayerSpecification,
|
|
9
|
+
LineLayerSpecification,
|
|
10
|
+
SymbolLayerSpecification,
|
|
11
|
+
CircleLayerSpecification,
|
|
12
|
+
HeatmapLayerSpecification,
|
|
13
|
+
FillExtrusionLayerSpecification,
|
|
14
|
+
RasterLayerSpecification,
|
|
15
|
+
HillshadeLayerSpecification,
|
|
16
|
+
BackgroundLayerSpecification,
|
|
17
|
+
|
|
18
|
+
// Sources
|
|
19
|
+
SourceSpecification,
|
|
20
|
+
VectorSourceSpecification,
|
|
21
|
+
RasterSourceSpecification,
|
|
22
|
+
RasterDEMSourceSpecification,
|
|
23
|
+
GeoJSONSourceSpecification,
|
|
24
|
+
VideoSourceSpecification,
|
|
25
|
+
ImageSourceSpecification,
|
|
26
|
+
CanvasSourceSpecification,
|
|
27
|
+
|
|
28
|
+
// Style
|
|
29
|
+
StyleSpecification,
|
|
30
|
+
SkySpecification,
|
|
31
|
+
LightSpecification,
|
|
32
|
+
TerrainSpecification,
|
|
33
|
+
ProjectionSpecification,
|
|
34
|
+
} from "maplibre-gl";
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import * as React from
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
// This is a simplified version of
|
|
3
3
|
// https://github.com/facebook/react/blob/4131af3e4bf52f3a003537ec95a1655147c81270/src/renderers/dom/shared/CSSPropertyOperations.js#L62
|
|
4
|
-
const unitlessNumber =
|
|
4
|
+
const unitlessNumber =
|
|
5
|
+
/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;
|
|
5
6
|
|
|
6
|
-
export function applyReactStyle(
|
|
7
|
+
export function applyReactStyle(
|
|
8
|
+
element: HTMLElement,
|
|
9
|
+
styles: React.CSSProperties,
|
|
10
|
+
) {
|
|
7
11
|
if (!element || !styles) {
|
|
8
12
|
return;
|
|
9
13
|
}
|