react-bkoi-gl 1.0.1
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 +96 -0
- package/bkoi-gl/package.json +6 -0
- package/dist/components/attribution-control.d.ts +11 -0
- package/dist/components/attribution-control.js +19 -0
- package/dist/components/attribution-control.js.map +1 -0
- package/dist/components/fullscreen-control.d.ts +14 -0
- package/dist/components/fullscreen-control.js +21 -0
- package/dist/components/fullscreen-control.js.map +1 -0
- package/dist/components/geolocate-control.d.ts +37 -0
- package/dist/components/geolocate-control.js +51 -0
- package/dist/components/geolocate-control.js.map +1 -0
- package/dist/components/layer.d.ts +17 -0
- package/dist/components/layer.js +99 -0
- package/dist/components/layer.js.map +1 -0
- package/dist/components/map.d.ts +23 -0
- package/dist/components/map.js +102 -0
- package/dist/components/map.js.map +1 -0
- package/dist/components/marker.d.ts +41 -0
- package/dist/components/marker.js +102 -0
- package/dist/components/marker.js.map +1 -0
- package/dist/components/navigation-control.d.ts +11 -0
- package/dist/components/navigation-control.js +19 -0
- package/dist/components/navigation-control.js.map +1 -0
- package/dist/components/popup.d.ts +33 -0
- package/dist/components/popup.js +81 -0
- package/dist/components/popup.js.map +1 -0
- package/dist/components/scale-control.d.ts +13 -0
- package/dist/components/scale-control.js +31 -0
- package/dist/components/scale-control.js.map +1 -0
- package/dist/components/source.d.ts +7 -0
- package/dist/components/source.js +98 -0
- package/dist/components/source.js.map +1 -0
- package/dist/components/use-control.d.ts +9 -0
- package/dist/components/use-control.js +31 -0
- package/dist/components/use-control.js.map +1 -0
- package/dist/components/use-map.d.ts +20 -0
- package/dist/components/use-map.js +55 -0
- package/dist/components/use-map.js.map +1 -0
- package/dist/exports-bkoi-gl.cjs +1512 -0
- package/dist/exports-bkoi-gl.d.ts +89 -0
- package/dist/exports-bkoi-gl.js +36 -0
- package/dist/exports-bkoi-gl.js.map +1 -0
- package/dist/exports-mapbox.d.ts +139 -0
- package/dist/exports-mapbox.js +36 -0
- package/dist/exports-mapbox.js.map +1 -0
- package/dist/index.cjs +1514 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/mapbox/create-ref.d.ts +9 -0
- package/dist/mapbox/create-ref.js +64 -0
- package/dist/mapbox/create-ref.js.map +1 -0
- package/dist/mapbox/mapbox.d.ts +81 -0
- package/dist/mapbox/mapbox.js +477 -0
- package/dist/mapbox/mapbox.js.map +1 -0
- package/dist/styles/react-bkoi-gl.css +1 -0
- package/dist/types/common.d.ts +78 -0
- package/dist/types/common.js +2 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/events-bkoi-gl.d.ts +49 -0
- package/dist/types/events-bkoi-gl.js +2 -0
- package/dist/types/events-bkoi-gl.js.map +1 -0
- package/dist/types/events-mapbox.d.ts +49 -0
- package/dist/types/events-mapbox.js +2 -0
- package/dist/types/events-mapbox.js.map +1 -0
- package/dist/types/events.d.ts +39 -0
- package/dist/types/events.js +2 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/index.d.ts +70 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/lib.d.ts +224 -0
- package/dist/types/lib.js +2 -0
- package/dist/types/lib.js.map +1 -0
- package/dist/types/public.d.ts +2 -0
- package/dist/types/public.js +2 -0
- package/dist/types/public.js.map +1 -0
- package/dist/types/style-spec-bkoi-gl.d.ts +9 -0
- package/dist/types/style-spec-bkoi-gl.js +2 -0
- package/dist/types/style-spec-bkoi-gl.js.map +1 -0
- package/dist/types/style-spec-mapbox.d.ts +7 -0
- package/dist/types/style-spec-mapbox.js +2 -0
- package/dist/types/style-spec-mapbox.js.map +1 -0
- package/dist/utils/apply-react-style.d.ts +2 -0
- package/dist/utils/apply-react-style.js +16 -0
- package/dist/utils/apply-react-style.js.map +1 -0
- package/dist/utils/assert.d.ts +1 -0
- package/dist/utils/assert.js +6 -0
- package/dist/utils/assert.js.map +1 -0
- package/dist/utils/deep-equal.d.ts +15 -0
- package/dist/utils/deep-equal.js +46 -0
- package/dist/utils/deep-equal.js.map +1 -0
- package/dist/utils/set-globals.d.ts +22 -0
- package/dist/utils/set-globals.js +19 -0
- package/dist/utils/set-globals.js.map +1 -0
- package/dist/utils/style-utils.d.ts +2 -0
- package/dist/utils/style-utils.js +42 -0
- package/dist/utils/style-utils.js.map +1 -0
- package/dist/utils/transform.d.ts +26 -0
- package/dist/utils/transform.js +56 -0
- package/dist/utils/transform.js.map +1 -0
- package/dist/utils/use-isomorphic-layout-effect.d.ts +3 -0
- package/dist/utils/use-isomorphic-layout-effect.js +4 -0
- package/dist/utils/use-isomorphic-layout-effect.js.map +1 -0
- package/package.json +78 -0
- package/src/components/attribution-control.ts +32 -0
- package/src/components/fullscreen-control.tsx +37 -0
- package/src/components/geolocate-control.ts +90 -0
- package/src/components/layer.ts +133 -0
- package/src/components/map.tsx +155 -0
- package/src/components/marker.ts +137 -0
- package/src/components/navigation-control.ts +29 -0
- package/src/components/popup.ts +116 -0
- package/src/components/scale-control.ts +46 -0
- package/src/components/source.ts +158 -0
- package/src/components/use-control.ts +64 -0
- package/src/components/use-map.tsx +69 -0
- package/src/exports-bkoi-gl.ts +156 -0
- package/src/exports-mapbox.ts +159 -0
- package/src/index.ts +2 -0
- package/src/mapbox/create-ref.ts +118 -0
- package/src/mapbox/mapbox.ts +742 -0
- package/src/types/common.ts +94 -0
- package/src/types/events-bkoi-gl.ts +78 -0
- package/src/types/events-mapbox.ts +76 -0
- package/src/types/events.ts +73 -0
- package/src/types/index.ts +93 -0
- package/src/types/lib.ts +279 -0
- package/src/types/public.ts +9 -0
- package/src/types/style-spec-bkoi-gl.ts +81 -0
- package/src/types/style-spec-mapbox.ts +80 -0
- package/src/utils/apply-react-style.ts +20 -0
- package/src/utils/assert.ts +5 -0
- package/src/utils/deep-equal.ts +61 -0
- package/src/utils/set-globals.ts +57 -0
- package/src/utils/style-utils.ts +59 -0
- package/src/utils/transform.ts +86 -0
- package/src/utils/use-isomorphic-layout-effect.ts +7 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type GeoJSON from 'geojson';
|
|
2
|
+
|
|
3
|
+
/* Data types that are compatible with both mapbox and maplibre. Not exposed to the end user. */
|
|
4
|
+
|
|
5
|
+
/** @mapbox/point-geometry */
|
|
6
|
+
export interface Point {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
}
|
|
10
|
+
export type PointLike = Point | [number, number];
|
|
11
|
+
|
|
12
|
+
export interface LngLat {
|
|
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
|
+
};
|
|
71
|
+
|
|
72
|
+
/* Public */
|
|
73
|
+
|
|
74
|
+
/** Describes the camera's state */
|
|
75
|
+
export type ViewState = {
|
|
76
|
+
/** Longitude at map center */
|
|
77
|
+
longitude: number;
|
|
78
|
+
/** Latitude at map center */
|
|
79
|
+
latitude: number;
|
|
80
|
+
/** Map zoom level */
|
|
81
|
+
zoom: number;
|
|
82
|
+
/** Map rotation bearing in degrees counter-clockwise from north */
|
|
83
|
+
bearing: number;
|
|
84
|
+
/** Map angle in degrees at which the camera is looking at the ground */
|
|
85
|
+
pitch: number;
|
|
86
|
+
/** Dimensions in pixels applied on each side of the viewport for shifting the vanishing point. */
|
|
87
|
+
padding: PaddingOptions;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export type ControlPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
|
|
91
|
+
|
|
92
|
+
export interface ImmutableLike<T> {
|
|
93
|
+
toJS: () => T;
|
|
94
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Map,
|
|
3
|
+
MapLibreEvent as MapEvent,
|
|
4
|
+
MapMouseEvent,
|
|
5
|
+
MapLayerMouseEvent,
|
|
6
|
+
MapTouchEvent,
|
|
7
|
+
MapLayerTouchEvent,
|
|
8
|
+
MapStyleDataEvent,
|
|
9
|
+
MapSourceDataEvent,
|
|
10
|
+
MapWheelEvent,
|
|
11
|
+
MapLibreZoomEvent as MapBoxZoomEvent
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
// eslint-disable-next-line import/no-unresolved
|
|
14
|
+
} from 'bkoi-gl';
|
|
15
|
+
import {ErrorEvent as _ErrorEvent, ViewStateChangeEvent as _ViewStateChangeEvent} from './events';
|
|
16
|
+
|
|
17
|
+
export type {
|
|
18
|
+
MapEvent,
|
|
19
|
+
MapMouseEvent,
|
|
20
|
+
MapLayerMouseEvent,
|
|
21
|
+
MapTouchEvent,
|
|
22
|
+
MapLayerTouchEvent,
|
|
23
|
+
MapStyleDataEvent,
|
|
24
|
+
MapSourceDataEvent,
|
|
25
|
+
MapWheelEvent,
|
|
26
|
+
MapBoxZoomEvent
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type ErrorEvent = _ErrorEvent<Map>;
|
|
30
|
+
export type ViewStateChangeEvent = _ViewStateChangeEvent<Map>;
|
|
31
|
+
|
|
32
|
+
export type MapCallbacks = {
|
|
33
|
+
onMouseDown?: (e: MapLayerMouseEvent) => void;
|
|
34
|
+
onMouseUp?: (e: MapLayerMouseEvent) => void;
|
|
35
|
+
onMouseOver?: (e: MapLayerMouseEvent) => void;
|
|
36
|
+
onMouseMove?: (e: MapLayerMouseEvent) => void;
|
|
37
|
+
onClick?: (e: MapLayerMouseEvent) => void;
|
|
38
|
+
onDblClick?: (e: MapLayerMouseEvent) => void;
|
|
39
|
+
onMouseEnter?: (e: MapLayerMouseEvent) => void;
|
|
40
|
+
onMouseLeave?: (e: MapLayerMouseEvent) => void;
|
|
41
|
+
onMouseOut?: (e: MapLayerMouseEvent) => void;
|
|
42
|
+
onContextMenu?: (e: MapLayerMouseEvent) => void;
|
|
43
|
+
onTouchStart?: (e: MapLayerTouchEvent) => void;
|
|
44
|
+
onTouchEnd?: (e: MapLayerTouchEvent) => void;
|
|
45
|
+
onTouchMove?: (e: MapLayerTouchEvent) => void;
|
|
46
|
+
onTouchCancel?: (e: MapLayerTouchEvent) => void;
|
|
47
|
+
|
|
48
|
+
onMoveStart?: (e: ViewStateChangeEvent) => void;
|
|
49
|
+
onMove?: (e: ViewStateChangeEvent) => void;
|
|
50
|
+
onMoveEnd?: (e: ViewStateChangeEvent) => void;
|
|
51
|
+
onDragStart?: (e: ViewStateChangeEvent) => void;
|
|
52
|
+
onDrag?: (e: ViewStateChangeEvent) => void;
|
|
53
|
+
onDragEnd?: (e: ViewStateChangeEvent) => void;
|
|
54
|
+
onZoomStart?: (e: ViewStateChangeEvent) => void;
|
|
55
|
+
onZoom?: (e: ViewStateChangeEvent) => void;
|
|
56
|
+
onZoomEnd?: (e: ViewStateChangeEvent) => void;
|
|
57
|
+
onRotateStart?: (e: ViewStateChangeEvent) => void;
|
|
58
|
+
onRotate?: (e: ViewStateChangeEvent) => void;
|
|
59
|
+
onRotateEnd?: (e: ViewStateChangeEvent) => void;
|
|
60
|
+
onPitchStart?: (e: ViewStateChangeEvent) => void;
|
|
61
|
+
onPitch?: (e: ViewStateChangeEvent) => void;
|
|
62
|
+
onPitchEnd?: (e: ViewStateChangeEvent) => void;
|
|
63
|
+
|
|
64
|
+
onWheel?: (e: MapWheelEvent) => void;
|
|
65
|
+
onBoxZoomStart?: (e: MapBoxZoomEvent) => void;
|
|
66
|
+
onBoxZoomEnd?: (e: MapBoxZoomEvent) => void;
|
|
67
|
+
onBoxZoomCancel?: (e: MapBoxZoomEvent) => void;
|
|
68
|
+
|
|
69
|
+
onResize?: (e: MapEvent) => void;
|
|
70
|
+
onLoad?: (e: MapEvent) => void;
|
|
71
|
+
onRender?: (e: MapEvent) => void;
|
|
72
|
+
onIdle?: (e: MapEvent) => void;
|
|
73
|
+
onError?: (e: ErrorEvent) => void;
|
|
74
|
+
onRemove?: (e: MapEvent) => void;
|
|
75
|
+
onData?: (e: MapStyleDataEvent | MapSourceDataEvent) => void;
|
|
76
|
+
onStyleData?: (e: MapStyleDataEvent) => void;
|
|
77
|
+
onSourceData?: (e: MapSourceDataEvent) => void;
|
|
78
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Map,
|
|
3
|
+
MapboxEvent as MapEvent,
|
|
4
|
+
MapMouseEvent,
|
|
5
|
+
MapLayerMouseEvent,
|
|
6
|
+
MapTouchEvent,
|
|
7
|
+
MapLayerTouchEvent,
|
|
8
|
+
MapStyleDataEvent,
|
|
9
|
+
MapSourceDataEvent,
|
|
10
|
+
MapWheelEvent,
|
|
11
|
+
MapBoxZoomEvent
|
|
12
|
+
} from 'mapbox-gl';
|
|
13
|
+
import {ErrorEvent as _ErrorEvent, ViewStateChangeEvent as _ViewStateChangeEvent} from './events';
|
|
14
|
+
|
|
15
|
+
export type {
|
|
16
|
+
MapEvent,
|
|
17
|
+
MapMouseEvent,
|
|
18
|
+
MapLayerMouseEvent,
|
|
19
|
+
MapTouchEvent,
|
|
20
|
+
MapLayerTouchEvent,
|
|
21
|
+
MapStyleDataEvent,
|
|
22
|
+
MapSourceDataEvent,
|
|
23
|
+
MapWheelEvent,
|
|
24
|
+
MapBoxZoomEvent
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type ErrorEvent = _ErrorEvent<Map>;
|
|
28
|
+
export type ViewStateChangeEvent = _ViewStateChangeEvent<Map>;
|
|
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: MapEvent) => void;
|
|
68
|
+
onLoad?: (e: MapEvent) => void;
|
|
69
|
+
onRender?: (e: MapEvent) => void;
|
|
70
|
+
onIdle?: (e: MapEvent) => void;
|
|
71
|
+
onError?: (e: ErrorEvent) => void;
|
|
72
|
+
onRemove?: (e: MapEvent) => void;
|
|
73
|
+
onData?: (e: MapStyleDataEvent | MapSourceDataEvent) => void;
|
|
74
|
+
onStyleData?: (e: MapStyleDataEvent) => void;
|
|
75
|
+
onSourceData?: (e: MapSourceDataEvent) => void;
|
|
76
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type {ViewState, Point, LngLat, MapGeoJSONFeature} from './common';
|
|
2
|
+
import type {
|
|
3
|
+
MapInstance,
|
|
4
|
+
Evented,
|
|
5
|
+
MarkerInstance,
|
|
6
|
+
PopupInstance,
|
|
7
|
+
GeolocateControlInstance
|
|
8
|
+
} from './lib';
|
|
9
|
+
|
|
10
|
+
export interface Callbacks {
|
|
11
|
+
[key: `on${string}`]: Function;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface MapEvent<SourceT extends Evented, OriginalEventT = undefined> {
|
|
15
|
+
type: string;
|
|
16
|
+
target: SourceT;
|
|
17
|
+
originalEvent: OriginalEventT;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type ErrorEvent<MapT extends MapInstance> = MapEvent<MapT> & {
|
|
21
|
+
type: 'error';
|
|
22
|
+
error: Error;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type MapMouseEvent<MapT extends MapInstance> = MapEvent<MapT, MouseEvent> & {
|
|
26
|
+
point: Point;
|
|
27
|
+
lngLat: LngLat;
|
|
28
|
+
features?: MapGeoJSONFeature[];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type ViewStateChangeEvent<MapT extends MapInstance> =
|
|
32
|
+
| (MapEvent<MapT, MouseEvent | TouchEvent | WheelEvent | undefined> & {
|
|
33
|
+
type: 'movestart' | 'move' | 'moveend' | 'zoomstart' | 'zoom' | 'zoomend';
|
|
34
|
+
viewState: ViewState;
|
|
35
|
+
})
|
|
36
|
+
| (MapEvent<MapT, MouseEvent | TouchEvent | undefined> & {
|
|
37
|
+
type:
|
|
38
|
+
| 'rotatestart'
|
|
39
|
+
| 'rotate'
|
|
40
|
+
| 'rotateend'
|
|
41
|
+
| 'dragstart'
|
|
42
|
+
| 'drag'
|
|
43
|
+
| 'dragend'
|
|
44
|
+
| 'pitchstart'
|
|
45
|
+
| 'pitch'
|
|
46
|
+
| 'pitchend';
|
|
47
|
+
viewState: ViewState;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export type PopupEvent<PopupT extends PopupInstance> = {
|
|
51
|
+
type: 'open' | 'close';
|
|
52
|
+
target: PopupT;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type MarkerEvent<MarkerT extends MarkerInstance, OriginalEventT = undefined> = MapEvent<
|
|
56
|
+
MarkerT,
|
|
57
|
+
OriginalEventT
|
|
58
|
+
>;
|
|
59
|
+
|
|
60
|
+
export type MarkerDragEvent<MarkerT extends MarkerInstance> = MarkerEvent<MarkerT> & {
|
|
61
|
+
type: 'dragstart' | 'drag' | 'dragend';
|
|
62
|
+
target: MarkerT;
|
|
63
|
+
lngLat: LngLat;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export type GeolocateEvent<GeolocateControlT extends GeolocateControlInstance> =
|
|
67
|
+
MapEvent<GeolocateControlT>;
|
|
68
|
+
|
|
69
|
+
export type GeolocateResultEvent<GeolocateControlT extends GeolocateControlInstance> =
|
|
70
|
+
GeolocateEvent<GeolocateControlT> & GeolocationPosition;
|
|
71
|
+
|
|
72
|
+
export type GeolocateErrorEvent<GeolocateControlT extends GeolocateControlInstance> =
|
|
73
|
+
GeolocateEvent<GeolocateControlT> & GeolocationPositionError;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export * from './common';
|
|
2
|
+
export * from './lib';
|
|
3
|
+
export * from './events';
|
|
4
|
+
|
|
5
|
+
import type GeoJSON from 'geojson';
|
|
6
|
+
import type {CustomSourceImplementation} from './lib';
|
|
7
|
+
|
|
8
|
+
// Internal: source implementations
|
|
9
|
+
|
|
10
|
+
export interface ISource {
|
|
11
|
+
type: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ILayer {
|
|
15
|
+
id: string;
|
|
16
|
+
type: string;
|
|
17
|
+
|
|
18
|
+
metadata?: any;
|
|
19
|
+
source?: unknown;
|
|
20
|
+
|
|
21
|
+
minzoom?: number;
|
|
22
|
+
maxzoom?: number;
|
|
23
|
+
|
|
24
|
+
filter?: any;
|
|
25
|
+
layout?: {
|
|
26
|
+
[property: string]: any;
|
|
27
|
+
};
|
|
28
|
+
paint?: {
|
|
29
|
+
[property: string]: any;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface MapStyle {
|
|
34
|
+
name?: string;
|
|
35
|
+
metadata?: unknown;
|
|
36
|
+
version: number;
|
|
37
|
+
layers: ILayer[];
|
|
38
|
+
sources: {
|
|
39
|
+
[sourceName: string]: object;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
fog?: any;
|
|
43
|
+
terrain?: any;
|
|
44
|
+
light?: any;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface GeoJSONSourceImplementation {
|
|
48
|
+
type: 'geojson';
|
|
49
|
+
setData(
|
|
50
|
+
data: GeoJSON.Feature<GeoJSON.Geometry> | GeoJSON.FeatureCollection<GeoJSON.Geometry> | String
|
|
51
|
+
): this;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface ImageSourceImplemtation {
|
|
55
|
+
type: 'image';
|
|
56
|
+
updateImage(options: {url?: string; coordinates?: number[][]}): this;
|
|
57
|
+
setCoordinates(coordinates: number[][]): this;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface CanvasSourceImplemtation {
|
|
61
|
+
type: 'canvas';
|
|
62
|
+
play(): void;
|
|
63
|
+
pause(): void;
|
|
64
|
+
getCanvas(): HTMLCanvasElement;
|
|
65
|
+
setCoordinates(coordinates: number[][]): this;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface VectorSourceImplementation {
|
|
69
|
+
type: 'vector';
|
|
70
|
+
setTiles(tiles: ReadonlyArray<string>): this;
|
|
71
|
+
setUrl(url: string): this;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface RasterSourceImplementation {
|
|
75
|
+
type: 'raster' | 'raster-dem';
|
|
76
|
+
setTiles(tiles: ReadonlyArray<string>): this;
|
|
77
|
+
setUrl(url: string): this;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface VideoSourceImplementation {
|
|
81
|
+
type: 'video';
|
|
82
|
+
getVideo(): HTMLVideoElement;
|
|
83
|
+
setCoordinates(coordinates: number[][]): this;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export type AnySourceImplementation =
|
|
87
|
+
| GeoJSONSourceImplementation
|
|
88
|
+
| VideoSourceImplementation
|
|
89
|
+
| ImageSourceImplemtation
|
|
90
|
+
| CanvasSourceImplemtation
|
|
91
|
+
| VectorSourceImplementation
|
|
92
|
+
| RasterSourceImplementation
|
|
93
|
+
| CustomSourceImplementation<HTMLImageElement | ImageData | ImageBitmap>;
|
package/src/types/lib.ts
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import type {PaddingOptions, LngLat, Point, LngLatLike, PointLike, ControlPosition} from './common';
|
|
2
|
+
|
|
3
|
+
export interface IControl<MapT extends MapInstance = MapInstance> {
|
|
4
|
+
onAdd(map: MapT): HTMLElement;
|
|
5
|
+
|
|
6
|
+
onRemove(map: MapT): void;
|
|
7
|
+
|
|
8
|
+
getDefaultPosition?: (() => string) | undefined;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type Listener = (event?: any) => any;
|
|
12
|
+
|
|
13
|
+
export interface Evented {
|
|
14
|
+
on(type: string, listener: Listener);
|
|
15
|
+
|
|
16
|
+
off(type?: string | any, listener?: Listener);
|
|
17
|
+
|
|
18
|
+
once(type: string, listener: Listener);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A user-facing type that represents the minimal intersection between Mapbox.Map and Maplibre.Map
|
|
23
|
+
* User provided `mapLib.Map` is supposed to implement this interface
|
|
24
|
+
* Only losely typed for compatibility
|
|
25
|
+
*/
|
|
26
|
+
export interface MapInstance extends Evented {
|
|
27
|
+
// https://github.com/mapbox/mapbox-gl-js/issues/6522
|
|
28
|
+
fire(type: string, properties?: {[key: string]: any});
|
|
29
|
+
|
|
30
|
+
addControl(control: IControl<this>, position?: ControlPosition);
|
|
31
|
+
|
|
32
|
+
removeControl(control: IControl<this>);
|
|
33
|
+
|
|
34
|
+
hasControl(control: IControl<this>): boolean;
|
|
35
|
+
|
|
36
|
+
resize(): this;
|
|
37
|
+
|
|
38
|
+
queryRenderedFeatures(geometry?: any, options?: any): any[];
|
|
39
|
+
|
|
40
|
+
setStyle(style: any, options?: any);
|
|
41
|
+
|
|
42
|
+
isMoving(): boolean;
|
|
43
|
+
|
|
44
|
+
getStyle(): any;
|
|
45
|
+
|
|
46
|
+
isStyleLoaded(): boolean | void;
|
|
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
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* A user-facing type that represents the minimal intersection between Mapbox and Maplibre
|
|
172
|
+
* User provided `mapLib` is supposed to implement this interface
|
|
173
|
+
* Only losely typed for compatibility
|
|
174
|
+
*/
|
|
175
|
+
export interface MapLib<MapT extends MapInstance> {
|
|
176
|
+
supported?: (options: any) => boolean;
|
|
177
|
+
|
|
178
|
+
Map: {new (options: any): MapT};
|
|
179
|
+
|
|
180
|
+
Marker: {new (...options: any[]): MarkerInstance};
|
|
181
|
+
|
|
182
|
+
Popup: {new (options: any): PopupInstance};
|
|
183
|
+
|
|
184
|
+
AttributionControl: {new (options: any): AttributionControlInstance};
|
|
185
|
+
|
|
186
|
+
FullscreenControl: {new (options: any): FullscreenControlInstance};
|
|
187
|
+
|
|
188
|
+
GeolocateControl: {new (options: any): GeolocateControlInstance};
|
|
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;
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
// Custom layer
|
|
234
|
+
export interface CustomLayerInterface {
|
|
235
|
+
id: string;
|
|
236
|
+
type: 'custom';
|
|
237
|
+
renderingMode?: '2d' | '3d';
|
|
238
|
+
|
|
239
|
+
onRemove?(map: MapInstance, gl: WebGLRenderingContext): void;
|
|
240
|
+
onAdd?(map: MapInstance, gl: WebGLRenderingContext): void;
|
|
241
|
+
|
|
242
|
+
prerender?(gl: WebGLRenderingContext, matrix: number[]): void;
|
|
243
|
+
render(gl: WebGLRenderingContext, matrix: number[]): void;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Custom source
|
|
247
|
+
|
|
248
|
+
export interface CustomSourceImplementation<TileDataT> {
|
|
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
|
+
}
|
|
268
|
+
|
|
269
|
+
export interface CustomSource<TileDataT = unknown> {
|
|
270
|
+
id: string;
|
|
271
|
+
type: 'custom';
|
|
272
|
+
scheme: string;
|
|
273
|
+
minzoom: number;
|
|
274
|
+
maxzoom: number;
|
|
275
|
+
tileSize: number;
|
|
276
|
+
attribution: string;
|
|
277
|
+
|
|
278
|
+
_implementation: CustomSourceImplementation<TileDataT>;
|
|
279
|
+
}
|