react-bkoi-gl 1.0.7 → 2.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/LICENSE +21 -0
- package/README.md +172 -18
- package/dist/index.cjs +671 -736
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +370 -0
- package/dist/index.d.ts +370 -2
- package/dist/index.js +1434 -2
- package/dist/index.js.map +1 -1
- package/dist/styles/index.d.ts +4 -0
- package/dist/styles/react-bkoi-gl.css +1 -1
- package/package.json +84 -36
- package/bkoi-gl/package.json +0 -6
- package/dist/components/attribution-control.d.ts +0 -11
- package/dist/components/attribution-control.js +0 -19
- package/dist/components/attribution-control.js.map +0 -1
- package/dist/components/fullscreen-control.d.ts +0 -14
- package/dist/components/fullscreen-control.js +0 -21
- package/dist/components/fullscreen-control.js.map +0 -1
- package/dist/components/geolocate-control.d.ts +0 -37
- package/dist/components/geolocate-control.js +0 -46
- package/dist/components/geolocate-control.js.map +0 -1
- package/dist/components/layer.d.ts +0 -17
- package/dist/components/layer.js +0 -99
- package/dist/components/layer.js.map +0 -1
- package/dist/components/map.d.ts +0 -23
- package/dist/components/map.js +0 -102
- package/dist/components/map.js.map +0 -1
- package/dist/components/marker.d.ts +0 -41
- package/dist/components/marker.js +0 -98
- package/dist/components/marker.js.map +0 -1
- package/dist/components/navigation-control.d.ts +0 -11
- package/dist/components/navigation-control.js +0 -19
- package/dist/components/navigation-control.js.map +0 -1
- package/dist/components/popup.d.ts +0 -33
- package/dist/components/popup.js +0 -79
- package/dist/components/popup.js.map +0 -1
- package/dist/components/scale-control.d.ts +0 -13
- package/dist/components/scale-control.js +0 -31
- package/dist/components/scale-control.js.map +0 -1
- package/dist/components/source.d.ts +0 -7
- package/dist/components/source.js +0 -97
- package/dist/components/source.js.map +0 -1
- package/dist/components/use-control.d.ts +0 -9
- package/dist/components/use-control.js +0 -31
- package/dist/components/use-control.js.map +0 -1
- package/dist/components/use-map.d.ts +0 -20
- package/dist/components/use-map.js +0 -54
- package/dist/components/use-map.js.map +0 -1
- 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.d.ts +0 -9
- 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/common.d.ts +0 -78
- package/dist/types/common.js +0 -2
- package/dist/types/common.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/events.d.ts +0 -39
- package/dist/types/events.js +0 -2
- package/dist/types/events.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/lib.d.ts +0 -224
- package/dist/types/lib.js +0 -2
- package/dist/types/lib.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/dist/utils/apply-react-style.d.ts +0 -2
- package/dist/utils/apply-react-style.js +0 -16
- package/dist/utils/apply-react-style.js.map +0 -1
- package/dist/utils/assert.d.ts +0 -1
- package/dist/utils/assert.js +0 -6
- package/dist/utils/assert.js.map +0 -1
- package/dist/utils/deep-equal.d.ts +0 -15
- package/dist/utils/deep-equal.js +0 -46
- package/dist/utils/deep-equal.js.map +0 -1
- package/dist/utils/set-globals.d.ts +0 -22
- package/dist/utils/set-globals.js +0 -19
- package/dist/utils/set-globals.js.map +0 -1
- package/dist/utils/style-utils.d.ts +0 -2
- package/dist/utils/style-utils.js +0 -42
- package/dist/utils/style-utils.js.map +0 -1
- package/dist/utils/transform.d.ts +0 -26
- package/dist/utils/transform.js +0 -56
- package/dist/utils/transform.js.map +0 -1
- package/dist/utils/use-isomorphic-layout-effect.d.ts +0 -3
- package/dist/utils/use-isomorphic-layout-effect.js +0 -4
- package/dist/utils/use-isomorphic-layout-effect.js.map +0 -1
- package/src/components/attribution-control.ts +0 -32
- package/src/components/fullscreen-control.tsx +0 -37
- package/src/components/geolocate-control.ts +0 -90
- package/src/components/layer.ts +0 -133
- package/src/components/map.tsx +0 -155
- package/src/components/marker.ts +0 -137
- package/src/components/navigation-control.ts +0 -29
- package/src/components/popup.ts +0 -116
- package/src/components/scale-control.ts +0 -46
- package/src/components/source.ts +0 -158
- package/src/components/use-control.ts +0 -64
- package/src/components/use-map.tsx +0 -69
- package/src/exports-bkoi-gl.ts +0 -156
- package/src/exports-mapbox.ts +0 -159
- package/src/index.ts +0 -2
- package/src/mapbox/create-ref.ts +0 -118
- package/src/mapbox/mapbox.ts +0 -742
- package/src/types/common.ts +0 -94
- package/src/types/events-bkoi-gl.ts +0 -78
- package/src/types/events-mapbox.ts +0 -76
- package/src/types/events.ts +0 -73
- package/src/types/index.ts +0 -93
- package/src/types/lib.ts +0 -279
- 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/utils/apply-react-style.ts +0 -20
- package/src/utils/assert.ts +0 -5
- package/src/utils/deep-equal.ts +0 -61
- package/src/utils/set-globals.ts +0 -57
- package/src/utils/style-utils.ts +0 -59
- package/src/utils/transform.ts +0 -86
- package/src/utils/use-isomorphic-layout-effect.ts +0 -7
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import {useState, useCallback, useMemo, useContext} from 'react';
|
|
3
|
-
|
|
4
|
-
import {MapRef} from '../mapbox/create-ref';
|
|
5
|
-
import {MapContext} from './map';
|
|
6
|
-
import {MapInstance} from '../types';
|
|
7
|
-
|
|
8
|
-
type MountedMapsContextValue = {
|
|
9
|
-
maps: {[id: string]: MapRef<MapInstance>};
|
|
10
|
-
onMapMount: (map: MapRef<MapInstance>, id: string) => void;
|
|
11
|
-
onMapUnmount: (id: string) => void;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const MountedMapsContext = React.createContext<MountedMapsContextValue>(null);
|
|
15
|
-
|
|
16
|
-
export const MapProvider: React.FC<{children?: React.ReactNode}> = props => {
|
|
17
|
-
const [maps, setMaps] = useState<{[id: string]: MapRef<MapInstance>}>({});
|
|
18
|
-
|
|
19
|
-
const onMapMount = useCallback((map: MapRef<MapInstance>, id: string = 'default') => {
|
|
20
|
-
setMaps(currMaps => {
|
|
21
|
-
if (id === 'current') {
|
|
22
|
-
throw new Error("'current' cannot be used as map id");
|
|
23
|
-
}
|
|
24
|
-
if (currMaps[id]) {
|
|
25
|
-
throw new Error(`Multiple maps with the same id: ${id}`);
|
|
26
|
-
}
|
|
27
|
-
return {...currMaps, [id]: map};
|
|
28
|
-
});
|
|
29
|
-
}, []);
|
|
30
|
-
|
|
31
|
-
const onMapUnmount = useCallback((id: string = 'default') => {
|
|
32
|
-
setMaps(currMaps => {
|
|
33
|
-
if (currMaps[id]) {
|
|
34
|
-
const nextMaps = {...currMaps};
|
|
35
|
-
delete nextMaps[id];
|
|
36
|
-
return nextMaps;
|
|
37
|
-
}
|
|
38
|
-
return currMaps;
|
|
39
|
-
});
|
|
40
|
-
}, []);
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<MountedMapsContext.Provider
|
|
44
|
-
value={{
|
|
45
|
-
maps,
|
|
46
|
-
onMapMount,
|
|
47
|
-
onMapUnmount
|
|
48
|
-
}}
|
|
49
|
-
>
|
|
50
|
-
{props.children}
|
|
51
|
-
</MountedMapsContext.Provider>
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export type MapCollection<MapT extends MapInstance> = {
|
|
56
|
-
[id: string]: MapRef<MapT> | undefined;
|
|
57
|
-
current?: MapRef<MapT>;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export function useMap<MapT extends MapInstance>(): MapCollection<MapT> {
|
|
61
|
-
const maps = useContext(MountedMapsContext)?.maps;
|
|
62
|
-
const currentMap = useContext(MapContext);
|
|
63
|
-
|
|
64
|
-
const mapsWithCurrent = useMemo(() => {
|
|
65
|
-
return {...maps, current: currentMap?.map};
|
|
66
|
-
}, [maps, currentMap]);
|
|
67
|
-
|
|
68
|
-
return mapsWithCurrent as MapCollection<MapT>;
|
|
69
|
-
}
|
package/src/exports-bkoi-gl.ts
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Map as BkoiMap,
|
|
4
|
-
MapOptions,
|
|
5
|
-
Marker as BkoiMarker,
|
|
6
|
-
MarkerOptions,
|
|
7
|
-
Popup as BkoiPopup,
|
|
8
|
-
PopupOptions,
|
|
9
|
-
AttributionControl as BkoiAttributionControl,
|
|
10
|
-
FullscreenControl as BkoiFullscreenControl,
|
|
11
|
-
GeolocateControl as BkoiGeolocateControl,
|
|
12
|
-
NavigationControl as BkoiNavigationControl,
|
|
13
|
-
ScaleControl as BkoiScaleControl
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
// eslint-disable-next-line import/no-unresolved
|
|
16
|
-
} from 'bkoi-gl';
|
|
17
|
-
import { MapStyle, AnyLayer, AnySource } from './types/style-spec-bkoi-gl';
|
|
18
|
-
|
|
19
|
-
import { default as _Map, MapProps as _MapProps } from './components/map';
|
|
20
|
-
import { default as _Marker, MarkerProps as _MarkerProps } from './components/marker';
|
|
21
|
-
import { default as _Popup, PopupProps as _PopupProps } from './components/popup';
|
|
22
|
-
import {
|
|
23
|
-
default as _AttributionControl,
|
|
24
|
-
AttributionControlProps as _AttributionControlProps
|
|
25
|
-
} from './components/attribution-control';
|
|
26
|
-
import {
|
|
27
|
-
default as _FullscreenControl,
|
|
28
|
-
FullscreenControlProps as _FullscreenControlProps
|
|
29
|
-
} from './components/fullscreen-control';
|
|
30
|
-
import {
|
|
31
|
-
default as _GeolocateControl,
|
|
32
|
-
GeolocateControlProps as _GeolocateControlProps
|
|
33
|
-
} from './components/geolocate-control';
|
|
34
|
-
import {
|
|
35
|
-
default as _NavigationControl,
|
|
36
|
-
NavigationControlProps as _NavigationControlProps
|
|
37
|
-
} from './components/navigation-control';
|
|
38
|
-
import {
|
|
39
|
-
default as _ScaleControl,
|
|
40
|
-
ScaleControlProps as _ScaleControlProps
|
|
41
|
-
} from './components/scale-control';
|
|
42
|
-
import { default as _Layer, LayerProps as _LayerProps } from './components/layer';
|
|
43
|
-
import { default as _Source, SourceProps as _SourceProps } from './components/source';
|
|
44
|
-
import { useMap as _useMap } from './components/use-map';
|
|
45
|
-
import type { MapRef as _MapRef } from './mapbox/create-ref';
|
|
46
|
-
import type * as events from './types/events';
|
|
47
|
-
import type { MapCallbacks } from './types/events-bkoi-gl';
|
|
48
|
-
|
|
49
|
-
export function useMap() {
|
|
50
|
-
return _useMap<BkoiMap>();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export type MapProps = _MapProps<MapOptions, MapStyle, MapCallbacks, BkoiMap>;
|
|
54
|
-
export type MapRef = _MapRef<BkoiMap>;
|
|
55
|
-
// @ts-ignore
|
|
56
|
-
// eslint-disable-next-line import/no-unresolved
|
|
57
|
-
const mapLib = import('bkoi-gl');
|
|
58
|
-
export const Map = (() => {
|
|
59
|
-
return React.forwardRef(function Map(props: MapProps, ref: React.Ref<MapRef>) {
|
|
60
|
-
return _Map<MapOptions, MapStyle, MapCallbacks, BkoiMap>(props, ref, mapLib);
|
|
61
|
-
});
|
|
62
|
-
})();
|
|
63
|
-
|
|
64
|
-
export type MarkerProps = _MarkerProps<MarkerOptions, BkoiMarker>;
|
|
65
|
-
export const Marker = _Marker as (
|
|
66
|
-
props: MarkerProps & React.RefAttributes<BkoiMarker>
|
|
67
|
-
) => React.ReactElement | null;
|
|
68
|
-
|
|
69
|
-
export type PopupProps = _PopupProps<PopupOptions, BkoiPopup>;
|
|
70
|
-
export const Popup = _Popup as (
|
|
71
|
-
props: PopupProps & React.RefAttributes<BkoiPopup>
|
|
72
|
-
) => React.ReactElement | null;
|
|
73
|
-
|
|
74
|
-
type AttributionControlOptions = ConstructorParameters<typeof BkoiAttributionControl>[0];
|
|
75
|
-
export type AttributionControlProps = _AttributionControlProps<AttributionControlOptions>;
|
|
76
|
-
export const AttributionControl = _AttributionControl as (
|
|
77
|
-
props: AttributionControlProps
|
|
78
|
-
) => React.ReactElement | null;
|
|
79
|
-
|
|
80
|
-
type FullscreenControlOptions = ConstructorParameters<typeof BkoiFullscreenControl>[0];
|
|
81
|
-
export type FullscreenControlProps = _FullscreenControlProps<FullscreenControlOptions>;
|
|
82
|
-
export const FullscreenControl = _FullscreenControl as (
|
|
83
|
-
props: FullscreenControlProps
|
|
84
|
-
) => React.ReactElement | null;
|
|
85
|
-
|
|
86
|
-
type NavigationControlOptions = ConstructorParameters<typeof BkoiNavigationControl>[0];
|
|
87
|
-
export type NavigationControlProps = _NavigationControlProps<NavigationControlOptions>;
|
|
88
|
-
export const NavigationControl = _NavigationControl as (
|
|
89
|
-
props: NavigationControlProps
|
|
90
|
-
) => React.ReactElement | null;
|
|
91
|
-
|
|
92
|
-
type GeolocateControlOptions = ConstructorParameters<typeof BkoiGeolocateControl>[0];
|
|
93
|
-
export type GeolocateControlProps = _GeolocateControlProps<
|
|
94
|
-
GeolocateControlOptions,
|
|
95
|
-
BkoiGeolocateControl
|
|
96
|
-
>;
|
|
97
|
-
export const GeolocateControl = _GeolocateControl as (
|
|
98
|
-
props: GeolocateControlProps & React.RefAttributes<BkoiGeolocateControl>
|
|
99
|
-
) => React.ReactElement | null;
|
|
100
|
-
|
|
101
|
-
type ScaleControlOptions = ConstructorParameters<typeof BkoiScaleControl>[0];
|
|
102
|
-
export type ScaleControlProps = _ScaleControlProps<ScaleControlOptions>;
|
|
103
|
-
export const ScaleControl = _ScaleControl as (
|
|
104
|
-
props: ScaleControlProps
|
|
105
|
-
) => React.ReactElement | null;
|
|
106
|
-
|
|
107
|
-
export type LayerProps = _LayerProps<AnyLayer>;
|
|
108
|
-
export const Layer = _Layer as (props: LayerProps) => React.ReactElement | null;
|
|
109
|
-
|
|
110
|
-
export type SourceProps = _SourceProps<AnySource>;
|
|
111
|
-
export const Source = _Source as (props: SourceProps) => React.ReactElement | null;
|
|
112
|
-
|
|
113
|
-
export { default as useControl } from './components/use-control';
|
|
114
|
-
export { MapProvider } from './components/use-map';
|
|
115
|
-
|
|
116
|
-
export default Map;
|
|
117
|
-
|
|
118
|
-
// Types
|
|
119
|
-
export * from './types/public';
|
|
120
|
-
export type { default as Point } from '@mapbox/point-geometry';
|
|
121
|
-
// export type {
|
|
122
|
-
// PointLike,
|
|
123
|
-
// LngLat,
|
|
124
|
-
// LngLatLike,
|
|
125
|
-
// LngLatBounds,
|
|
126
|
-
// LngLatBoundsLike,
|
|
127
|
-
// PaddingOptions,
|
|
128
|
-
// MapGeoJSONFeature,
|
|
129
|
-
// GeoJSONSource,
|
|
130
|
-
// VideoSource,
|
|
131
|
-
// ImageSource,
|
|
132
|
-
// CanvasSource,
|
|
133
|
-
// VectorTileSource
|
|
134
|
-
// } from 'maplibre-gl';
|
|
135
|
-
export * from './types/style-spec-bkoi-gl';
|
|
136
|
-
|
|
137
|
-
// Events
|
|
138
|
-
export type {
|
|
139
|
-
MapEvent,
|
|
140
|
-
MapMouseEvent,
|
|
141
|
-
MapLayerMouseEvent,
|
|
142
|
-
MapTouchEvent,
|
|
143
|
-
MapLayerTouchEvent,
|
|
144
|
-
MapStyleDataEvent,
|
|
145
|
-
MapSourceDataEvent,
|
|
146
|
-
MapWheelEvent,
|
|
147
|
-
MapBoxZoomEvent,
|
|
148
|
-
ErrorEvent,
|
|
149
|
-
ViewStateChangeEvent
|
|
150
|
-
} from './types/events-bkoi-gl';
|
|
151
|
-
export type PopupEvent = events.PopupEvent<BkoiPopup>;
|
|
152
|
-
export type MarkerEvent = events.MarkerEvent<BkoiMarker>;
|
|
153
|
-
export type MarkerDragEvent = events.MarkerDragEvent<BkoiMarker>;
|
|
154
|
-
export type GeolocateEvent = events.GeolocateEvent<BkoiGeolocateControl>;
|
|
155
|
-
export type GeolocateResultEvent = events.GeolocateResultEvent<BkoiGeolocateControl>;
|
|
156
|
-
export type GeolocateErrorEvent = events.GeolocateErrorEvent<BkoiGeolocateControl>;
|
package/src/exports-mapbox.ts
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type {
|
|
3
|
-
Map as MapboxMap,
|
|
4
|
-
MapboxOptions,
|
|
5
|
-
Marker as MapboxMarker,
|
|
6
|
-
MarkerOptions,
|
|
7
|
-
Popup as MapboxPopup,
|
|
8
|
-
PopupOptions,
|
|
9
|
-
AttributionControl as MapboxAttributionControl,
|
|
10
|
-
FullscreenControl as MapboxFullscreenControl,
|
|
11
|
-
GeolocateControl as MapboxGeolocateControl,
|
|
12
|
-
NavigationControl as MapboxNavigationControl,
|
|
13
|
-
ScaleControl as MapboxScaleControl
|
|
14
|
-
} from 'mapbox-gl';
|
|
15
|
-
import {MapStyle, AnyLayer, AnySource} from './types/style-spec-mapbox';
|
|
16
|
-
|
|
17
|
-
import {default as _Map, MapProps as _MapProps} from './components/map';
|
|
18
|
-
import {default as _Marker, MarkerProps as _MarkerProps} from './components/marker';
|
|
19
|
-
import {default as _Popup, PopupProps as _PopupProps} from './components/popup';
|
|
20
|
-
import {
|
|
21
|
-
default as _AttributionControl,
|
|
22
|
-
AttributionControlProps as _AttributionControlProps
|
|
23
|
-
} from './components/attribution-control';
|
|
24
|
-
import {
|
|
25
|
-
default as _FullscreenControl,
|
|
26
|
-
FullscreenControlProps as _FullscreenControlProps
|
|
27
|
-
} from './components/fullscreen-control';
|
|
28
|
-
import {
|
|
29
|
-
default as _GeolocateControl,
|
|
30
|
-
GeolocateControlProps as _GeolocateControlProps
|
|
31
|
-
} from './components/geolocate-control';
|
|
32
|
-
import {
|
|
33
|
-
default as _NavigationControl,
|
|
34
|
-
NavigationControlProps as _NavigationControlProps
|
|
35
|
-
} from './components/navigation-control';
|
|
36
|
-
import {
|
|
37
|
-
default as _ScaleControl,
|
|
38
|
-
ScaleControlProps as _ScaleControlProps
|
|
39
|
-
} from './components/scale-control';
|
|
40
|
-
import {default as _Layer, LayerProps as _LayerProps} from './components/layer';
|
|
41
|
-
import {default as _Source, SourceProps as _SourceProps} from './components/source';
|
|
42
|
-
import {useMap as _useMap} from './components/use-map';
|
|
43
|
-
import type {MapRef as _MapRef} from './mapbox/create-ref';
|
|
44
|
-
import type * as events from './types/events';
|
|
45
|
-
import type {MapCallbacks} from './types/events-mapbox';
|
|
46
|
-
|
|
47
|
-
export function useMap() {
|
|
48
|
-
return _useMap<MapboxMap>();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export type MapProps = _MapProps<MapboxOptions, MapStyle, MapCallbacks, MapboxMap>;
|
|
52
|
-
export type MapRef = _MapRef<MapboxMap>;
|
|
53
|
-
const mapLib = import('mapbox-gl');
|
|
54
|
-
export const Map = (() => {
|
|
55
|
-
return React.forwardRef(function Map(props: MapProps, ref: React.Ref<MapRef>) {
|
|
56
|
-
return _Map<MapboxOptions, MapStyle, MapCallbacks, MapboxMap>(props, ref, mapLib);
|
|
57
|
-
});
|
|
58
|
-
})();
|
|
59
|
-
|
|
60
|
-
export type MarkerProps = _MarkerProps<MarkerOptions, MapboxMarker>;
|
|
61
|
-
export const Marker = _Marker as (
|
|
62
|
-
props: MarkerProps & React.RefAttributes<MapboxMarker>
|
|
63
|
-
) => React.ReactElement | null;
|
|
64
|
-
|
|
65
|
-
export type PopupProps = _PopupProps<PopupOptions, MapboxPopup>;
|
|
66
|
-
export const Popup = _Popup as (
|
|
67
|
-
props: PopupProps & React.RefAttributes<MapboxPopup>
|
|
68
|
-
) => React.ReactElement | null;
|
|
69
|
-
|
|
70
|
-
type AttributionControlOptions = ConstructorParameters<typeof MapboxAttributionControl>[0];
|
|
71
|
-
export type AttributionControlProps = _AttributionControlProps<AttributionControlOptions>;
|
|
72
|
-
export const AttributionControl = _AttributionControl as (
|
|
73
|
-
props: AttributionControlProps
|
|
74
|
-
) => React.ReactElement | null;
|
|
75
|
-
|
|
76
|
-
type FullscreenControlOptions = ConstructorParameters<typeof MapboxFullscreenControl>[0];
|
|
77
|
-
export type FullscreenControlProps = _FullscreenControlProps<FullscreenControlOptions>;
|
|
78
|
-
export const FullscreenControl = _FullscreenControl as (
|
|
79
|
-
props: FullscreenControlProps
|
|
80
|
-
) => React.ReactElement | null;
|
|
81
|
-
|
|
82
|
-
type NavigationControlOptions = ConstructorParameters<typeof MapboxNavigationControl>[0];
|
|
83
|
-
export type NavigationControlProps = _NavigationControlProps<NavigationControlOptions>;
|
|
84
|
-
export const NavigationControl = _NavigationControl as (
|
|
85
|
-
props: NavigationControlProps
|
|
86
|
-
) => React.ReactElement | null;
|
|
87
|
-
|
|
88
|
-
type GeolocateControlOptions = ConstructorParameters<typeof MapboxGeolocateControl>[0];
|
|
89
|
-
export type GeolocateControlProps = _GeolocateControlProps<
|
|
90
|
-
GeolocateControlOptions,
|
|
91
|
-
MapboxGeolocateControl
|
|
92
|
-
>;
|
|
93
|
-
export const GeolocateControl = _GeolocateControl as (
|
|
94
|
-
props: GeolocateControlProps & React.RefAttributes<MapboxGeolocateControl>
|
|
95
|
-
) => React.ReactElement | null;
|
|
96
|
-
|
|
97
|
-
type ScaleControlOptions = ConstructorParameters<typeof MapboxScaleControl>[0];
|
|
98
|
-
export type ScaleControlProps = _ScaleControlProps<ScaleControlOptions>;
|
|
99
|
-
export const ScaleControl = _ScaleControl as (
|
|
100
|
-
props: ScaleControlProps
|
|
101
|
-
) => React.ReactElement | null;
|
|
102
|
-
|
|
103
|
-
export type LayerProps = _LayerProps<AnyLayer>;
|
|
104
|
-
export const Layer = _Layer as (props: LayerProps) => React.ReactElement | null;
|
|
105
|
-
|
|
106
|
-
export type SourceProps = _SourceProps<AnySource>;
|
|
107
|
-
export const Source = _Source as (props: SourceProps) => React.ReactElement | null;
|
|
108
|
-
|
|
109
|
-
export {default as useControl} from './components/use-control';
|
|
110
|
-
export {MapProvider} from './components/use-map';
|
|
111
|
-
|
|
112
|
-
export default Map;
|
|
113
|
-
|
|
114
|
-
// Types
|
|
115
|
-
export * from './types/public';
|
|
116
|
-
export type {
|
|
117
|
-
Point,
|
|
118
|
-
PointLike,
|
|
119
|
-
LngLat,
|
|
120
|
-
LngLatLike,
|
|
121
|
-
LngLatBounds,
|
|
122
|
-
LngLatBoundsLike,
|
|
123
|
-
PaddingOptions,
|
|
124
|
-
MapboxGeoJSONFeature as MapGeoJSONFeature,
|
|
125
|
-
GeoJSONSource,
|
|
126
|
-
VideoSource,
|
|
127
|
-
ImageSource,
|
|
128
|
-
CanvasSource,
|
|
129
|
-
VectorSourceImpl as VectorTileSource
|
|
130
|
-
} from 'mapbox-gl';
|
|
131
|
-
export * from './types/style-spec-mapbox';
|
|
132
|
-
|
|
133
|
-
// Events
|
|
134
|
-
export type {
|
|
135
|
-
MapEvent,
|
|
136
|
-
MapMouseEvent,
|
|
137
|
-
MapLayerMouseEvent,
|
|
138
|
-
MapTouchEvent,
|
|
139
|
-
MapLayerTouchEvent,
|
|
140
|
-
MapStyleDataEvent,
|
|
141
|
-
MapSourceDataEvent,
|
|
142
|
-
MapWheelEvent,
|
|
143
|
-
MapBoxZoomEvent,
|
|
144
|
-
ErrorEvent,
|
|
145
|
-
ViewStateChangeEvent
|
|
146
|
-
} from './types/events-mapbox';
|
|
147
|
-
export type PopupEvent = events.PopupEvent<MapboxPopup>;
|
|
148
|
-
export type MarkerEvent = events.MarkerEvent<MapboxMarker>;
|
|
149
|
-
export type MarkerDragEvent = events.MarkerDragEvent<MapboxMarker>;
|
|
150
|
-
export type GeolocateEvent = events.GeolocateEvent<MapboxGeolocateControl>;
|
|
151
|
-
export type GeolocateResultEvent = events.GeolocateResultEvent<MapboxGeolocateControl>;
|
|
152
|
-
export type GeolocateErrorEvent = events.GeolocateErrorEvent<MapboxGeolocateControl>;
|
|
153
|
-
|
|
154
|
-
// v7.0 backward compatibility
|
|
155
|
-
|
|
156
|
-
/** @deprecated use `MapStyle` */
|
|
157
|
-
export type MapboxStyle = MapStyle;
|
|
158
|
-
|
|
159
|
-
export type {Map as MapboxMap, MapboxEvent, MapboxGeoJSONFeature} from 'mapbox-gl';
|
package/src/index.ts
DELETED
package/src/mapbox/create-ref.ts
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
MapInstance,
|
|
3
|
-
MapInstanceInternal,
|
|
4
|
-
MapStyle,
|
|
5
|
-
Callbacks,
|
|
6
|
-
LngLatLike,
|
|
7
|
-
PointLike
|
|
8
|
-
} from '../types';
|
|
9
|
-
import type Mapbox from './mapbox';
|
|
10
|
-
|
|
11
|
-
/** These methods may break the react binding if called directly */
|
|
12
|
-
const skipMethods = [
|
|
13
|
-
'setMaxBounds',
|
|
14
|
-
'setMinZoom',
|
|
15
|
-
'setMaxZoom',
|
|
16
|
-
'setMinPitch',
|
|
17
|
-
'setMaxPitch',
|
|
18
|
-
'setRenderWorldCopies',
|
|
19
|
-
'setProjection',
|
|
20
|
-
'setStyle',
|
|
21
|
-
'addSource',
|
|
22
|
-
'removeSource',
|
|
23
|
-
'addLayer',
|
|
24
|
-
'removeLayer',
|
|
25
|
-
'setLayerZoomRange',
|
|
26
|
-
'setFilter',
|
|
27
|
-
'setPaintProperty',
|
|
28
|
-
'setLayoutProperty',
|
|
29
|
-
'setLight',
|
|
30
|
-
'setTerrain',
|
|
31
|
-
'setFog',
|
|
32
|
-
'remove'
|
|
33
|
-
] as const;
|
|
34
|
-
|
|
35
|
-
export type MapRef<MapT extends MapInstance> = {
|
|
36
|
-
getMap(): MapT;
|
|
37
|
-
} & Omit<MapT, typeof skipMethods[number]>;
|
|
38
|
-
|
|
39
|
-
export default function createRef<
|
|
40
|
-
StyleT extends MapStyle,
|
|
41
|
-
CallbacksT extends Callbacks,
|
|
42
|
-
MapT extends MapInstance
|
|
43
|
-
>(mapInstance: Mapbox<StyleT, CallbacksT, MapT>): MapRef<MapT> | null {
|
|
44
|
-
if (!mapInstance) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const map = mapInstance.map as MapInstanceInternal<MapT>;
|
|
49
|
-
const result: any = {
|
|
50
|
-
getMap: () => map,
|
|
51
|
-
|
|
52
|
-
// Overwrite getters to use our shadow transform
|
|
53
|
-
getCenter: () => mapInstance.transform.center,
|
|
54
|
-
getZoom: () => mapInstance.transform.zoom,
|
|
55
|
-
getBearing: () => mapInstance.transform.bearing,
|
|
56
|
-
getPitch: () => mapInstance.transform.pitch,
|
|
57
|
-
getPadding: () => mapInstance.transform.padding,
|
|
58
|
-
getBounds: () => mapInstance.transform.getBounds(),
|
|
59
|
-
project: (lnglat: LngLatLike) => {
|
|
60
|
-
const tr = map.transform;
|
|
61
|
-
map.transform = mapInstance.transform;
|
|
62
|
-
const result = map.project(lnglat);
|
|
63
|
-
map.transform = tr;
|
|
64
|
-
return result;
|
|
65
|
-
},
|
|
66
|
-
unproject: (point: PointLike) => {
|
|
67
|
-
const tr = map.transform;
|
|
68
|
-
map.transform = mapInstance.transform;
|
|
69
|
-
const result = map.unproject(point);
|
|
70
|
-
map.transform = tr;
|
|
71
|
-
return result;
|
|
72
|
-
},
|
|
73
|
-
// options diverge between mapbox and maplibre
|
|
74
|
-
queryTerrainElevation: (lnglat: LngLatLike, options?: any) => {
|
|
75
|
-
const tr = map.transform;
|
|
76
|
-
map.transform = mapInstance.transform;
|
|
77
|
-
const result = map.queryTerrainElevation(lnglat, options);
|
|
78
|
-
map.transform = tr;
|
|
79
|
-
return result;
|
|
80
|
-
},
|
|
81
|
-
queryRenderedFeatures: (geometry?: any, options?: any) => {
|
|
82
|
-
const tr = map.transform;
|
|
83
|
-
map.transform = mapInstance.transform;
|
|
84
|
-
const result = map.queryRenderedFeatures(geometry, options);
|
|
85
|
-
map.transform = tr;
|
|
86
|
-
return result;
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
for (const key of getMethodNames(map)) {
|
|
91
|
-
// @ts-expect-error
|
|
92
|
-
if (!(key in result) && !skipMethods.includes(key)) {
|
|
93
|
-
result[key] = map[key].bind(map);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return result;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function getMethodNames(obj: Object) {
|
|
101
|
-
const result = new Set<string>();
|
|
102
|
-
|
|
103
|
-
let proto = obj;
|
|
104
|
-
while (proto) {
|
|
105
|
-
for (const key of Object.getOwnPropertyNames(proto)) {
|
|
106
|
-
if (
|
|
107
|
-
key[0] !== '_' &&
|
|
108
|
-
typeof obj[key] === 'function' &&
|
|
109
|
-
key !== 'fire' &&
|
|
110
|
-
key !== 'setEventedParent'
|
|
111
|
-
) {
|
|
112
|
-
result.add(key);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
proto = Object.getPrototypeOf(proto);
|
|
116
|
-
}
|
|
117
|
-
return Array.from(result);
|
|
118
|
-
}
|