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.
Files changed (167) hide show
  1. package/README.md +163 -18
  2. package/dist/components/attribution-control.d.ts +4 -6
  3. package/dist/components/attribution-control.js +6 -5
  4. package/dist/components/attribution-control.js.map +1 -1
  5. package/dist/components/fullscreen-control.d.ts +4 -6
  6. package/dist/components/fullscreen-control.js +4 -4
  7. package/dist/components/fullscreen-control.js.map +1 -1
  8. package/dist/components/geolocate-control.d.ts +10 -26
  9. package/dist/components/geolocate-control.js +11 -11
  10. package/dist/components/geolocate-control.js.map +1 -1
  11. package/dist/components/layer.d.ts +7 -6
  12. package/dist/components/layer.js +8 -9
  13. package/dist/components/layer.js.map +1 -1
  14. package/dist/components/logo-control.d.ts +9 -0
  15. package/dist/components/logo-control.js +28 -0
  16. package/dist/components/logo-control.js.map +1 -0
  17. package/dist/components/map.d.ts +20 -16
  18. package/dist/components/map.js +38 -32
  19. package/dist/components/map.js.map +1 -1
  20. package/dist/components/marker.d.ts +10 -33
  21. package/dist/components/marker.js +22 -15
  22. package/dist/components/marker.js.map +1 -1
  23. package/dist/components/navigation-control.d.ts +4 -6
  24. package/dist/components/navigation-control.js +4 -4
  25. package/dist/components/navigation-control.js.map +1 -1
  26. package/dist/components/popup.d.ts +7 -25
  27. package/dist/components/popup.js +17 -28
  28. package/dist/components/popup.js.map +1 -1
  29. package/dist/components/scale-control.d.ts +4 -6
  30. package/dist/components/scale-control.js +4 -4
  31. package/dist/components/scale-control.js.map +1 -1
  32. package/dist/components/source.d.ts +3 -4
  33. package/dist/components/source.js +20 -22
  34. package/dist/components/source.js.map +1 -1
  35. package/dist/components/terrain-control.d.ts +10 -0
  36. package/dist/components/terrain-control.js +19 -0
  37. package/dist/components/terrain-control.js.map +1 -0
  38. package/dist/components/use-control.d.ts +6 -6
  39. package/dist/components/use-control.js +4 -5
  40. package/dist/components/use-control.js.map +1 -1
  41. package/dist/components/use-map.d.ts +8 -9
  42. package/dist/components/use-map.js +5 -5
  43. package/dist/components/use-map.js.map +1 -1
  44. package/dist/exports-maplibre-gl.d.ts +33 -0
  45. package/dist/exports-maplibre-gl.js +21 -0
  46. package/dist/exports-maplibre-gl.js.map +1 -0
  47. package/dist/index.cjs +590 -681
  48. package/dist/index.d.ts +2 -2
  49. package/dist/index.js +2 -2
  50. package/dist/index.js.map +1 -1
  51. package/dist/{mapbox → maplibre}/create-ref.d.ts +6 -6
  52. package/dist/maplibre/create-ref.js +30 -0
  53. package/dist/maplibre/create-ref.js.map +1 -0
  54. package/dist/maplibre/maplibre.d.ts +81 -0
  55. package/dist/maplibre/maplibre.js +387 -0
  56. package/dist/maplibre/maplibre.js.map +1 -0
  57. package/dist/styles/index.d.ts +4 -0
  58. package/dist/styles/react-bkoi-gl.css +1 -1
  59. package/dist/styles.d.js +2 -0
  60. package/dist/styles.d.js.map +1 -0
  61. package/dist/tsconfig.build.tsbuildinfo +1 -0
  62. package/dist/types/common.d.ts +2 -60
  63. package/dist/types/common.js.map +1 -1
  64. package/dist/types/events.d.ts +64 -23
  65. package/dist/types/events.js.map +1 -1
  66. package/dist/types/internal.d.ts +14 -0
  67. package/dist/types/internal.js +2 -0
  68. package/dist/types/internal.js.map +1 -0
  69. package/dist/types/lib.d.ts +16 -200
  70. package/dist/types/lib.js.map +1 -1
  71. package/dist/types/style-spec.d.ts +1 -0
  72. package/dist/types/style-spec.js +2 -0
  73. package/dist/types/style-spec.js.map +1 -0
  74. package/dist/utils/apply-react-style.d.ts +1 -1
  75. package/dist/utils/apply-react-style.js.map +1 -1
  76. package/dist/utils/compare-class-names.d.ts +2 -0
  77. package/dist/utils/compare-class-names.js +23 -0
  78. package/dist/utils/compare-class-names.js.map +1 -0
  79. package/dist/utils/deep-equal.d.ts +1 -1
  80. package/dist/utils/deep-equal.js +1 -1
  81. package/dist/utils/deep-equal.js.map +1 -1
  82. package/dist/utils/set-globals.d.ts +6 -8
  83. package/dist/utils/set-globals.js +22 -10
  84. package/dist/utils/set-globals.js.map +1 -1
  85. package/dist/utils/style-utils.d.ts +3 -2
  86. package/dist/utils/style-utils.js +4 -4
  87. package/dist/utils/style-utils.js.map +1 -1
  88. package/dist/utils/transform.d.ts +11 -19
  89. package/dist/utils/transform.js +13 -36
  90. package/dist/utils/transform.js.map +1 -1
  91. package/dist/utils/use-isomorphic-layout-effect.d.ts +1 -1
  92. package/dist/utils/use-isomorphic-layout-effect.js +2 -2
  93. package/dist/utils/use-isomorphic-layout-effect.js.map +1 -1
  94. package/package.json +42 -26
  95. package/src/components/attribution-control.ts +40 -16
  96. package/src/components/fullscreen-control.ts +40 -0
  97. package/src/components/geolocate-control.ts +45 -39
  98. package/src/components/layer.ts +37 -29
  99. package/src/components/logo-control.ts +44 -0
  100. package/src/components/map.tsx +86 -75
  101. package/src/components/marker.ts +141 -123
  102. package/src/components/navigation-control.ts +11 -12
  103. package/src/components/popup.ts +94 -97
  104. package/src/components/scale-control.ts +12 -14
  105. package/src/components/source.ts +58 -57
  106. package/src/components/terrain-control.ts +29 -0
  107. package/src/components/use-control.ts +21 -17
  108. package/src/components/use-map.tsx +26 -24
  109. package/src/exports-maplibre-gl.ts +37 -0
  110. package/src/index.ts +3 -2
  111. package/src/maplibre/create-ref.ts +70 -0
  112. package/src/maplibre/maplibre.ts +624 -0
  113. package/src/styles.d.ts +4 -0
  114. package/src/types/common.ts +12 -72
  115. package/src/types/events.ts +102 -42
  116. package/src/types/internal.ts +26 -0
  117. package/src/types/lib.ts +65 -260
  118. package/src/types/style-spec.ts +34 -0
  119. package/src/utils/apply-react-style.ts +7 -3
  120. package/src/utils/compare-class-names.ts +29 -0
  121. package/src/utils/deep-equal.ts +2 -2
  122. package/src/utils/set-globals.ts +22 -28
  123. package/src/utils/style-utils.ts +18 -9
  124. package/src/utils/transform.ts +32 -60
  125. package/src/utils/use-isomorphic-layout-effect.ts +3 -2
  126. package/bkoi-gl/package.json +0 -6
  127. package/dist/exports-bkoi-gl.cjs +0 -1512
  128. package/dist/exports-bkoi-gl.d.ts +0 -89
  129. package/dist/exports-bkoi-gl.js +0 -36
  130. package/dist/exports-bkoi-gl.js.map +0 -1
  131. package/dist/exports-mapbox.d.ts +0 -139
  132. package/dist/exports-mapbox.js +0 -36
  133. package/dist/exports-mapbox.js.map +0 -1
  134. package/dist/mapbox/create-ref.js +0 -64
  135. package/dist/mapbox/create-ref.js.map +0 -1
  136. package/dist/mapbox/mapbox.d.ts +0 -81
  137. package/dist/mapbox/mapbox.js +0 -476
  138. package/dist/mapbox/mapbox.js.map +0 -1
  139. package/dist/types/events-bkoi-gl.d.ts +0 -49
  140. package/dist/types/events-bkoi-gl.js +0 -2
  141. package/dist/types/events-bkoi-gl.js.map +0 -1
  142. package/dist/types/events-mapbox.d.ts +0 -49
  143. package/dist/types/events-mapbox.js +0 -2
  144. package/dist/types/events-mapbox.js.map +0 -1
  145. package/dist/types/index.d.ts +0 -70
  146. package/dist/types/index.js +0 -5
  147. package/dist/types/index.js.map +0 -1
  148. package/dist/types/public.d.ts +0 -2
  149. package/dist/types/public.js +0 -2
  150. package/dist/types/public.js.map +0 -1
  151. package/dist/types/style-spec-bkoi-gl.d.ts +0 -9
  152. package/dist/types/style-spec-bkoi-gl.js +0 -2
  153. package/dist/types/style-spec-bkoi-gl.js.map +0 -1
  154. package/dist/types/style-spec-mapbox.d.ts +0 -7
  155. package/dist/types/style-spec-mapbox.js +0 -2
  156. package/dist/types/style-spec-mapbox.js.map +0 -1
  157. package/src/components/fullscreen-control.tsx +0 -37
  158. package/src/exports-bkoi-gl.ts +0 -156
  159. package/src/exports-mapbox.ts +0 -159
  160. package/src/mapbox/create-ref.ts +0 -118
  161. package/src/mapbox/mapbox.ts +0 -742
  162. package/src/types/events-bkoi-gl.ts +0 -78
  163. package/src/types/events-mapbox.ts +0 -76
  164. package/src/types/index.ts +0 -93
  165. package/src/types/public.ts +0 -9
  166. package/src/types/style-spec-bkoi-gl.ts +0 -81
  167. package/src/types/style-spec-mapbox.ts +0 -80
