react-bkoi-gl 2.0.1 → 2.1.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 +1420 -176
- package/dist/index.cjs +1181 -174
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +548 -48
- package/dist/index.d.ts +548 -48
- package/dist/index.js +1189 -203
- package/dist/index.js.map +1 -1
- package/dist/styles/react-bkoi-gl.css +95 -1
- package/package.json +28 -8
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
2
|
import { CSSProperties } from 'react';
|
|
3
|
-
import { PaddingOptions, MapOptions, Map as Map$1, MarkerOptions, Marker as Marker$1, PopupOptions, Popup as Popup$1, AttributionControlOptions, AttributionControl as AttributionControl$1, FullscreenControlOptions, FullscreenControl as FullscreenControl$1, GeolocateControlOptions, GeolocateControl as GeolocateControl$1, NavigationControlOptions, NavigationControl as NavigationControl$1, ScaleControlOptions, ScaleControl as ScaleControl$1, TerrainSpecification, TerrainControl as TerrainControl$1, LogoControlOptions, LogoControl as LogoControl$1, MapLayerMouseEvent, MapLayerTouchEvent, MapWheelEvent, MapLibreZoomEvent, MapLibreEvent, MapStyleDataEvent, MapSourceDataEvent,
|
|
4
|
-
export { AttributionControlOptions, BackgroundLayerSpecification, CanvasSourceSpecification, CircleLayerSpecification, ControlPosition, CustomLayerInterface, FillExtrusionLayerSpecification, FillLayerSpecification, FullscreenControlOptions, GeoJSONSourceSpecification, GeolocateControlOptions, HeatmapLayerSpecification, HillshadeLayerSpecification, IControl, ImageSourceSpecification, LayerSpecification, LightSpecification, LineLayerSpecification, LngLat, LngLatBounds, LngLatBoundsLike, LngLatLike, LogoControlOptions, MapLibreZoomEvent as MapBoxZoomEvent, MapLibreEvent as MapEvent, MapGeoJSONFeature, MapLayerMouseEvent, MapLayerTouchEvent, MapOptions, MapSourceDataEvent, MapStyleDataEvent, MapTouchEvent, MapWheelEvent, MarkerOptions, NavigationControlOptions, PaddingOptions, Point, PointLike, PopupOptions, ProjectionSpecification, RasterDEMSourceSpecification, RasterLayerSpecification, RasterSourceSpecification, ScaleControlOptions, SkySpecification, SourceSpecification, StyleSpecification, SymbolLayerSpecification, TerrainSpecification, VectorSourceSpecification, VideoSourceSpecification } from 'maplibre-gl';
|
|
3
|
+
import { PaddingOptions, MapOptions, Map as Map$1, MarkerOptions, Marker as Marker$1, PopupOptions, Popup as Popup$1, AttributionControlOptions, AttributionControl as AttributionControl$1, FullscreenControlOptions, FullscreenControl as FullscreenControl$1, GeolocateControlOptions, GeolocateControl as GeolocateControl$1, NavigationControlOptions, NavigationControl as NavigationControl$1, ScaleControlOptions, ScaleControl as ScaleControl$1, TerrainSpecification, TerrainControl as TerrainControl$1, LogoControlOptions, LogoControl as LogoControl$1, MapLayerMouseEvent, MapLayerTouchEvent, MapWheelEvent, MapLibreZoomEvent, MapLibreEvent, MapStyleDataEvent, MapSourceDataEvent, MapMouseEvent as MapMouseEvent$1, Point, LngLat, MapGeoJSONFeature, LngLatBoundsLike, PointLike, StyleSpecification, ProjectionSpecification, LightSpecification, SkySpecification, ControlPosition, SourceSpecification, Source as Source$1, LayerSpecification, CustomLayerInterface, IControl } from 'maplibre-gl';
|
|
4
|
+
export { AttributionControlOptions, BackgroundLayerSpecification, CanvasSourceSpecification, CircleLayerSpecification, ControlPosition, CustomLayerInterface, FillExtrusionLayerSpecification, FillLayerSpecification, FullscreenControlOptions, GeoJSONSourceSpecification, GeolocateControlOptions, HeatmapLayerSpecification, HillshadeLayerSpecification, IControl, ImageSourceSpecification, LayerSpecification, LightSpecification, LineLayerSpecification, LngLat, LngLatBounds, LngLatBoundsLike, LngLatLike, LogoControlOptions, MapLibreZoomEvent as MapBoxZoomEvent, MapLibreEvent as MapEvent, MapGeoJSONFeature, MapLayerMouseEvent, MapLayerTouchEvent, MapMouseEvent as MapMouseEventBase, MapOptions, MapSourceDataEvent, MapStyleDataEvent, MapTouchEvent, MapWheelEvent, MarkerOptions, NavigationControlOptions, PaddingOptions, Point, PointLike, PopupOptions, ProjectionSpecification, RasterDEMSourceSpecification, RasterLayerSpecification, RasterSourceSpecification, ScaleControlOptions, SkySpecification, SourceSpecification, StyleSpecification, SymbolLayerSpecification, TerrainSpecification, VectorSourceSpecification, VideoSourceSpecification } from 'maplibre-gl';
|
|
5
5
|
|
|
6
6
|
/** Describes the camera's state */
|
|
7
7
|
type ViewState = {
|
|
@@ -22,6 +22,16 @@ interface ImmutableLike<T> {
|
|
|
22
22
|
toJS: () => T;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* A relaxed control interface that accepts both MapLibre IControl implementations
|
|
27
|
+
* and third-party controls (e.g. @deck.gl/mapbox MapboxOverlay) that may use
|
|
28
|
+
* different Map type definitions.
|
|
29
|
+
*/
|
|
30
|
+
interface MapControl {
|
|
31
|
+
onAdd?(map: unknown): unknown;
|
|
32
|
+
onRemove?(map: unknown): unknown;
|
|
33
|
+
getDefaultPosition?(): string;
|
|
34
|
+
}
|
|
25
35
|
/**
|
|
26
36
|
* A user-facing type that represents the minimal intersection between Mapbox and Maplibre
|
|
27
37
|
* User provided `mapLib` is supposed to implement this interface
|
|
@@ -67,7 +77,7 @@ interface MapEvent<SourceT, OriginalEventT = undefined> {
|
|
|
67
77
|
originalEvent: OriginalEventT;
|
|
68
78
|
}
|
|
69
79
|
type ErrorEvent = MapEvent<Map$1> & {
|
|
70
|
-
type:
|
|
80
|
+
type: 'error';
|
|
71
81
|
error: Error;
|
|
72
82
|
};
|
|
73
83
|
type MapMouseEvent = MapMouseEvent$1 & {
|
|
@@ -76,10 +86,10 @@ type MapMouseEvent = MapMouseEvent$1 & {
|
|
|
76
86
|
features?: MapGeoJSONFeature[];
|
|
77
87
|
};
|
|
78
88
|
type ViewStateChangeEvent = (MapEvent<Map$1, MouseEvent | TouchEvent | WheelEvent | undefined> & {
|
|
79
|
-
type:
|
|
89
|
+
type: 'movestart' | 'move' | 'moveend' | 'zoomstart' | 'zoom' | 'zoomend';
|
|
80
90
|
viewState: ViewState;
|
|
81
91
|
}) | (MapEvent<Map$1, MouseEvent | TouchEvent | undefined> & {
|
|
82
|
-
type:
|
|
92
|
+
type: 'rotatestart' | 'rotate' | 'rotateend' | 'dragstart' | 'drag' | 'dragend' | 'pitchstart' | 'pitch' | 'pitchend';
|
|
83
93
|
viewState: ViewState;
|
|
84
94
|
});
|
|
85
95
|
type MapCallbacks = {
|
|
@@ -127,12 +137,12 @@ type MapCallbacks = {
|
|
|
127
137
|
onSourceData?: (e: MapSourceDataEvent) => void;
|
|
128
138
|
};
|
|
129
139
|
type PopupEvent = {
|
|
130
|
-
type:
|
|
140
|
+
type: 'open' | 'close';
|
|
131
141
|
target: Popup$1;
|
|
132
142
|
};
|
|
133
143
|
type MarkerEvent<OriginalEventT = undefined> = MapEvent<Marker$1, OriginalEventT>;
|
|
134
144
|
type MarkerDragEvent = MarkerEvent & {
|
|
135
|
-
type:
|
|
145
|
+
type: 'dragstart' | 'drag' | 'dragend';
|
|
136
146
|
lngLat: LngLat;
|
|
137
147
|
};
|
|
138
148
|
type GeolocateEvent = MapEvent<GeolocateControl$1>;
|
|
@@ -168,7 +178,7 @@ type MaplibreProps = Partial<ViewState> & MapCallbacks & {
|
|
|
168
178
|
/** The projection property of the style. Must conform to the Projection Style Specification.
|
|
169
179
|
* @default 'mercator'
|
|
170
180
|
*/
|
|
171
|
-
projection?: ProjectionSpecification |
|
|
181
|
+
projection?: ProjectionSpecification | 'mercator' | 'globe';
|
|
172
182
|
/** Light properties of the map. */
|
|
173
183
|
light?: LightSpecification;
|
|
174
184
|
/** Terrain property of the style. Must conform to the Terrain Style Specification.
|
|
@@ -212,7 +222,7 @@ type MapContextValue = {
|
|
|
212
222
|
mapLib: MapLib;
|
|
213
223
|
map: MapRef;
|
|
214
224
|
};
|
|
215
|
-
type MapInitOptions = Omit<MapOptions,
|
|
225
|
+
type MapInitOptions = Omit<MapOptions, 'style' | 'container' | 'bounds' | 'fitBoundsOptions' | 'center'>;
|
|
216
226
|
type MapProps = MapInitOptions & MaplibreProps & GlobalSettings & {
|
|
217
227
|
mapLib?: MapLib | Promise<MapLib>;
|
|
218
228
|
reuseMaps?: boolean;
|
|
@@ -220,13 +230,9 @@ type MapProps = MapInitOptions & MaplibreProps & GlobalSettings & {
|
|
|
220
230
|
id?: string;
|
|
221
231
|
/** Map container CSS style */
|
|
222
232
|
style?: CSSProperties;
|
|
223
|
-
children?: React.ReactNode;
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
/** Show Attribution (default: true) */
|
|
227
|
-
showAttribution?: boolean;
|
|
228
|
-
} & React.RefAttributes<MapRef>;
|
|
229
|
-
declare const Map: React.FC<MapProps>;
|
|
233
|
+
children?: React$1.ReactNode;
|
|
234
|
+
} & React$1.RefAttributes<MapRef>;
|
|
235
|
+
declare const Map: React$1.FC<MapProps>;
|
|
230
236
|
|
|
231
237
|
type MarkerProps = MarkerOptions & {
|
|
232
238
|
/** Longitude of the anchor location */
|
|
@@ -235,14 +241,14 @@ type MarkerProps = MarkerOptions & {
|
|
|
235
241
|
latitude: number;
|
|
236
242
|
popup?: Popup$1;
|
|
237
243
|
/** CSS style override, applied to the control's container */
|
|
238
|
-
style?: React.CSSProperties;
|
|
244
|
+
style?: React$1.CSSProperties;
|
|
239
245
|
onClick?: (e: MarkerEvent<MouseEvent>) => void;
|
|
240
246
|
onDragStart?: (e: MarkerDragEvent) => void;
|
|
241
247
|
onDrag?: (e: MarkerDragEvent) => void;
|
|
242
248
|
onDragEnd?: (e: MarkerDragEvent) => void;
|
|
243
|
-
children?: React.ReactNode;
|
|
249
|
+
children?: React$1.ReactNode;
|
|
244
250
|
};
|
|
245
|
-
declare const Marker: React.FC<MarkerProps>;
|
|
251
|
+
declare const Marker: React$1.FC<MarkerProps>;
|
|
246
252
|
|
|
247
253
|
type PopupProps = PopupOptions & {
|
|
248
254
|
/** Longitude of the anchor location */
|
|
@@ -250,37 +256,37 @@ type PopupProps = PopupOptions & {
|
|
|
250
256
|
/** Latitude of the anchor location */
|
|
251
257
|
latitude: number;
|
|
252
258
|
/** CSS style override, applied to the control's container */
|
|
253
|
-
style?: React.CSSProperties;
|
|
259
|
+
style?: React$1.CSSProperties;
|
|
254
260
|
onOpen?: (e: PopupEvent) => void;
|
|
255
261
|
onClose?: (e: PopupEvent) => void;
|
|
256
|
-
children?: React.ReactNode;
|
|
262
|
+
children?: React$1.ReactNode;
|
|
257
263
|
};
|
|
258
|
-
declare const Popup: React.FC<PopupProps>;
|
|
264
|
+
declare const Popup: React$1.FC<PopupProps>;
|
|
259
265
|
|
|
260
266
|
type AttributionControlProps = AttributionControlOptions & {
|
|
261
267
|
/** Placement of the control relative to the map. */
|
|
262
268
|
position?: ControlPosition;
|
|
263
269
|
/** CSS style override, applied to the control's container */
|
|
264
|
-
style?: React.CSSProperties;
|
|
270
|
+
style?: React$1.CSSProperties;
|
|
265
271
|
};
|
|
266
|
-
declare const AttributionControl: React.FC<AttributionControlProps>;
|
|
272
|
+
declare const AttributionControl: React$1.FC<AttributionControlProps>;
|
|
267
273
|
|
|
268
|
-
type FullscreenControlProps = Omit<FullscreenControlOptions,
|
|
274
|
+
type FullscreenControlProps = Omit<FullscreenControlOptions, 'container'> & {
|
|
269
275
|
/** Id of the DOM element which should be made full screen. By default, the map container
|
|
270
276
|
* element will be made full screen. */
|
|
271
277
|
containerId?: string;
|
|
272
278
|
/** Placement of the control relative to the map. */
|
|
273
279
|
position?: ControlPosition;
|
|
274
280
|
/** CSS style override, applied to the control's container */
|
|
275
|
-
style?: React.CSSProperties;
|
|
281
|
+
style?: React$1.CSSProperties;
|
|
276
282
|
};
|
|
277
|
-
declare const FullscreenControl: React.FC<FullscreenControlProps>;
|
|
283
|
+
declare const FullscreenControl: React$1.FC<FullscreenControlProps>;
|
|
278
284
|
|
|
279
285
|
type GeolocateControlProps = GeolocateControlOptions & {
|
|
280
286
|
/** Placement of the control relative to the map. */
|
|
281
287
|
position?: ControlPosition;
|
|
282
288
|
/** CSS style override, applied to the control's container */
|
|
283
|
-
style?: React.CSSProperties;
|
|
289
|
+
style?: React$1.CSSProperties;
|
|
284
290
|
/** Called on each Geolocation API position update that returned as success. */
|
|
285
291
|
onGeolocate?: (e: GeolocateResultEvent) => void;
|
|
286
292
|
/** Called on each Geolocation API position update that returned as an error. */
|
|
@@ -293,15 +299,15 @@ type GeolocateControlProps = GeolocateControlOptions & {
|
|
|
293
299
|
/** Called when the GeolocateControl changes to the background state. */
|
|
294
300
|
onTrackUserLocationEnd?: (e: GeolocateEvent) => void;
|
|
295
301
|
};
|
|
296
|
-
declare const GeolocateControl: React.FC<GeolocateControlProps>;
|
|
302
|
+
declare const GeolocateControl: React$1.FC<GeolocateControlProps>;
|
|
297
303
|
|
|
298
304
|
type NavigationControlProps = NavigationControlOptions & {
|
|
299
305
|
/** Placement of the control relative to the map. */
|
|
300
306
|
position?: ControlPosition;
|
|
301
307
|
/** CSS style override, applied to the control's container */
|
|
302
|
-
style?: React.CSSProperties;
|
|
308
|
+
style?: React$1.CSSProperties;
|
|
303
309
|
};
|
|
304
|
-
declare const NavigationControl: React.FC<NavigationControlProps>;
|
|
310
|
+
declare const NavigationControl: React$1.FC<NavigationControlProps>;
|
|
305
311
|
|
|
306
312
|
type ScaleControlProps = ScaleControlOptions & {
|
|
307
313
|
unit?: string;
|
|
@@ -309,57 +315,307 @@ type ScaleControlProps = ScaleControlOptions & {
|
|
|
309
315
|
/** Placement of the control relative to the map. */
|
|
310
316
|
position?: ControlPosition;
|
|
311
317
|
/** CSS style override, applied to the control's container */
|
|
312
|
-
style?: React.CSSProperties;
|
|
318
|
+
style?: React$1.CSSProperties;
|
|
313
319
|
};
|
|
314
|
-
declare const ScaleControl: React.FC<ScaleControlProps>;
|
|
320
|
+
declare const ScaleControl: React$1.FC<ScaleControlProps>;
|
|
315
321
|
|
|
316
322
|
type TerrainControlProps = TerrainSpecification & {
|
|
317
323
|
/** Placement of the control relative to the map. */
|
|
318
324
|
position?: ControlPosition;
|
|
319
325
|
/** CSS style override, applied to the control's container */
|
|
320
|
-
style?: React.CSSProperties;
|
|
326
|
+
style?: React$1.CSSProperties;
|
|
321
327
|
};
|
|
322
|
-
declare const TerrainControl: React.FC<TerrainControlProps>;
|
|
328
|
+
declare const TerrainControl: React$1.FC<TerrainControlProps>;
|
|
323
329
|
|
|
324
330
|
type LogoControlProps = LogoControlOptions & {
|
|
325
331
|
/** Placement of the control relative to the map. */
|
|
326
332
|
position?: ControlPosition;
|
|
327
333
|
/** CSS style override, applied to the control's container */
|
|
328
|
-
style?: React.CSSProperties;
|
|
334
|
+
style?: React$1.CSSProperties;
|
|
329
335
|
};
|
|
330
|
-
declare const LogoControl: React.FC<LogoControlProps>;
|
|
336
|
+
declare const LogoControl: React$1.FC<LogoControlProps>;
|
|
331
337
|
|
|
338
|
+
/**
|
|
339
|
+
* @fileoverview Source component for adding data sources to a MapLibre GL map.
|
|
340
|
+
*
|
|
341
|
+
* Sources define the data that layers can render. This component supports all
|
|
342
|
+
* MapLibre GL source types including GeoJSON, vector tiles, raster tiles. image. and video.
|
|
343
|
+
*
|
|
344
|
+
* @module components/source
|
|
345
|
+
* @see {@link https://maplibre.org/maplibre-gl-js/docs/sources/}
|
|
346
|
+
*/
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Props for the Source component.
|
|
350
|
+
*
|
|
351
|
+
* @typedef {Object} SourceProps
|
|
352
|
+
* @property {string} [id] - Unique identifier for the source. If not provided. one will be generated automatically.
|
|
353
|
+
* @property {React.ReactNode} [children] - Child Layer components that will use this source.
|
|
354
|
+
* @extends {SourceSpecification}
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* ```tsx
|
|
358
|
+
* // GeoJSON source with a layer
|
|
359
|
+
* <Source id="my-data" type="geojson" data={geojsonData}>
|
|
360
|
+
* <Layer id="points-layer" type="circle" paint={{ 'circle-radius': 8 }} />
|
|
361
|
+
* </Source>
|
|
362
|
+
*
|
|
363
|
+
* // Vector tile source
|
|
364
|
+
* <Source id="streets" type="vector" url="mapbox://streets-v11" />
|
|
365
|
+
*
|
|
366
|
+
* // Raster source
|
|
367
|
+
* <Source id="satellite" type="raster" tiles={['https://example.com/tiles/{z}/{x}/{y}.png']} tileSize={256} />
|
|
368
|
+
* ```
|
|
369
|
+
*/
|
|
332
370
|
type SourceProps = SourceSpecification & {
|
|
371
|
+
/** Unique identifier for the source. If not provided. one will be generated automatically. */
|
|
333
372
|
id?: string;
|
|
373
|
+
/** Child Layer components that will use this source. */
|
|
334
374
|
children?: any;
|
|
335
375
|
};
|
|
336
|
-
declare
|
|
376
|
+
declare const Source: React$1.MemoExoticComponent<React$1.ForwardRefExoticComponent<SourceProps & React$1.RefAttributes<Source$1>>>;
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* @fileoverview CanvasSource component for adding canvas-based data sources to a MapLibre GL map.
|
|
380
|
+
*
|
|
381
|
+
* Canvas sources allow rendering custom HTML canvas elements as map layers.
|
|
382
|
+
* This is useful for dynamic, animated, or custom-rendered data overlays.
|
|
383
|
+
*
|
|
384
|
+
* @module components/canvas-source
|
|
385
|
+
* @see {@link https://maplibre.org/maplibre-gl-js/docs/sources/}
|
|
386
|
+
*/
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Coordinates for the canvas corners [top-left, top-right, bottom-right, bottom-left]
|
|
390
|
+
*/
|
|
391
|
+
type CanvasCoordinates = [
|
|
392
|
+
[
|
|
393
|
+
number,
|
|
394
|
+
number
|
|
395
|
+
],
|
|
396
|
+
[
|
|
397
|
+
number,
|
|
398
|
+
number
|
|
399
|
+
],
|
|
400
|
+
[
|
|
401
|
+
number,
|
|
402
|
+
number
|
|
403
|
+
],
|
|
404
|
+
[
|
|
405
|
+
number,
|
|
406
|
+
number
|
|
407
|
+
]
|
|
408
|
+
];
|
|
409
|
+
/**
|
|
410
|
+
* Props for the CanvasSource component.
|
|
411
|
+
*
|
|
412
|
+
* @typedef {Object} CanvasSourceProps
|
|
413
|
+
* @property {string} [id] - Unique identifier for the source.
|
|
414
|
+
* @property {CanvasCoordinates} coordinates - Corner coordinates of the canvas.
|
|
415
|
+
* @property {HTMLCanvasElement} canvas - The canvas element to render.
|
|
416
|
+
* @property {boolean} [animate] - Whether to animate the canvas (re-render on each frame).
|
|
417
|
+
* @property {number} [width] - Width of the canvas context.
|
|
418
|
+
* @property {number} [height] - Height of the canvas context.
|
|
419
|
+
* @property {React.ReactNode} [children] - Child Layer components.
|
|
420
|
+
*
|
|
421
|
+
* @example
|
|
422
|
+
* ```tsx
|
|
423
|
+
* // Canvas source with dynamic content
|
|
424
|
+
* const canvasRef = useRef<HTMLCanvasElement>(null);
|
|
425
|
+
* const [canvasEl, setCanvasEl] = useState<HTMLCanvasElement | null>(null);
|
|
426
|
+
*
|
|
427
|
+
* useEffect(() => {
|
|
428
|
+
* const canvas = canvasRef.current;
|
|
429
|
+
* if (!canvas) return;
|
|
430
|
+
* const ctx = canvas.getContext('2d');
|
|
431
|
+
* if (ctx) {
|
|
432
|
+
* ctx.fillStyle = 'rgba(255, 0, 0, 0.5)';
|
|
433
|
+
* ctx.fillRect(0, 0, 100, 100);
|
|
434
|
+
* }
|
|
435
|
+
* setCanvasEl(canvas);
|
|
436
|
+
* }, []);
|
|
437
|
+
*
|
|
438
|
+
* {canvasEl && (
|
|
439
|
+
* <CanvasSource
|
|
440
|
+
* id="canvas-source"
|
|
441
|
+
* coordinates={[
|
|
442
|
+
* [90.39, 23.83], // top-left
|
|
443
|
+
* [90.41, 23.83], // top-right
|
|
444
|
+
* [90.41, 23.81], // bottom-right
|
|
445
|
+
* [90.39, 23.81] // bottom-left
|
|
446
|
+
* ]}
|
|
447
|
+
* canvas={canvasEl}
|
|
448
|
+
* >
|
|
449
|
+
* <Layer type="raster" paint={{ 'raster-opacity': 0.8 }} />
|
|
450
|
+
* </CanvasSource>
|
|
451
|
+
* )}
|
|
452
|
+
* ```
|
|
453
|
+
*/
|
|
454
|
+
type CanvasSourceProps = {
|
|
455
|
+
/** Unique identifier for the source */
|
|
456
|
+
id?: string;
|
|
457
|
+
/** Corner coordinates of the canvas [top-left, top-right, bottom-right, bottom-left] */
|
|
458
|
+
coordinates: CanvasCoordinates;
|
|
459
|
+
/** The canvas element to render */
|
|
460
|
+
canvas: HTMLCanvasElement;
|
|
461
|
+
/** Whether to animate the canvas (re-render on each frame) */
|
|
462
|
+
animate?: boolean;
|
|
463
|
+
/** Width of the canvas context */
|
|
464
|
+
width?: number;
|
|
465
|
+
/** Height of the canvas context */
|
|
466
|
+
height?: number;
|
|
467
|
+
/** Child Layer components */
|
|
468
|
+
children?: React$1.ReactNode;
|
|
469
|
+
};
|
|
470
|
+
declare const CanvasSource: React$1.NamedExoticComponent<CanvasSourceProps>;
|
|
337
471
|
|
|
472
|
+
/**
|
|
473
|
+
* Utility type to make id optional in layer specification.
|
|
474
|
+
* @private
|
|
475
|
+
*/
|
|
338
476
|
type OptionalId<T> = T extends {
|
|
339
477
|
id: string;
|
|
340
|
-
} ? Omit<T,
|
|
478
|
+
} ? Omit<T, 'id'> & {
|
|
341
479
|
id?: string;
|
|
342
480
|
} : T;
|
|
481
|
+
/**
|
|
482
|
+
* Utility type to make source optional in layer specification.
|
|
483
|
+
* @private
|
|
484
|
+
*/
|
|
343
485
|
type OptionalSource<T> = T extends {
|
|
344
486
|
source: string;
|
|
345
|
-
} ? Omit<T,
|
|
487
|
+
} ? Omit<T, 'source'> & {
|
|
346
488
|
source?: string;
|
|
347
489
|
} : T;
|
|
490
|
+
/**
|
|
491
|
+
* Props for the Layer component.
|
|
492
|
+
*
|
|
493
|
+
* @typedef {Object} LayerProps
|
|
494
|
+
* @property {string} [id] - Unique identifier for the layer. If not provided, one will be generated automatically.
|
|
495
|
+
* @property {string} [source] - The source ID this layer should use (inherited from parent Source component).
|
|
496
|
+
* @property {string} [beforeId] - If set, the layer will be inserted before the specified layer.
|
|
497
|
+
* @property {function} [onClick] - Called when the layer is clicked.
|
|
498
|
+
* @property {function} [onMouseEnter] - Called when the mouse enters the layer.
|
|
499
|
+
* @property {function} [onMouseLeave] - Called when the mouse leaves the layer.
|
|
500
|
+
* @property {function} [onMouseMove] - Called when the mouse moves over the layer.
|
|
501
|
+
* @property {function} [onMouseDown] - Called when mouse button is pressed on the layer.
|
|
502
|
+
* @property {function} [onMouseUp] - Called when mouse button is released on the layer.
|
|
503
|
+
* @property {function} [onContextMenu] - Called on right-click context menu.
|
|
504
|
+
* @property {function} [onDoubleClick] - Called on double click.
|
|
505
|
+
* @extends {LayerSpecification | CustomLayerInterface}
|
|
506
|
+
*
|
|
507
|
+
* @example
|
|
508
|
+
* ```tsx
|
|
509
|
+
* // Circle layer with paint properties
|
|
510
|
+
* <Layer
|
|
511
|
+
* id="points-layer"
|
|
512
|
+
* type="circle"
|
|
513
|
+
* paint={{
|
|
514
|
+
* 'circle-radius': 8,
|
|
515
|
+
* 'circle-color': '#007cbf'
|
|
516
|
+
* }}
|
|
517
|
+
* />
|
|
518
|
+
*
|
|
519
|
+
* // Line layer with filter
|
|
520
|
+
* <Layer
|
|
521
|
+
* id="roads-layer"
|
|
522
|
+
* type="line"
|
|
523
|
+
* source="streets"
|
|
524
|
+
* source-layer="road"
|
|
525
|
+
* filter={['==', ['get', 'type'], 'primary']}
|
|
526
|
+
* paint={{ 'line-width': 2 }}
|
|
527
|
+
* />
|
|
528
|
+
*
|
|
529
|
+
* // Interactive layer with events
|
|
530
|
+
* <Layer
|
|
531
|
+
* id="interactive-layer"
|
|
532
|
+
* type="fill"
|
|
533
|
+
* paint={{ 'fill-color': '#088' }}
|
|
534
|
+
* onClick={(e) => console.log('Clicked:', e.features)}
|
|
535
|
+
* onMouseEnter={(e) => console.log('Hover:', e.features)}
|
|
536
|
+
* onMouseLeave={() => console.log('Left layer')}
|
|
537
|
+
* />
|
|
538
|
+
*
|
|
539
|
+
* // Custom layer
|
|
540
|
+
* <Layer
|
|
541
|
+
* type="custom"
|
|
542
|
+
* renderingMode="2d"
|
|
543
|
+
* onAdd={(map) => { ... }}
|
|
544
|
+
* render={(gl, matrix) => { ... }}
|
|
545
|
+
* />
|
|
546
|
+
* ```
|
|
547
|
+
*/
|
|
348
548
|
type LayerProps = (OptionalSource<OptionalId<LayerSpecification>> | CustomLayerInterface) & {
|
|
349
549
|
/** If set, the layer will be inserted before the specified layer */
|
|
350
550
|
beforeId?: string;
|
|
551
|
+
/** Called when the layer is clicked */
|
|
552
|
+
onClick?: (e: MapLayerMouseEvent) => void;
|
|
553
|
+
/** Called when the mouse enters the layer */
|
|
554
|
+
onMouseEnter?: (e: MapLayerMouseEvent) => void;
|
|
555
|
+
/** Called when the mouse leaves the layer */
|
|
556
|
+
onMouseLeave?: () => void;
|
|
557
|
+
/** Called when the mouse moves over the layer */
|
|
558
|
+
onMouseMove?: (e: MapLayerMouseEvent) => void;
|
|
559
|
+
/** Called when mouse button is pressed on the layer */
|
|
560
|
+
onMouseDown?: (e: MapLayerMouseEvent) => void;
|
|
561
|
+
/** Called when mouse button is released on the layer */
|
|
562
|
+
onMouseUp?: (e: MapLayerMouseEvent) => void;
|
|
563
|
+
/** Called on right-click context menu */
|
|
564
|
+
onContextMenu?: (e: MapLayerMouseEvent) => void;
|
|
565
|
+
/** Called on double click */
|
|
566
|
+
onDoubleClick?: (e: MapLayerMouseEvent) => void;
|
|
351
567
|
};
|
|
352
|
-
|
|
568
|
+
/**
|
|
569
|
+
* Layer component for adding visual layers to a MapLibre GL map.
|
|
570
|
+
*
|
|
571
|
+
* Layers define how data from sources is rendered on the map. Supports all
|
|
572
|
+
* MapLibre GL layer types including fill, line, circle, symbol, raster,
|
|
573
|
+
* hillshade, heatmap, and custom layers.
|
|
574
|
+
*
|
|
575
|
+
* Must be a child of a Source component (for data layers) or used standalone
|
|
576
|
+
* with a source prop for pre-existing sources.
|
|
577
|
+
*
|
|
578
|
+
* @component
|
|
579
|
+
* @example
|
|
580
|
+
* ```tsx
|
|
581
|
+
* // Circle layer with paint properties
|
|
582
|
+
* <Layer
|
|
583
|
+
* id="points-layer"
|
|
584
|
+
* type="circle"
|
|
585
|
+
* paint={{
|
|
586
|
+
* 'circle-radius': 8,
|
|
587
|
+
* 'circle-color': '#007cbf'
|
|
588
|
+
* }}
|
|
589
|
+
* />
|
|
590
|
+
*
|
|
591
|
+
* // Line layer with filter
|
|
592
|
+
* <Layer
|
|
593
|
+
* id="roads-layer"
|
|
594
|
+
* type="line"
|
|
595
|
+
* source="streets"
|
|
596
|
+
* source-layer="road"
|
|
597
|
+
* filter={['==', ['get', 'type'], 'primary']}
|
|
598
|
+
* paint={{ 'line-width': 2 }}
|
|
599
|
+
* />
|
|
600
|
+
*
|
|
601
|
+
* // Inside a Source component
|
|
602
|
+
* <Source id="geojson" type="geojson" data={data}>
|
|
603
|
+
* <Layer type="circle" paint={{ 'circle-radius': 6 }} />
|
|
604
|
+
* </Source>
|
|
605
|
+
* ```
|
|
606
|
+
*/
|
|
607
|
+
declare function _Layer(props: LayerProps): any;
|
|
608
|
+
declare const Layer: React$1.MemoExoticComponent<typeof _Layer>;
|
|
353
609
|
|
|
354
610
|
type ControlOptions = {
|
|
355
611
|
position?: ControlPosition;
|
|
356
612
|
};
|
|
357
|
-
declare function useControl<T extends
|
|
358
|
-
declare function useControl<T extends
|
|
359
|
-
declare function useControl<T extends
|
|
613
|
+
declare function useControl<T extends MapControl>(onCreate: (context: MapContextValue) => T, opts?: ControlOptions): T;
|
|
614
|
+
declare function useControl<T extends MapControl>(onCreate: (context: MapContextValue) => T, onRemove: (context: MapContextValue) => void, opts?: ControlOptions): T;
|
|
615
|
+
declare function useControl<T extends MapControl>(onCreate: (context: MapContextValue) => T, onAdd: (context: MapContextValue) => void, onRemove: (context: MapContextValue) => void, opts?: ControlOptions): T;
|
|
360
616
|
|
|
361
|
-
declare const MapProvider: React.FC<{
|
|
362
|
-
children?: React.ReactNode;
|
|
617
|
+
declare const MapProvider: React$1.FC<{
|
|
618
|
+
children?: React$1.ReactNode;
|
|
363
619
|
}>;
|
|
364
620
|
type MapCollection = {
|
|
365
621
|
[id: string]: MapRef | undefined;
|
|
@@ -367,4 +623,248 @@ type MapCollection = {
|
|
|
367
623
|
};
|
|
368
624
|
declare function useMap(): MapCollection;
|
|
369
625
|
|
|
370
|
-
|
|
626
|
+
/**
|
|
627
|
+
* Draw event types
|
|
628
|
+
*/
|
|
629
|
+
interface DrawEvent {
|
|
630
|
+
type: string;
|
|
631
|
+
features?: GeoJSON.Feature<GeoJSON.Geometry>[];
|
|
632
|
+
featureIds?: string[];
|
|
633
|
+
mode?: string;
|
|
634
|
+
originalEvent?: unknown;
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Draw control options - extends maplibre-gl-draw options
|
|
638
|
+
*/
|
|
639
|
+
interface DrawControlOptions {
|
|
640
|
+
/** Whether controls are displayed by default */
|
|
641
|
+
displayControlsDefault?: boolean;
|
|
642
|
+
/** Control configuration */
|
|
643
|
+
controls?: {
|
|
644
|
+
point?: boolean;
|
|
645
|
+
line_string?: boolean;
|
|
646
|
+
polygon?: boolean;
|
|
647
|
+
trash?: boolean;
|
|
648
|
+
combine_features?: boolean;
|
|
649
|
+
uncombine_features?: boolean;
|
|
650
|
+
};
|
|
651
|
+
/** Custom styles for draw layers */
|
|
652
|
+
styles?: unknown[];
|
|
653
|
+
/** Available modes */
|
|
654
|
+
modes?: Record<string, unknown>;
|
|
655
|
+
/** Default mode */
|
|
656
|
+
defaultMode?: string;
|
|
657
|
+
}
|
|
658
|
+
type DrawControlProps = DrawControlOptions & {
|
|
659
|
+
/** Placement of the control relative to the map. */
|
|
660
|
+
position?: ControlPosition;
|
|
661
|
+
/** CSS style override, applied to the control's container */
|
|
662
|
+
style?: React$1.CSSProperties;
|
|
663
|
+
/** Callback fired when a feature is created */
|
|
664
|
+
onDrawCreate?: (e: DrawEvent) => void;
|
|
665
|
+
/** Callback fired when a feature is deleted */
|
|
666
|
+
onDrawDelete?: (e: DrawEvent) => void;
|
|
667
|
+
/** Callback fired when a feature is updated */
|
|
668
|
+
onDrawUpdate?: (e: DrawEvent) => void;
|
|
669
|
+
/** Callback fired when the selection changes */
|
|
670
|
+
onDrawSelectionChange?: (e: DrawEvent) => void;
|
|
671
|
+
/** Callback fired when the draw mode changes */
|
|
672
|
+
onDrawModeChange?: (e: DrawEvent) => void;
|
|
673
|
+
/** Callback fired when features are combined */
|
|
674
|
+
onDrawCombine?: (e: DrawEvent) => void;
|
|
675
|
+
/** Callback fired when features are uncombined */
|
|
676
|
+
onDrawUncombine?: (e: DrawEvent) => void;
|
|
677
|
+
/** Callback fired when rendering */
|
|
678
|
+
onDrawRender?: (e: DrawEvent) => void;
|
|
679
|
+
};
|
|
680
|
+
declare function _DrawControl(props: DrawControlProps): any;
|
|
681
|
+
declare const DrawControl: React$1.MemoExoticComponent<typeof _DrawControl>;
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Options for the GlobeControl
|
|
685
|
+
*/
|
|
686
|
+
interface GlobeControlOptions {
|
|
687
|
+
/** Custom button element */
|
|
688
|
+
buttonElement?: HTMLElement;
|
|
689
|
+
/** Custom button class name */
|
|
690
|
+
buttonClassName?: string;
|
|
691
|
+
/** Button title/tooltip text */
|
|
692
|
+
buttonTitle?: string;
|
|
693
|
+
/** Custom CSS for the button */
|
|
694
|
+
buttonStyle?: React.CSSProperties;
|
|
695
|
+
}
|
|
696
|
+
type GlobeControlProps = GlobeControlOptions & {
|
|
697
|
+
/** Position of the control on the map */
|
|
698
|
+
position?: ControlPosition;
|
|
699
|
+
/** Called when projection changes */
|
|
700
|
+
onProjectionChange?: (isGlobe: boolean) => void;
|
|
701
|
+
};
|
|
702
|
+
/**
|
|
703
|
+
* GlobeControl component for toggling between 3D globe and 2D map views.
|
|
704
|
+
*
|
|
705
|
+
* This control works with MapLibre GL 3.x+ which supports globe projection.
|
|
706
|
+
* Adds a button to the map that toggles between mercator (flat) and globe (3D) projections.
|
|
707
|
+
*
|
|
708
|
+
* @component
|
|
709
|
+
* @example
|
|
710
|
+
* ```tsx
|
|
711
|
+
* import { Map, GlobeControl } from 'react-bkoi-gl';
|
|
712
|
+
* import "react-bkoi-gl/styles";
|
|
713
|
+
*
|
|
714
|
+
* function GlobeExample() {
|
|
715
|
+
* const handleProjectionChange = (isGlobe) => {
|
|
716
|
+
* console.log('Globe view:', isGlobe);
|
|
717
|
+
* };
|
|
718
|
+
*
|
|
719
|
+
* return (
|
|
720
|
+
* <Map
|
|
721
|
+
* mapStyle={`https://map.barikoi.com/styles/osm-liberty/style.json?key=${API_KEY}`}
|
|
722
|
+
* initialViewState={{
|
|
723
|
+
* longitude: 90.3938,
|
|
724
|
+
* latitude: 23.8216,
|
|
725
|
+
* zoom: 12
|
|
726
|
+
* }}
|
|
727
|
+
* >
|
|
728
|
+
* <GlobeControl
|
|
729
|
+
* position="top-right"
|
|
730
|
+
* onProjectionChange={handleProjectionChange}
|
|
731
|
+
* />
|
|
732
|
+
* </Map>
|
|
733
|
+
* );
|
|
734
|
+
* }
|
|
735
|
+
* ```
|
|
736
|
+
*/
|
|
737
|
+
declare function _GlobeControl(props: GlobeControlProps): any;
|
|
738
|
+
declare const GlobeControl: React$1.MemoExoticComponent<typeof _GlobeControl>;
|
|
739
|
+
|
|
740
|
+
type MapLibreMap = Map$1;
|
|
741
|
+
/**
|
|
742
|
+
* Map interaction types that can be disabled/enabled
|
|
743
|
+
*/
|
|
744
|
+
type MapInteractions = 'dragPan' | 'scrollZoom' | 'boxZoom' | 'dragRotate' | 'keyboard' | 'doubleClickZoom' | 'touchZoomRotate';
|
|
745
|
+
/**
|
|
746
|
+
* Configuration for minimap interactions
|
|
747
|
+
*/
|
|
748
|
+
type MinimapInteractions = Record<MapInteractions, boolean>;
|
|
749
|
+
/**
|
|
750
|
+
* Configuration for the parent rectangle overlay
|
|
751
|
+
*/
|
|
752
|
+
interface ParentRectConfig {
|
|
753
|
+
/** Layout properties for the line layer */
|
|
754
|
+
lineLayout?: Record<string, unknown>;
|
|
755
|
+
/** Paint properties for the line layer */
|
|
756
|
+
linePaint?: Record<string, unknown>;
|
|
757
|
+
/** Paint properties for the fill layer */
|
|
758
|
+
fillPaint?: Record<string, unknown>;
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Configuration for the toggle button
|
|
762
|
+
*/
|
|
763
|
+
interface ToggleButtonConfig {
|
|
764
|
+
/** Custom SVG icon */
|
|
765
|
+
icon?: string;
|
|
766
|
+
/** Custom CSS class */
|
|
767
|
+
className?: string;
|
|
768
|
+
/** Custom inline styles */
|
|
769
|
+
style?: Record<string, string>;
|
|
770
|
+
/** Background color of the icon */
|
|
771
|
+
iconBackgroundColor?: string;
|
|
772
|
+
/** Hover color */
|
|
773
|
+
hoverColor?: string;
|
|
774
|
+
/** Enable rotation based on position */
|
|
775
|
+
enableRotation?: boolean;
|
|
776
|
+
/** Custom rotation angle */
|
|
777
|
+
rotationAngle?: number;
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* Minimap control options
|
|
781
|
+
*/
|
|
782
|
+
interface MinimapControlOptions {
|
|
783
|
+
/** Initial center coordinates */
|
|
784
|
+
center?: [number, number];
|
|
785
|
+
/** Barikoi API access token */
|
|
786
|
+
accessToken?: string;
|
|
787
|
+
/** Map style for the minimap */
|
|
788
|
+
style?: string | StyleSpecification;
|
|
789
|
+
/** Zoom level difference from parent */
|
|
790
|
+
zoomAdjust?: number;
|
|
791
|
+
/** Lock to specific zoom level */
|
|
792
|
+
lockZoom?: number;
|
|
793
|
+
/** Sync pitch with parent */
|
|
794
|
+
pitchAdjust?: boolean;
|
|
795
|
+
/** Custom container styles */
|
|
796
|
+
containerStyle?: Record<string, string>;
|
|
797
|
+
/** Position on map */
|
|
798
|
+
position?: ControlPosition;
|
|
799
|
+
/** Parent rectangle configuration */
|
|
800
|
+
parentRect?: ParentRectConfig;
|
|
801
|
+
/** Whether minimap can be toggled */
|
|
802
|
+
toggleable?: boolean;
|
|
803
|
+
/** Toggle button configuration */
|
|
804
|
+
toggleButton?: ToggleButtonConfig;
|
|
805
|
+
/** Start minimized */
|
|
806
|
+
initialMinimized?: boolean;
|
|
807
|
+
/** Width when minimized */
|
|
808
|
+
collapsedWidth?: string;
|
|
809
|
+
/** Height when minimized */
|
|
810
|
+
collapsedHeight?: string;
|
|
811
|
+
/** Border radius */
|
|
812
|
+
borderRadius?: string;
|
|
813
|
+
/** Interaction configuration */
|
|
814
|
+
interactions?: Partial<MinimapInteractions>;
|
|
815
|
+
/** Toggle callback */
|
|
816
|
+
onToggle?: (isMinimized: boolean) => void;
|
|
817
|
+
/** Hide tooltip text */
|
|
818
|
+
hideText?: string;
|
|
819
|
+
/** Show tooltip text */
|
|
820
|
+
showText?: string;
|
|
821
|
+
/** Enable responsive sizing */
|
|
822
|
+
responsive?: boolean;
|
|
823
|
+
/** Responsive width */
|
|
824
|
+
responsiveWidth?: string;
|
|
825
|
+
/** Responsive height */
|
|
826
|
+
responsiveHeight?: string;
|
|
827
|
+
/** Minimum width */
|
|
828
|
+
minWidth?: string;
|
|
829
|
+
/** Minimum height */
|
|
830
|
+
minHeight?: string;
|
|
831
|
+
/** Maximum width */
|
|
832
|
+
maxWidth?: string;
|
|
833
|
+
/** Maximum height */
|
|
834
|
+
maxHeight?: string;
|
|
835
|
+
}
|
|
836
|
+
type MinimapControlProps = MinimapControlOptions;
|
|
837
|
+
/**
|
|
838
|
+
* Minimap class - wraps MapLibre Map as a control
|
|
839
|
+
*/
|
|
840
|
+
declare class Minimap implements IControl {
|
|
841
|
+
private options;
|
|
842
|
+
private map;
|
|
843
|
+
private parentMap;
|
|
844
|
+
private container;
|
|
845
|
+
private readonly id;
|
|
846
|
+
private parentRect?;
|
|
847
|
+
private differentStyle;
|
|
848
|
+
private desync?;
|
|
849
|
+
private toggleButtonCleanup?;
|
|
850
|
+
private isMinimized;
|
|
851
|
+
private resizeHandler?;
|
|
852
|
+
constructor(options?: MinimapControlOptions);
|
|
853
|
+
onAdd(parentMap: MapLibreMap): HTMLElement;
|
|
854
|
+
onRemove(): void;
|
|
855
|
+
private createContainer;
|
|
856
|
+
private getContainerStyles;
|
|
857
|
+
private validateContainerStyle;
|
|
858
|
+
private configureInteractions;
|
|
859
|
+
private setupToggleButton;
|
|
860
|
+
private setupResponsiveSizing;
|
|
861
|
+
toggle(): void;
|
|
862
|
+
isMinimizedState(): boolean;
|
|
863
|
+
private addParentRect;
|
|
864
|
+
private setParentBounds;
|
|
865
|
+
private syncMaps;
|
|
866
|
+
}
|
|
867
|
+
declare function _MinimapControl(props: MinimapControlProps): any;
|
|
868
|
+
declare const MinimapControl: React$1.MemoExoticComponent<typeof _MinimapControl>;
|
|
869
|
+
|
|
870
|
+
export { AttributionControl, type AttributionControlProps, type CanvasCoordinates, CanvasSource, type CanvasSourceProps, DrawControl, type DrawControlOptions, type DrawControlProps, type ErrorEvent, FullscreenControl, type FullscreenControlProps, GeolocateControl, type GeolocateControlProps, type GeolocateErrorEvent, type GeolocateEvent, type GeolocateResultEvent, GlobeControl, type GlobeControlOptions, type GlobeControlProps, type ImmutableLike, Layer, type LayerProps, LogoControl, type LogoControlProps, Map, type MapCallbacks, type MapControl, type MapInteractions, type MapLib, type MapMouseEvent, type MapProps, MapProvider, type MapRef, Marker, type MarkerDragEvent, type MarkerEvent, type MarkerProps, Minimap, MinimapControl, type MinimapControlOptions, type MinimapControlProps, type MinimapInteractions, NavigationControl, type NavigationControlProps, type ParentRectConfig, Popup, type PopupEvent, type PopupProps, ScaleControl, type ScaleControlProps, Source, type SourceProps, TerrainControl, type TerrainControlProps, type ToggleButtonConfig, type ViewState, type ViewStateChangeEvent, Map as default, useControl, useMap };
|