@maplibre/maplibre-react-native 11.0.0-beta.13 → 11.0.0-beta.15
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/android/src/main/java/org/maplibre/reactnative/components/annotations/markerview/MLRNMarkerView.kt +2 -29
- package/android/src/main/java/org/maplibre/reactnative/modules/MLRNOfflineModule.kt +27 -4
- package/lib/commonjs/components/camera/Camera.js +4 -3
- package/lib/commonjs/components/camera/Camera.js.map +1 -1
- package/lib/commonjs/components/map/Map.js +4 -3
- package/lib/commonjs/components/map/Map.js.map +1 -1
- package/lib/commonjs/components/sources/geojson-source/GeoJSONSource.js +4 -3
- package/lib/commonjs/components/sources/geojson-source/GeoJSONSource.js.map +1 -1
- package/lib/commonjs/components/sources/vector-source/VectorSource.js +4 -3
- package/lib/commonjs/components/sources/vector-source/VectorSource.js.map +1 -1
- package/lib/module/components/camera/Camera.js +5 -4
- package/lib/module/components/camera/Camera.js.map +1 -1
- package/lib/module/components/map/Map.js +5 -4
- package/lib/module/components/map/Map.js.map +1 -1
- package/lib/module/components/sources/geojson-source/GeoJSONSource.js +5 -4
- package/lib/module/components/sources/geojson-source/GeoJSONSource.js.map +1 -1
- package/lib/module/components/sources/vector-source/VectorSource.js +5 -4
- package/lib/module/components/sources/vector-source/VectorSource.js.map +1 -1
- package/lib/typescript/commonjs/components/camera/Camera.d.ts +6 -1
- package/lib/typescript/commonjs/components/camera/Camera.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/map/Map.d.ts +6 -1
- package/lib/typescript/commonjs/components/map/Map.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/sources/geojson-source/GeoJSONSource.d.ts +6 -2
- package/lib/typescript/commonjs/components/sources/geojson-source/GeoJSONSource.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/sources/vector-source/VectorSource.d.ts +6 -2
- package/lib/typescript/commonjs/components/sources/vector-source/VectorSource.d.ts.map +1 -1
- package/lib/typescript/commonjs/utils/animated/Animated.d.ts +1 -1
- package/lib/typescript/module/components/camera/Camera.d.ts +6 -1
- package/lib/typescript/module/components/camera/Camera.d.ts.map +1 -1
- package/lib/typescript/module/components/map/Map.d.ts +6 -1
- package/lib/typescript/module/components/map/Map.d.ts.map +1 -1
- package/lib/typescript/module/components/sources/geojson-source/GeoJSONSource.d.ts +6 -2
- package/lib/typescript/module/components/sources/geojson-source/GeoJSONSource.d.ts.map +1 -1
- package/lib/typescript/module/components/sources/vector-source/VectorSource.d.ts +6 -2
- package/lib/typescript/module/components/sources/vector-source/VectorSource.d.ts.map +1 -1
- package/lib/typescript/module/utils/animated/Animated.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/camera/Camera.tsx +69 -68
- package/src/components/map/Map.tsx +147 -154
- package/src/components/sources/geojson-source/GeoJSONSource.tsx +64 -61
- package/src/components/sources/vector-source/VectorSource.tsx +39 -36
|
@@ -6,9 +6,9 @@ import type {
|
|
|
6
6
|
import {
|
|
7
7
|
Component,
|
|
8
8
|
type ComponentProps,
|
|
9
|
-
forwardRef,
|
|
10
9
|
memo,
|
|
11
10
|
type ReactElement,
|
|
11
|
+
type Ref,
|
|
12
12
|
useImperativeHandle,
|
|
13
13
|
useLayoutEffect,
|
|
14
14
|
useMemo,
|
|
@@ -461,166 +461,159 @@ export interface MapProps extends ViewProps {
|
|
|
461
461
|
* Triggered when a style has finished loading
|
|
462
462
|
*/
|
|
463
463
|
onDidFinishLoadingStyle?: (event: NativeSyntheticEvent<null>) => void;
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Ref to access Map methods.
|
|
467
|
+
*/
|
|
468
|
+
ref?: Ref<MapRef>;
|
|
464
469
|
}
|
|
465
470
|
|
|
466
471
|
/**
|
|
467
472
|
* MapLibre Native Map
|
|
468
473
|
*/
|
|
469
474
|
export const Map = memo(
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
getCenter
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
getZoom
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
getBearing
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
getPitch
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
getBounds
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
getViewState
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
project
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
pixelPointOrPixelPointBoundsOrOptions
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
Array.isArray(pixelPointOrPixelPointBoundsOrOptions) &&
|
|
522
|
-
((value: PixelPoint | PixelPointBounds): value is PixelPoint =>
|
|
523
|
-
typeof value[0] === "number" && typeof value[1] === "number")(
|
|
524
|
-
pixelPointOrPixelPointBoundsOrOptions,
|
|
525
|
-
)
|
|
526
|
-
) {
|
|
527
|
-
return await NativeMapViewModule.queryRenderedFeaturesWithPoint(
|
|
528
|
-
findNodeHandle(nativeRef.current),
|
|
529
|
-
pixelPointOrPixelPointBoundsOrOptions,
|
|
530
|
-
options?.layers ?? [],
|
|
531
|
-
getNativeFilter(options?.filter) as string[],
|
|
532
|
-
);
|
|
533
|
-
} else if (
|
|
534
|
-
pixelPointOrPixelPointBoundsOrOptions &&
|
|
535
|
-
Array.isArray(pixelPointOrPixelPointBoundsOrOptions) &&
|
|
536
|
-
((
|
|
537
|
-
value: PixelPoint | PixelPointBounds,
|
|
538
|
-
): value is PixelPointBounds =>
|
|
539
|
-
Array.isArray(value[0]) && Array.isArray(value[1]))(
|
|
540
|
-
pixelPointOrPixelPointBoundsOrOptions,
|
|
541
|
-
)
|
|
542
|
-
) {
|
|
543
|
-
return await NativeMapViewModule.queryRenderedFeaturesWithBounds(
|
|
544
|
-
findNodeHandle(nativeRef.current),
|
|
545
|
-
pixelPointOrPixelPointBoundsOrOptions,
|
|
546
|
-
options?.layers ?? [],
|
|
547
|
-
getNativeFilter(options?.filter) as string[],
|
|
548
|
-
);
|
|
549
|
-
} else {
|
|
550
|
-
return await NativeMapViewModule.queryRenderedFeaturesWithBounds(
|
|
551
|
-
findNodeHandle(nativeRef.current),
|
|
552
|
-
null,
|
|
553
|
-
pixelPointOrPixelPointBoundsOrOptions?.layers ?? [],
|
|
554
|
-
getNativeFilter(
|
|
555
|
-
pixelPointOrPixelPointBoundsOrOptions?.filter,
|
|
556
|
-
) as string[],
|
|
557
|
-
);
|
|
558
|
-
}
|
|
559
|
-
},
|
|
560
|
-
|
|
561
|
-
createStaticMapImage: (options) =>
|
|
562
|
-
NativeMapViewModule.createStaticMapImage(
|
|
475
|
+
({ androidView = "surface", style, ref, ...props }: MapProps) => {
|
|
476
|
+
const [isReady, setIsReady] = useState(false);
|
|
477
|
+
|
|
478
|
+
const nativeRef = useRef<
|
|
479
|
+
Component<ComponentProps<typeof MapViewNativeComponent>> &
|
|
480
|
+
ReactNativeElement
|
|
481
|
+
>(null);
|
|
482
|
+
|
|
483
|
+
useImperativeHandle(ref, () => ({
|
|
484
|
+
getCenter: () =>
|
|
485
|
+
NativeMapViewModule.getCenter(findNodeHandle(nativeRef.current)),
|
|
486
|
+
|
|
487
|
+
getZoom: () =>
|
|
488
|
+
NativeMapViewModule.getZoom(findNodeHandle(nativeRef.current)),
|
|
489
|
+
|
|
490
|
+
getBearing: () =>
|
|
491
|
+
NativeMapViewModule.getBearing(findNodeHandle(nativeRef.current)),
|
|
492
|
+
|
|
493
|
+
getPitch: () =>
|
|
494
|
+
NativeMapViewModule.getPitch(findNodeHandle(nativeRef.current)),
|
|
495
|
+
|
|
496
|
+
getBounds: () =>
|
|
497
|
+
NativeMapViewModule.getBounds(findNodeHandle(nativeRef.current)),
|
|
498
|
+
|
|
499
|
+
getViewState: () =>
|
|
500
|
+
NativeMapViewModule.getViewState(
|
|
501
|
+
findNodeHandle(nativeRef.current),
|
|
502
|
+
) as Promise<ViewState>,
|
|
503
|
+
|
|
504
|
+
project: (lngLat) =>
|
|
505
|
+
NativeMapViewModule.project(findNodeHandle(nativeRef.current), lngLat),
|
|
506
|
+
|
|
507
|
+
unproject: (point) =>
|
|
508
|
+
NativeMapViewModule.unproject(findNodeHandle(nativeRef.current), point),
|
|
509
|
+
|
|
510
|
+
queryRenderedFeatures: async (
|
|
511
|
+
pixelPointOrPixelPointBoundsOrOptions?:
|
|
512
|
+
| PixelPoint
|
|
513
|
+
| PixelPointBounds
|
|
514
|
+
| QueryRenderedFeaturesOptions,
|
|
515
|
+
options?: QueryRenderedFeaturesOptions,
|
|
516
|
+
) => {
|
|
517
|
+
if (
|
|
518
|
+
pixelPointOrPixelPointBoundsOrOptions &&
|
|
519
|
+
Array.isArray(pixelPointOrPixelPointBoundsOrOptions) &&
|
|
520
|
+
((value: PixelPoint | PixelPointBounds): value is PixelPoint =>
|
|
521
|
+
typeof value[0] === "number" && typeof value[1] === "number")(
|
|
522
|
+
pixelPointOrPixelPointBoundsOrOptions,
|
|
523
|
+
)
|
|
524
|
+
) {
|
|
525
|
+
return await NativeMapViewModule.queryRenderedFeaturesWithPoint(
|
|
563
526
|
findNodeHandle(nativeRef.current),
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
527
|
+
pixelPointOrPixelPointBoundsOrOptions,
|
|
528
|
+
options?.layers ?? [],
|
|
529
|
+
getNativeFilter(options?.filter) as string[],
|
|
530
|
+
);
|
|
531
|
+
} else if (
|
|
532
|
+
pixelPointOrPixelPointBoundsOrOptions &&
|
|
533
|
+
Array.isArray(pixelPointOrPixelPointBoundsOrOptions) &&
|
|
534
|
+
((value: PixelPoint | PixelPointBounds): value is PixelPointBounds =>
|
|
535
|
+
Array.isArray(value[0]) && Array.isArray(value[1]))(
|
|
536
|
+
pixelPointOrPixelPointBoundsOrOptions,
|
|
537
|
+
)
|
|
538
|
+
) {
|
|
539
|
+
return await NativeMapViewModule.queryRenderedFeaturesWithBounds(
|
|
569
540
|
findNodeHandle(nativeRef.current),
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
)
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
NativeMapViewModule.showAttribution(
|
|
541
|
+
pixelPointOrPixelPointBoundsOrOptions,
|
|
542
|
+
options?.layers ?? [],
|
|
543
|
+
getNativeFilter(options?.filter) as string[],
|
|
544
|
+
);
|
|
545
|
+
} else {
|
|
546
|
+
return await NativeMapViewModule.queryRenderedFeaturesWithBounds(
|
|
577
547
|
findNodeHandle(nativeRef.current),
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
548
|
+
null,
|
|
549
|
+
pixelPointOrPixelPointBoundsOrOptions?.layers ?? [],
|
|
550
|
+
getNativeFilter(
|
|
551
|
+
pixelPointOrPixelPointBoundsOrOptions?.filter,
|
|
552
|
+
) as string[],
|
|
553
|
+
);
|
|
554
|
+
}
|
|
555
|
+
},
|
|
556
|
+
|
|
557
|
+
createStaticMapImage: (options) =>
|
|
558
|
+
NativeMapViewModule.createStaticMapImage(
|
|
559
|
+
findNodeHandle(nativeRef.current),
|
|
560
|
+
options.output,
|
|
561
|
+
),
|
|
562
|
+
|
|
563
|
+
setSourceVisibility: (visible, source, sourceLayer) =>
|
|
564
|
+
NativeMapViewModule.setSourceVisibility(
|
|
565
|
+
findNodeHandle(nativeRef.current),
|
|
566
|
+
visible,
|
|
567
|
+
source,
|
|
568
|
+
sourceLayer ?? null,
|
|
569
|
+
),
|
|
570
|
+
|
|
571
|
+
showAttribution: () =>
|
|
572
|
+
NativeMapViewModule.showAttribution(findNodeHandle(nativeRef.current)),
|
|
573
|
+
}));
|
|
574
|
+
|
|
575
|
+
// Start before rendering
|
|
576
|
+
useLayoutEffect(() => {
|
|
577
|
+
LogManager.start();
|
|
578
|
+
|
|
579
|
+
return () => {
|
|
580
|
+
LogManager.stop();
|
|
581
|
+
};
|
|
582
|
+
}, []);
|
|
583
|
+
|
|
584
|
+
const nativeProps = useMemo(() => {
|
|
585
|
+
const { mapStyle, light, ...otherProps } = props;
|
|
586
|
+
|
|
587
|
+
return {
|
|
588
|
+
...otherProps,
|
|
589
|
+
ref: nativeRef,
|
|
590
|
+
style: styles.flex1,
|
|
591
|
+
mapStyle:
|
|
592
|
+
typeof mapStyle === "object" ? JSON.stringify(mapStyle) : mapStyle,
|
|
593
|
+
light: props.light
|
|
594
|
+
? transformStyle(convertToInternalStyle(props.light))
|
|
595
|
+
: undefined,
|
|
596
|
+
};
|
|
597
|
+
}, [props]);
|
|
598
|
+
|
|
599
|
+
let map: ReactElement | null = null;
|
|
600
|
+
if (isReady) {
|
|
601
|
+
const NativeMapView =
|
|
602
|
+
Platform.OS === "android" && androidView === "texture"
|
|
603
|
+
? AndroidTextureMapViewNativeComponent
|
|
604
|
+
: MapViewNativeComponent;
|
|
605
|
+
|
|
606
|
+
map = <NativeMapView {...nativeProps} />;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
return (
|
|
610
|
+
<View
|
|
611
|
+
onLayout={() => setIsReady(true)}
|
|
612
|
+
style={style ?? styles.flex1}
|
|
613
|
+
testID={nativeProps.testID ? `${nativeProps.testID}-view` : undefined}
|
|
614
|
+
>
|
|
615
|
+
{map}
|
|
616
|
+
</View>
|
|
617
|
+
);
|
|
618
|
+
},
|
|
626
619
|
);
|
|
@@ -5,9 +5,9 @@ import type {
|
|
|
5
5
|
import {
|
|
6
6
|
Component,
|
|
7
7
|
type ComponentProps,
|
|
8
|
-
forwardRef,
|
|
9
8
|
memo,
|
|
10
9
|
type ReactNode,
|
|
10
|
+
type Ref,
|
|
11
11
|
useImperativeHandle,
|
|
12
12
|
useRef,
|
|
13
13
|
} from "react";
|
|
@@ -155,6 +155,11 @@ export interface GeoJSONSourceProps extends BaseProps, PressableSourceProps {
|
|
|
155
155
|
lineMetrics?: boolean;
|
|
156
156
|
|
|
157
157
|
children?: ReactNode;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Ref to access GeoJSONSource methods.
|
|
161
|
+
*/
|
|
162
|
+
ref?: Ref<GeoJSONSourceRef>;
|
|
158
163
|
}
|
|
159
164
|
|
|
160
165
|
/**
|
|
@@ -162,64 +167,62 @@ export interface GeoJSONSourceProps extends BaseProps, PressableSourceProps {
|
|
|
162
167
|
* The data may be provided as an url or a GeoJSON object.
|
|
163
168
|
*/
|
|
164
169
|
export const GeoJSONSource = memo(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
getData
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
getClusterExpansionZoom
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
getClusterChildren
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
},
|
|
224
|
-
),
|
|
170
|
+
({ id, data, ref, ...props }: GeoJSONSourceProps) => {
|
|
171
|
+
const nativeRef = useRef<
|
|
172
|
+
Component<ComponentProps<typeof GeoJSONSourceNativeComponent>> &
|
|
173
|
+
ReactNativeElement
|
|
174
|
+
>(null);
|
|
175
|
+
|
|
176
|
+
const frozenId = useFrozenId(id);
|
|
177
|
+
|
|
178
|
+
useImperativeHandle(ref, () => ({
|
|
179
|
+
getData: async (filter) => {
|
|
180
|
+
return NativeGeoJSONSourceModule.getData(
|
|
181
|
+
findNodeHandle(nativeRef.current),
|
|
182
|
+
getNativeFilter(filter),
|
|
183
|
+
);
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
getClusterExpansionZoom: async (clusterId) => {
|
|
187
|
+
return NativeGeoJSONSourceModule.getClusterExpansionZoom(
|
|
188
|
+
findNodeHandle(nativeRef.current),
|
|
189
|
+
clusterId,
|
|
190
|
+
);
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
getClusterLeaves: async (
|
|
194
|
+
clusterId: number,
|
|
195
|
+
limit: number,
|
|
196
|
+
offset: number,
|
|
197
|
+
) => {
|
|
198
|
+
return NativeGeoJSONSourceModule.getClusterLeaves(
|
|
199
|
+
findNodeHandle(nativeRef.current),
|
|
200
|
+
clusterId,
|
|
201
|
+
limit,
|
|
202
|
+
offset,
|
|
203
|
+
);
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
getClusterChildren: async (clusterId: number) => {
|
|
207
|
+
return NativeGeoJSONSourceModule.getClusterChildren(
|
|
208
|
+
findNodeHandle(nativeRef.current),
|
|
209
|
+
clusterId,
|
|
210
|
+
);
|
|
211
|
+
},
|
|
212
|
+
}));
|
|
213
|
+
|
|
214
|
+
return (
|
|
215
|
+
<GeoJSONSourceNativeComponent
|
|
216
|
+
ref={nativeRef}
|
|
217
|
+
id={frozenId}
|
|
218
|
+
data={typeof data === "string" ? data : JSON.stringify(data)}
|
|
219
|
+
hasOnPress={!!props.onPress}
|
|
220
|
+
{...props}
|
|
221
|
+
>
|
|
222
|
+
{cloneReactChildrenWithProps(props.children, {
|
|
223
|
+
source: frozenId,
|
|
224
|
+
})}
|
|
225
|
+
</GeoJSONSourceNativeComponent>
|
|
226
|
+
);
|
|
227
|
+
},
|
|
225
228
|
);
|
|
@@ -2,9 +2,9 @@ import type { FilterSpecification } from "@maplibre/maplibre-gl-style-spec";
|
|
|
2
2
|
import {
|
|
3
3
|
Component,
|
|
4
4
|
type ComponentProps,
|
|
5
|
-
forwardRef,
|
|
6
5
|
memo,
|
|
7
6
|
type ReactNode,
|
|
7
|
+
type Ref,
|
|
8
8
|
useImperativeHandle,
|
|
9
9
|
useRef,
|
|
10
10
|
} from "react";
|
|
@@ -82,48 +82,51 @@ export interface VectorSourceProps extends BaseProps, PressableSourceProps {
|
|
|
82
82
|
attribution?: string;
|
|
83
83
|
|
|
84
84
|
children?: ReactNode;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Ref to access VectorSource methods.
|
|
88
|
+
*/
|
|
89
|
+
ref?: Ref<VectorSourceRef>;
|
|
85
90
|
}
|
|
86
91
|
|
|
87
92
|
/**
|
|
88
93
|
* VectorSource is a map content source that supplies tiled vector data in Mapbox Vector Tile format to be shown on the map.
|
|
89
94
|
* The location of and metadata about the tiles are defined either by an option dictionary or by an external file that conforms to the TileJSON specification.
|
|
90
95
|
*/
|
|
91
|
-
export const VectorSource = memo(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
>(null);
|
|
96
|
+
export const VectorSource = memo(({ id, ref, ...props }: VectorSourceProps) => {
|
|
97
|
+
const nativeRef = useRef<
|
|
98
|
+
Component<ComponentProps<typeof VectorSourceNativeComponent>> &
|
|
99
|
+
ReactNativeElement
|
|
100
|
+
>(null);
|
|
97
101
|
|
|
98
|
-
|
|
102
|
+
const frozenId = useFrozenId(id);
|
|
99
103
|
|
|
100
|
-
|
|
101
|
-
|
|
104
|
+
useImperativeHandle(ref, () => ({
|
|
105
|
+
querySourceFeatures: async ({
|
|
106
|
+
sourceLayer,
|
|
107
|
+
filter,
|
|
108
|
+
}: {
|
|
109
|
+
sourceLayer: string;
|
|
110
|
+
filter?: FilterSpecification;
|
|
111
|
+
}): Promise<GeoJSON.Feature[]> => {
|
|
112
|
+
return NativeVectorSourceModule.querySourceFeatures(
|
|
113
|
+
findNodeHandle(nativeRef.current),
|
|
102
114
|
sourceLayer,
|
|
103
|
-
filter,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}): Promise<GeoJSON.Feature[]> => {
|
|
108
|
-
return NativeVectorSourceModule.querySourceFeatures(
|
|
109
|
-
findNodeHandle(nativeRef.current),
|
|
110
|
-
sourceLayer,
|
|
111
|
-
getNativeFilter(filter) as string[],
|
|
112
|
-
);
|
|
113
|
-
},
|
|
114
|
-
}));
|
|
115
|
+
getNativeFilter(filter) as string[],
|
|
116
|
+
);
|
|
117
|
+
},
|
|
118
|
+
}));
|
|
115
119
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
);
|
|
120
|
+
return (
|
|
121
|
+
<VectorSourceNativeComponent
|
|
122
|
+
ref={nativeRef}
|
|
123
|
+
id={frozenId}
|
|
124
|
+
hasOnPress={!!props.onPress}
|
|
125
|
+
{...props}
|
|
126
|
+
>
|
|
127
|
+
{cloneReactChildrenWithProps(props.children, {
|
|
128
|
+
source: frozenId,
|
|
129
|
+
})}
|
|
130
|
+
</VectorSourceNativeComponent>
|
|
131
|
+
);
|
|
132
|
+
});
|