@@ -1,73 +1,15 @@
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
- };
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
  }
@@ -1,73 +1,133 @@
1
- import type {ViewState, Point, LngLat, MapGeoJSONFeature} from './common';
1
+ import type { Point, LngLat, MapGeoJSONFeature, ViewState } from "./common";
2
+
2
3
  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
- }
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
- export interface MapEvent<SourceT extends Evented, OriginalEventT = undefined> {
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<MapT extends MapInstance> = MapEvent<MapT> & {
21
- type: 'error';
84
+ export type ErrorEvent = MapEvent<Map> & {
85
+ type: "error";
22
86
  error: Error;
23
87
  };
24
88
 
25
- export type MapMouseEvent<MapT extends MapInstance> = MapEvent<MapT, MouseEvent> & {
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<MapT extends MapInstance> =
32
- | (MapEvent<MapT, MouseEvent | TouchEvent | WheelEvent | undefined> & {
33
- type: 'movestart' | 'move' | 'moveend' | 'zoomstart' | 'zoom' | 'zoomend';
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<MapT, MouseEvent | TouchEvent | undefined> & {
100
+ | (MapEvent<Map, MouseEvent | TouchEvent | undefined> & {
37
101
  type:
38
- | 'rotatestart'
39
- | 'rotate'
40
- | 'rotateend'
41
- | 'dragstart'
42
- | 'drag'
43
- | 'dragend'
44
- | 'pitchstart'
45
- | 'pitch'
46
- | 'pitchend';
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<PopupT extends PopupInstance> = {
51
- type: 'open' | 'close';
52
- target: PopupT;
114
+ export type PopupEvent = {
115
+ type: "open" | "close";
116
+ target: Popup;
53
117
  };
54
118
 
55
- export type MarkerEvent<MarkerT extends MarkerInstance, OriginalEventT = undefined> = MapEvent<
56
- MarkerT,
119
+ export type MarkerEvent<OriginalEventT = undefined> = MapEvent<
120
+ Marker,
57
121
  OriginalEventT
58
122
  >;
59
123
 
60
- export type MarkerDragEvent<MarkerT extends MarkerInstance> = MarkerEvent<MarkerT> & {
61
- type: 'dragstart' | 'drag' | 'dragend';
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<GeolocateControlT extends GeolocateControlInstance> =
67
- MapEvent<GeolocateControlT>;
129
+ export type GeolocateEvent = MapEvent<GeolocateControl>;
68
130
 
69
- export type GeolocateResultEvent<GeolocateControlT extends GeolocateControlInstance> =
70
- GeolocateEvent<GeolocateControlT> & GeolocationPosition;
131
+ export type GeolocateResultEvent = GeolocateEvent & GeolocationPosition;
71
132
 
72
- export type GeolocateErrorEvent<GeolocateControlT extends GeolocateControlInstance> =
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 {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
- }
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<MapT extends MapInstance> {
54
+ export interface MapLib {
176
55
  supported?: (options: any) => boolean;
177
56
 
178
- Map: {new (options: any): MapT};
179
-
180
- Marker: {new (...options: any[]): MarkerInstance};
181
-
182
- Popup: {new (options: any): PopupInstance};
57
+ Map: { new (options: MapOptions): Map };
183
58
 
184
- AttributionControl: {new (options: any): AttributionControlInstance};
59
+ Marker: { new (options: MarkerOptions): Marker };
185
60
 
186
- FullscreenControl: {new (options: any): FullscreenControlInstance};
61
+ Popup: { new (options: PopupOptions): Popup };
187
62
 
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;
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
- onRemove?(map: MapInstance, gl: WebGLRenderingContext): void;
240
- onAdd?(map: MapInstance, gl: WebGLRenderingContext): void;
67
+ FullscreenControl: {
68
+ new (options: FullscreenControlOptions): FullscreenControl;
69
+ };
241
70
 
242
- prerender?(gl: WebGLRenderingContext, matrix: number[]): void;
243
- render(gl: WebGLRenderingContext, matrix: number[]): void;
244
- }
71
+ GeolocateControl: {
72
+ new (options: GeolocateControlOptions): GeolocateControl;
73
+ };
245
74
 
246
- // Custom source
75
+ NavigationControl: {
76
+ new (options: NavigationControlOptions): NavigationControl;
77
+ };
247
78
 
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
- }
79
+ ScaleControl: { new (options: ScaleControlOptions): ScaleControl };
268
80
 
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;
81
+ TerrainControl: { new (options: TerrainSpecification): TerrainControl };
277
82
 
278
- _implementation: CustomSourceImplementation<TileDataT>;
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 'react';
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 = /box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;
4
+ const unitlessNumber =
5
+ /box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;
5
6
 
6
- export function applyReactStyle(element: HTMLElement, styles: React.CSSProperties) {
7
+ export function applyReactStyle(
8
+ element: HTMLElement,
9
+ styles: React.CSSProperties,
10
+ ) {
7
11
  if (!element || !styles) {
8
12
  return;
9
13
  }