@rnmapbox/maps 10.3.0-rc.0 → 10.3.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/android/src/main/java/com/rnmapbox/rnmbx/components/annotation/RNMBXMarkerViewContent.kt +55 -0
- package/android/src/main/java/com/rnmapbox/rnmbx/components/annotation/RNMBXMarkerViewContentManager.kt +7 -2
- package/android/src/main/java/com/rnmapbox/rnmbx/components/annotation/RNMBXMarkerViewManager.kt +0 -2
- package/android/src/main/java/com/rnmapbox/rnmbx/components/location/RNMBXNativeUserLocationManager.kt +25 -24
- package/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/NativeMapViewModule.kt +3 -2
- package/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/RNMBXMapView.kt +57 -39
- package/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/RNMBXMapViewManager.kt +0 -9
- package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/atmosphere/RNMBXAtmosphere.kt +4 -4
- package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/atmosphere/RNMBXAtmosphereManager.kt +2 -1
- package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/light/RNMBXLightManager.kt +2 -1
- package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXSource.kt +2 -6
- package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/terrain/RNMBXTerrainManager.kt +2 -1
- package/android/src/main/java/com/rnmapbox/rnmbx/events/FeatureClickEvent.java +5 -6
- package/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXModule.kt +1 -0
- package/android/src/main/java/com/rnmapbox/rnmbx/utils/ConvertUtils.kt +0 -30
- package/android/src/main/java/com/rnmapbox/rnmbx/utils/extensions/Dynamic.kt +3 -1
- package/android/src/main/java/com/rnmapbox/rnmbx/utils/extensions/ReadableArray.kt +16 -14
- package/ios/RNMBX/RNMBXMapViewModule.mm +1 -1
- package/ios/RNMBX/RNMBXModule.swift +1 -0
- package/lib/module/Mapbox.native.js.map +1 -1
- package/lib/module/components/MapView.js +95 -113
- package/lib/module/components/MapView.js.map +1 -1
- package/lib/module/components/MarkerView.js +93 -76
- package/lib/module/components/MarkerView.js.map +1 -1
- package/lib/module/modules/offline/offlineManager.js +2 -12
- package/lib/module/modules/offline/offlineManager.js.map +1 -1
- package/lib/module/specs/RNMBXMarkerViewContentNativeComponent.ts +13 -1
- package/lib/typescript/src/Mapbox.native.d.ts +1 -1
- package/lib/typescript/src/Mapbox.native.d.ts.map +1 -1
- package/lib/typescript/src/components/Camera.d.ts +2 -2
- package/lib/typescript/src/components/Camera.d.ts.map +1 -1
- package/lib/typescript/src/components/MapView.d.ts +53 -41
- package/lib/typescript/src/components/MapView.d.ts.map +1 -1
- package/lib/typescript/src/components/MarkerView.d.ts +10 -17
- package/lib/typescript/src/components/MarkerView.d.ts.map +1 -1
- package/lib/typescript/src/modules/offline/offlineManager.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXMarkerViewContentNativeComponent.d.ts +6 -0
- package/lib/typescript/src/specs/RNMBXMarkerViewContentNativeComponent.d.ts.map +1 -1
- package/package.json +1 -1
- package/setup-jest.js +1 -1
- package/src/Mapbox.native.ts +5 -1
- package/src/components/Camera.tsx +2 -2
- package/src/components/MapView.tsx +137 -154
- package/src/components/MarkerView.tsx +118 -95
- package/src/modules/offline/offlineManager.ts +2 -14
- package/src/specs/RNMBXMarkerViewContentNativeComponent.ts +13 -1
|
@@ -37,11 +37,6 @@ if (RNMBXModule == null) {
|
|
|
37
37
|
'Native part of Mapbox React Native libraries were not registered properly, double check our native installation guides.',
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
|
-
if (!RNMBXModule.MapboxV10) {
|
|
41
|
-
console.warn(
|
|
42
|
-
'@rnmapbox/maps: Non v10 implementations are deprecated and will be removed in next version - see https://github.com/rnmapbox/maps/wiki/Deprecated-RNMapboxImpl-Maplibre',
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
40
|
|
|
46
41
|
const styles = StyleSheet.create({
|
|
47
42
|
matchParent: { flex: 1 },
|
|
@@ -65,6 +60,11 @@ export type RegionPayload = {
|
|
|
65
60
|
pitch: number;
|
|
66
61
|
};
|
|
67
62
|
|
|
63
|
+
export type ScreenPointPayload = {
|
|
64
|
+
readonly screenPointX: number;
|
|
65
|
+
readonly screenPointY: number;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
68
|
export type GestureSettings = {
|
|
69
69
|
/**
|
|
70
70
|
* Whether double tapping the map with one touch results in a zoom-in animation.
|
|
@@ -312,14 +312,18 @@ type Props = ViewProps & {
|
|
|
312
312
|
gestureSettings?: GestureSettings;
|
|
313
313
|
|
|
314
314
|
/**
|
|
315
|
-
* Map press listener,
|
|
315
|
+
* Map press listener, called when a user presses the map.
|
|
316
316
|
*/
|
|
317
|
-
onPress?: (
|
|
317
|
+
onPress?: (
|
|
318
|
+
feature: GeoJSON.Feature<GeoJSON.Point, ScreenPointPayload>,
|
|
319
|
+
) => void;
|
|
318
320
|
|
|
319
321
|
/**
|
|
320
|
-
* Map long press listener,
|
|
322
|
+
* Map long press listener, called when a user long presses the map.
|
|
321
323
|
*/
|
|
322
|
-
onLongPress?: (
|
|
324
|
+
onLongPress?: (
|
|
325
|
+
feature: GeoJSON.Feature<GeoJSON.Point, ScreenPointPayload>,
|
|
326
|
+
) => void;
|
|
323
327
|
|
|
324
328
|
/**
|
|
325
329
|
* <v10 only
|
|
@@ -470,7 +474,7 @@ const CallbablePropKeys = [
|
|
|
470
474
|
'onCameraChanged',
|
|
471
475
|
] as const;
|
|
472
476
|
|
|
473
|
-
type CallbablePropKeys =
|
|
477
|
+
type CallbablePropKeys = typeof CallbablePropKeys[number];
|
|
474
478
|
|
|
475
479
|
type CallbablePropKeysWithoutOn = CallbablePropKeys extends `on${infer C}`
|
|
476
480
|
? C
|
|
@@ -494,7 +498,7 @@ class MapView extends NativeBridgeComponent(
|
|
|
494
498
|
compassFadeWhenNorth: false,
|
|
495
499
|
logoEnabled: true,
|
|
496
500
|
scaleBarEnabled: true,
|
|
497
|
-
surfaceView:
|
|
501
|
+
surfaceView: true,
|
|
498
502
|
requestDisallowInterceptTouchEvent: false,
|
|
499
503
|
regionWillChangeDebounceTime: 10,
|
|
500
504
|
regionDidChangeDebounceTime: 500,
|
|
@@ -591,93 +595,93 @@ class MapView extends NativeBridgeComponent(
|
|
|
591
595
|
}
|
|
592
596
|
|
|
593
597
|
_setHandledMapChangedEvents(props: Props) {
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
if (
|
|
599
|
-
if (
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
);
|
|
604
|
-
} else {
|
|
605
|
-
console.warn(`rnmapbox maps: ${name} is not supported`);
|
|
606
|
-
}
|
|
598
|
+
const events: string[] = [];
|
|
599
|
+
|
|
600
|
+
function addIfHasHandler(name: CallbablePropKeysWithoutOn) {
|
|
601
|
+
if (props[`on${name}`] != null) {
|
|
602
|
+
if (EventTypes[name] == null) {
|
|
603
|
+
if (name === 'DidFailLoadingMap') {
|
|
604
|
+
console.warn(
|
|
605
|
+
`rnmapbox maps: on${name} is deprecated, please use onMapLoadingError`,
|
|
606
|
+
);
|
|
607
607
|
} else {
|
|
608
|
-
|
|
609
|
-
return true;
|
|
608
|
+
console.warn(`rnmapbox maps: ${name} is not supported`);
|
|
610
609
|
}
|
|
610
|
+
} else {
|
|
611
|
+
events.push(EventTypes[name]);
|
|
612
|
+
return true;
|
|
611
613
|
}
|
|
612
|
-
return false;
|
|
613
614
|
}
|
|
615
|
+
return false;
|
|
616
|
+
}
|
|
614
617
|
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
}
|
|
641
|
-
if (props.onMapIdle) {
|
|
642
|
-
console.warn(
|
|
643
|
-
'rnmapbox/maps: only one of MapView.onRegionDidChange or onMapIdle is supported',
|
|
644
|
-
);
|
|
645
|
-
}
|
|
618
|
+
addIfHasHandler('RegionWillChange');
|
|
619
|
+
addIfHasHandler('RegionIsChanging');
|
|
620
|
+
addIfHasHandler('RegionDidChange');
|
|
621
|
+
addIfHasHandler('UserLocationUpdate');
|
|
622
|
+
addIfHasHandler('WillStartLoadingMap');
|
|
623
|
+
addIfHasHandler('DidFinishLoadingMap');
|
|
624
|
+
addIfHasHandler('MapLoadingError');
|
|
625
|
+
addIfHasHandler('DidFailLoadingMap');
|
|
626
|
+
addIfHasHandler('WillStartRenderingFrame');
|
|
627
|
+
addIfHasHandler('DidFinishRenderingFrame');
|
|
628
|
+
addIfHasHandler('DidFinishRenderingFrameFully');
|
|
629
|
+
addIfHasHandler('WillStartRenderingMap');
|
|
630
|
+
addIfHasHandler('DidFinishRenderingMap');
|
|
631
|
+
addIfHasHandler('DidFinishRenderingMapFully');
|
|
632
|
+
addIfHasHandler('DidFinishLoadingStyle');
|
|
633
|
+
|
|
634
|
+
addIfHasHandler('CameraChanged');
|
|
635
|
+
addIfHasHandler('MapIdle');
|
|
636
|
+
|
|
637
|
+
if (addIfHasHandler('RegionDidChange')) {
|
|
638
|
+
if (!this.deprecationLogged.regionDidChange) {
|
|
639
|
+
console.warn(
|
|
640
|
+
'onRegionDidChange is deprecated and will be removed in next release - please use onMapIdle. https://github.com/rnmapbox/maps/wiki/Deprecated-RegionIsDidChange',
|
|
641
|
+
);
|
|
642
|
+
this.deprecationLogged.regionDidChange = true;
|
|
646
643
|
}
|
|
647
|
-
if (
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
);
|
|
652
|
-
this.deprecationLogged.regionIsChanging = true;
|
|
653
|
-
}
|
|
654
|
-
if (props.onCameraChanged) {
|
|
655
|
-
console.warn(
|
|
656
|
-
'rnmapbox/maps: only one of MapView.onRegionIsChanging or onCameraChanged is supported',
|
|
657
|
-
);
|
|
658
|
-
}
|
|
644
|
+
if (props.onMapIdle) {
|
|
645
|
+
console.warn(
|
|
646
|
+
'rnmapbox/maps: only one of MapView.onRegionDidChange or onMapIdle is supported',
|
|
647
|
+
);
|
|
659
648
|
}
|
|
660
|
-
|
|
661
|
-
|
|
649
|
+
}
|
|
650
|
+
if (addIfHasHandler('RegionIsChanging')) {
|
|
651
|
+
if (!this.deprecationLogged.regionIsChanging) {
|
|
652
|
+
console.warn(
|
|
653
|
+
'onRegionIsChanging is deprecated and will be removed in next release - please use onCameraChanged. https://github.com/rnmapbox/maps/wiki/Deprecated-RegionIsDidChange',
|
|
654
|
+
);
|
|
655
|
+
this.deprecationLogged.regionIsChanging = true;
|
|
656
|
+
}
|
|
657
|
+
if (props.onCameraChanged) {
|
|
662
658
|
console.warn(
|
|
663
|
-
'
|
|
659
|
+
'rnmapbox/maps: only one of MapView.onRegionIsChanging or onCameraChanged is supported',
|
|
664
660
|
);
|
|
665
661
|
}
|
|
662
|
+
}
|
|
666
663
|
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
664
|
+
if (props.onRegionWillChange) {
|
|
665
|
+
console.warn(
|
|
666
|
+
'onRegionWillChange is deprecated and will be removed in v10 - please use onRegionIsChanging',
|
|
667
|
+
);
|
|
670
668
|
}
|
|
669
|
+
|
|
670
|
+
this._runNativeMethod('setHandledMapChangedEvents', this._nativeRef, [
|
|
671
|
+
events,
|
|
672
|
+
]);
|
|
671
673
|
}
|
|
672
674
|
|
|
673
675
|
/**
|
|
674
|
-
* Converts a geographic coordinate to a
|
|
676
|
+
* Converts a geographic coordinate to a screen coordinate relative to the map view.
|
|
675
677
|
*
|
|
676
678
|
* @example
|
|
677
|
-
* const
|
|
679
|
+
* const longitude = 144.949901;
|
|
680
|
+
* const latitude = -37.817070;
|
|
681
|
+
* const [x, y] = await this._map.getPointInView([longitude, latitude]);
|
|
678
682
|
*
|
|
679
|
-
* @param {
|
|
680
|
-
* @return {
|
|
683
|
+
* @param {Position} coordinate - A point expressed in the map view's coordinate system `[longitude, latitude]`.
|
|
684
|
+
* @return {Position} A point expressed in screen coordinates relative to the map view `[x, y]`.
|
|
681
685
|
*/
|
|
682
686
|
async getPointInView(coordinate: Position): Promise<Position> {
|
|
683
687
|
const res = await this._runNative<{ pointInView: Position }>(
|
|
@@ -688,13 +692,14 @@ class MapView extends NativeBridgeComponent(
|
|
|
688
692
|
}
|
|
689
693
|
|
|
690
694
|
/**
|
|
691
|
-
* Converts a
|
|
695
|
+
* Converts a screen coordinate relative to the map view to a geographic coordinate.
|
|
692
696
|
*
|
|
693
697
|
* @example
|
|
694
|
-
* const
|
|
698
|
+
* const x = 100; const y = 100;
|
|
699
|
+
* const [longitude, latitude] = await this._map.getCoordinateFromView([x, y]);
|
|
695
700
|
*
|
|
696
|
-
* @param {
|
|
697
|
-
* @return {
|
|
701
|
+
* @param {Position} point - A point expressed in screen coordinates relative to the map view `[x, y]`.
|
|
702
|
+
* @return {Position} A point expressed in the map view's coordinate system `[longitude, latitude]`.
|
|
698
703
|
*/
|
|
699
704
|
async getCoordinateFromView(point: Position): Promise<Position> {
|
|
700
705
|
const res = await this._runNative<{ coordinateFromView: Position }>(
|
|
@@ -705,12 +710,12 @@ class MapView extends NativeBridgeComponent(
|
|
|
705
710
|
}
|
|
706
711
|
|
|
707
712
|
/**
|
|
708
|
-
* The coordinate bounds
|
|
713
|
+
* The coordinate bounds of the map viewport.
|
|
709
714
|
*
|
|
710
715
|
* @example
|
|
711
|
-
* const
|
|
716
|
+
* const [[rightLon, topLat], [leftLon, bottomLat]] = await this._map.getVisibleBounds();
|
|
712
717
|
*
|
|
713
|
-
* @return {
|
|
718
|
+
* @return {[Position, Position]} The geographic coordinate bounds of the map viewport `[[rightLon, topLat], [leftLon, bottomLat]]`.
|
|
714
719
|
*/
|
|
715
720
|
async getVisibleBounds(): Promise<[Position, Position]> {
|
|
716
721
|
const res = await this._runNative<{ visibleBounds: [Position, Position] }>(
|
|
@@ -723,12 +728,13 @@ class MapView extends NativeBridgeComponent(
|
|
|
723
728
|
* Returns an array of rendered map features that intersect with a given point.
|
|
724
729
|
*
|
|
725
730
|
* @example
|
|
726
|
-
*
|
|
731
|
+
* const x = 30; const y = 40;
|
|
732
|
+
* this._map.queryRenderedFeaturesAtPoint([x, y], ['==', 'type', 'Point'], ['id1', 'id2'])
|
|
727
733
|
*
|
|
728
|
-
* @param {
|
|
729
|
-
* @param {
|
|
730
|
-
* @param {
|
|
731
|
-
* @return {FeatureCollection}
|
|
734
|
+
* @param {Position} coordinate - A point expressed in the map view’s coordinate system `[x, y]`;
|
|
735
|
+
* @param {FilterExpression | []} filter - A set of strings that correspond to the names of layers defined in the current style. Only the features contained in these layers are included in the returned array.
|
|
736
|
+
* @param {string[]} layerIDs - A array of layer IDs by which to filter the features.
|
|
737
|
+
* @return {FeatureCollection} A GeoJSON feature collection containing the query results.
|
|
732
738
|
*/
|
|
733
739
|
|
|
734
740
|
async queryRenderedFeaturesAtPoint(
|
|
@@ -758,22 +764,21 @@ class MapView extends NativeBridgeComponent(
|
|
|
758
764
|
* passing an empty array will query the entire visible bounds of the map.
|
|
759
765
|
*
|
|
760
766
|
* @example
|
|
761
|
-
*
|
|
767
|
+
* const left = 40; const top = 30;
|
|
768
|
+
* const right = 10; const bottom = 20;
|
|
769
|
+
* this._map.queryRenderedFeaturesInRect([top, left, bottom, right], ['==', 'type', 'Point'], ['id1', 'id2'])
|
|
762
770
|
*
|
|
763
|
-
* @param {
|
|
764
|
-
* @param {
|
|
765
|
-
* @param {
|
|
766
|
-
* @return {FeatureCollection}
|
|
771
|
+
* @param {BBox | []} bbox - A rectangle expressed in density-independent screen coordinates relative to the map view `[top, left, bottom, right]` or `[minY, minX, maxY, maxX]` (not geographic coordinates). An empty array queries the visible map area.
|
|
772
|
+
* @param {FilterExpression} filter - An array of strings that correspond to the names of layers defined in the current style. Only the features contained in these layers are included in the returned array.
|
|
773
|
+
* @param {string[] | null} layerIDs - A array of layer IDs by which to filter the features.
|
|
774
|
+
* @return {FeatureCollection} A GeoJSON feature collection containing the query results.
|
|
767
775
|
*/
|
|
768
776
|
async queryRenderedFeaturesInRect(
|
|
769
777
|
bbox: BBox | [],
|
|
770
778
|
filter: FilterExpression | [] = [],
|
|
771
779
|
layerIDs: string[] | null = null,
|
|
772
780
|
): Promise<GeoJSON.FeatureCollection | undefined> {
|
|
773
|
-
if (
|
|
774
|
-
bbox != null &&
|
|
775
|
-
(bbox.length === 4 || (RNMBXModule.MapboxV10 && bbox.length === 0))
|
|
776
|
-
) {
|
|
781
|
+
if (bbox != null && (bbox.length === 4 || bbox.length === 0)) {
|
|
777
782
|
const res = await this._runNative<{ data: GeoJSON.FeatureCollection }>(
|
|
778
783
|
'queryRenderedFeaturesInRect',
|
|
779
784
|
[bbox, getFilter(filter), layerIDs],
|
|
@@ -786,7 +791,7 @@ class MapView extends NativeBridgeComponent(
|
|
|
786
791
|
return res.data;
|
|
787
792
|
} else {
|
|
788
793
|
throw new Error(
|
|
789
|
-
'Must pass in a valid bounding box: [top,
|
|
794
|
+
'Must pass in a valid bounding box: [top, left, bottom, right]. An empty array [] is also acceptable in v10.',
|
|
790
795
|
);
|
|
791
796
|
}
|
|
792
797
|
}
|
|
@@ -798,9 +803,9 @@ class MapView extends NativeBridgeComponent(
|
|
|
798
803
|
* this._map.querySourceFeatures('your-source-id', [], ['your-source-layer'])
|
|
799
804
|
*
|
|
800
805
|
* @param {String} sourceId - Style source identifier used to query for source features.
|
|
801
|
-
* @param {
|
|
802
|
-
* @param {
|
|
803
|
-
* @return {FeatureCollection}
|
|
806
|
+
* @param {FilterExpression | []} filter - A filter to limit query results.
|
|
807
|
+
* @param {string[]} sourceLayerIDs - The name of the source layers to query. For vector tile sources, this parameter is required. For GeoJSON sources, it is ignored.
|
|
808
|
+
* @return {FeatureCollection} A GeoJSON feature collection.
|
|
804
809
|
*/
|
|
805
810
|
async querySourceFeatures(
|
|
806
811
|
sourceId: string,
|
|
@@ -844,9 +849,11 @@ class MapView extends NativeBridgeComponent(
|
|
|
844
849
|
}
|
|
845
850
|
|
|
846
851
|
/**
|
|
847
|
-
* Takes snapshot of map with current tiles and returns a
|
|
848
|
-
*
|
|
849
|
-
*
|
|
852
|
+
* Takes snapshot of map with current tiles and returns a Base64-encoded PNG image,
|
|
853
|
+
* or an file-system URI to a temporary PNG file if `writeToDisk` is `true`.
|
|
854
|
+
*
|
|
855
|
+
* @param {boolean} writeToDisk If `true`, creates a temporary PNG file and returns a file-system URI, otherwise returns a Base64-encoded PNG image. (Defaults to `false`)
|
|
856
|
+
* @return {string} A a Base64-encoded PNG image or a file-system URI to a temporary PNG file.
|
|
850
857
|
*/
|
|
851
858
|
async takeSnap(writeToDisk = false): Promise<string> {
|
|
852
859
|
const res = await this._runNative<{ uri: string }>('takeSnap', [
|
|
@@ -861,7 +868,7 @@ class MapView extends NativeBridgeComponent(
|
|
|
861
868
|
* @example
|
|
862
869
|
* const zoom = await this._map.getZoom();
|
|
863
870
|
*
|
|
864
|
-
* @return {
|
|
871
|
+
* @return {number} The current zoom of the map view.
|
|
865
872
|
*/
|
|
866
873
|
|
|
867
874
|
async getZoom(): Promise<number> {
|
|
@@ -870,12 +877,12 @@ class MapView extends NativeBridgeComponent(
|
|
|
870
877
|
}
|
|
871
878
|
|
|
872
879
|
/**
|
|
873
|
-
* Returns the map's
|
|
880
|
+
* Returns the map's center point expressed as geographic coordinates `[longitude, latitude]`.
|
|
874
881
|
*
|
|
875
882
|
* @example
|
|
876
883
|
* const center = await this._map.getCenter();
|
|
877
884
|
*
|
|
878
|
-
* @return {
|
|
885
|
+
* @return {Position} The map's center point expressed as geographic coordinates `[longitude, latitude]`.
|
|
879
886
|
*/
|
|
880
887
|
async getCenter(): Promise<Position> {
|
|
881
888
|
const res = await this._runNative<{ center: Position }>('getCenter');
|
|
@@ -891,12 +898,6 @@ class MapView extends NativeBridgeComponent(
|
|
|
891
898
|
* v10 only
|
|
892
899
|
*/
|
|
893
900
|
async clearData(): Promise<void> {
|
|
894
|
-
if (!RNMBXModule.MapboxV10) {
|
|
895
|
-
console.warn(
|
|
896
|
-
'RNMapbox: clearData is only implemented in v10 implementation or later',
|
|
897
|
-
);
|
|
898
|
-
return;
|
|
899
|
-
}
|
|
900
901
|
await this._runNative<void>('clearData');
|
|
901
902
|
}
|
|
902
903
|
|
|
@@ -905,8 +906,8 @@ class MapView extends NativeBridgeComponent(
|
|
|
905
906
|
* The elevation is returned in meters relative to mean sea-level.
|
|
906
907
|
* Returns null if terrain is disabled or if terrain data for the location hasn't been loaded yet.
|
|
907
908
|
*
|
|
908
|
-
* @param {
|
|
909
|
-
* @return {
|
|
909
|
+
* @param {Position} coordinate - The geographic coordinates `[longitude, latitude]` at which to query elevation.
|
|
910
|
+
* @return {number} Elevation in meters relative to mean sea-level.
|
|
910
911
|
*/
|
|
911
912
|
async queryTerrainElevation(coordinate: Position): Promise<number> {
|
|
912
913
|
const res = await this._runNative<{ data: number }>(
|
|
@@ -923,8 +924,8 @@ class MapView extends NativeBridgeComponent(
|
|
|
923
924
|
* await this._map.setSourceVisibility(false, 'composite', 'building')
|
|
924
925
|
*
|
|
925
926
|
* @param {boolean} visible - Visibility of the layers
|
|
926
|
-
* @param {
|
|
927
|
-
* @param {
|
|
927
|
+
* @param {string} sourceId - Target source identifier (e.g. 'composite')
|
|
928
|
+
* @param {string | null} sourceLayerId - Target source-layer identifier (e.g. 'building'). If `null`, the change affects all layers in the target source.
|
|
928
929
|
*/
|
|
929
930
|
setSourceVisibility(
|
|
930
931
|
visible: boolean,
|
|
@@ -956,13 +957,6 @@ class MapView extends NativeBridgeComponent(
|
|
|
956
957
|
sourceId: string,
|
|
957
958
|
sourceLayerId: string | null = null,
|
|
958
959
|
): Promise<void> {
|
|
959
|
-
if (!RNMBXModule.MapboxV10) {
|
|
960
|
-
console.warn(
|
|
961
|
-
'RNMapbox: setFeatureState is only implemented in v10 implementation or later',
|
|
962
|
-
);
|
|
963
|
-
return;
|
|
964
|
-
}
|
|
965
|
-
|
|
966
960
|
await this._runNative<void>('setFeatureState', [
|
|
967
961
|
featureId,
|
|
968
962
|
state,
|
|
@@ -983,13 +977,6 @@ class MapView extends NativeBridgeComponent(
|
|
|
983
977
|
sourceId: string,
|
|
984
978
|
sourceLayerId: string | null = null,
|
|
985
979
|
): Promise<Readonly<Record<string, unknown>>> {
|
|
986
|
-
if (!RNMBXModule.MapboxV10) {
|
|
987
|
-
console.warn(
|
|
988
|
-
'RNMapbox: setFeatureState is only implemented in v10 implementation or later',
|
|
989
|
-
);
|
|
990
|
-
return {};
|
|
991
|
-
}
|
|
992
|
-
|
|
993
980
|
const res = await this._runNative<{
|
|
994
981
|
featureState: Readonly<Record<string, unknown>>;
|
|
995
982
|
}>('getFeatureState', [featureId, sourceId, sourceLayerId]);
|
|
@@ -1013,13 +1000,6 @@ class MapView extends NativeBridgeComponent(
|
|
|
1013
1000
|
sourceId: string,
|
|
1014
1001
|
sourceLayerId: string | null = null,
|
|
1015
1002
|
): Promise<void> {
|
|
1016
|
-
if (!RNMBXModule.MapboxV10) {
|
|
1017
|
-
console.warn(
|
|
1018
|
-
'RNMapbox: removeFeatureState is only implemented in v10 implementation or later',
|
|
1019
|
-
);
|
|
1020
|
-
return;
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
1003
|
await this._runNative<void>('removeFeatureState', [
|
|
1024
1004
|
featureId,
|
|
1025
1005
|
stateKey,
|
|
@@ -1036,13 +1016,21 @@ class MapView extends NativeBridgeComponent(
|
|
|
1036
1016
|
}
|
|
1037
1017
|
}
|
|
1038
1018
|
|
|
1039
|
-
_onPress(
|
|
1019
|
+
_onPress(
|
|
1020
|
+
e: NativeSyntheticEvent<{
|
|
1021
|
+
payload: GeoJSON.Feature<GeoJSON.Point, ScreenPointPayload> | string;
|
|
1022
|
+
}>,
|
|
1023
|
+
) {
|
|
1040
1024
|
if (isFunction(this.props.onPress)) {
|
|
1041
1025
|
this.props.onPress(this._decodePayload(e.nativeEvent.payload));
|
|
1042
1026
|
}
|
|
1043
1027
|
}
|
|
1044
1028
|
|
|
1045
|
-
_onLongPress(
|
|
1029
|
+
_onLongPress(
|
|
1030
|
+
e: NativeSyntheticEvent<{
|
|
1031
|
+
payload: GeoJSON.Feature<GeoJSON.Point, ScreenPointPayload> | string;
|
|
1032
|
+
}>,
|
|
1033
|
+
) {
|
|
1046
1034
|
if (isFunction(this.props.onLongPress)) {
|
|
1047
1035
|
this.props.onLongPress(this._decodePayload(e.nativeEvent.payload));
|
|
1048
1036
|
}
|
|
@@ -1187,13 +1175,11 @@ class MapView extends NativeBridgeComponent(
|
|
|
1187
1175
|
return;
|
|
1188
1176
|
}
|
|
1189
1177
|
|
|
1190
|
-
if (
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
this.deprecationLogged.contentInset = true;
|
|
1196
|
-
}
|
|
1178
|
+
if (!this.deprecationLogged.contentInset) {
|
|
1179
|
+
console.warn(
|
|
1180
|
+
'@rnmapbox/maps: contentInset is deprecated, use Camera padding instead.',
|
|
1181
|
+
);
|
|
1182
|
+
this.deprecationLogged.contentInset = true;
|
|
1197
1183
|
}
|
|
1198
1184
|
|
|
1199
1185
|
if (!Array.isArray(this.props.contentInset)) {
|
|
@@ -1235,9 +1221,6 @@ class MapView extends NativeBridgeComponent(
|
|
|
1235
1221
|
}
|
|
1236
1222
|
|
|
1237
1223
|
_setLocalizeLabels(props: Props) {
|
|
1238
|
-
if (!RNMBXModule.MapboxV10) {
|
|
1239
|
-
return;
|
|
1240
|
-
}
|
|
1241
1224
|
if (typeof props.localizeLabels === 'boolean') {
|
|
1242
1225
|
props.localizeLabels = {
|
|
1243
1226
|
locale: 'current',
|