@rnmapbox/maps 10.0.0-beta.78 → 10.0.0-beta.79
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/rctmgl/build.gradle +8 -1
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/RCTMGLCamera.kt +1 -1
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt +48 -8
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapViewManager.kt +18 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/events/constants/EventTypes.java +5 -1
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/modules/RCTMGLModule.kt +4 -2
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/utils/GeoJSONUtils.kt +4 -1
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/utils/extensions/Point.kt +5 -1
- package/ios/RCTMGL-v10/RCTMGLInteractiveElement.swift +3 -0
- package/ios/RCTMGL-v10/RCTMGLLogging.swift +3 -1
- package/ios/RCTMGL-v10/RCTMGLPointAnnotation.swift +1 -0
- package/lib/commonjs/components/MapView.js +38 -31
- package/lib/commonjs/components/MapView.js.map +1 -1
- package/lib/commonjs/components/PointAnnotation.js +2 -0
- package/lib/commonjs/components/PointAnnotation.js.map +1 -1
- package/lib/commonjs/utils/checkRequiredProps.js +14 -0
- package/lib/commonjs/utils/checkRequiredProps.js.map +1 -0
- package/lib/module/components/MapView.js +38 -31
- package/lib/module/components/MapView.js.map +1 -1
- package/lib/module/components/PointAnnotation.js +2 -0
- package/lib/module/components/PointAnnotation.js.map +1 -1
- package/lib/module/utils/checkRequiredProps.js +8 -0
- package/lib/module/utils/checkRequiredProps.js.map +1 -0
- package/lib/typescript/components/MapView.d.ts +6 -7
- package/lib/typescript/components/MapView.d.ts.map +1 -1
- package/lib/typescript/components/PointAnnotation.d.ts.map +1 -1
- package/lib/typescript/utils/checkRequiredProps.d.ts +8 -0
- package/lib/typescript/utils/checkRequiredProps.d.ts.map +1 -0
- package/package.json +3 -2
- package/rnmapbox-maps.podspec +3 -0
- package/src/components/MapView.tsx +50 -45
- package/src/components/PointAnnotation.tsx +2 -0
- package/src/utils/checkRequiredProps.ts +17 -0
|
@@ -25,12 +25,19 @@ import { type Position } from '../types/Position';
|
|
|
25
25
|
|
|
26
26
|
import NativeBridgeComponent from './NativeBridgeComponent';
|
|
27
27
|
|
|
28
|
-
const
|
|
29
|
-
|
|
28
|
+
const { MGLModule } = NativeModules;
|
|
29
|
+
const { EventTypes } = MGLModule;
|
|
30
|
+
|
|
31
|
+
if (MGLModule == null) {
|
|
30
32
|
console.error(
|
|
31
33
|
'Native part of Mapbox React Native libraries were not registered properly, double check our native installation guides.',
|
|
32
34
|
);
|
|
33
35
|
}
|
|
36
|
+
if (!MGLModule.MapboxV10) {
|
|
37
|
+
console.warn(
|
|
38
|
+
'@rnmapbox/maps: Non v10 implementations are deprecated and will be removed in next version - see https://github.com/rnmapbox/maps/wiki/Deprecated-RNMapboxImpl-Maplibre',
|
|
39
|
+
);
|
|
40
|
+
}
|
|
34
41
|
|
|
35
42
|
export const NATIVE_MODULE_NAME = 'RCTMGLMapView';
|
|
36
43
|
|
|
@@ -40,7 +47,7 @@ const styles = StyleSheet.create({
|
|
|
40
47
|
matchParent: { flex: 1 },
|
|
41
48
|
});
|
|
42
49
|
|
|
43
|
-
const defaultStyleURL =
|
|
50
|
+
const defaultStyleURL = MGLModule.StyleURL.Street;
|
|
44
51
|
|
|
45
52
|
export type Point = {
|
|
46
53
|
x: number;
|
|
@@ -59,7 +66,7 @@ export type RegionPayload = {
|
|
|
59
66
|
};
|
|
60
67
|
|
|
61
68
|
/**
|
|
62
|
-
* v10 only
|
|
69
|
+
* v10 only
|
|
63
70
|
*/
|
|
64
71
|
export type MapState = {
|
|
65
72
|
properties: {
|
|
@@ -74,19 +81,20 @@ export type MapState = {
|
|
|
74
81
|
};
|
|
75
82
|
gestures: {
|
|
76
83
|
isGestureActive: boolean;
|
|
77
|
-
isAnimatingFromGesture: boolean;
|
|
78
84
|
};
|
|
79
85
|
};
|
|
80
86
|
|
|
81
87
|
/**
|
|
82
|
-
* label localization settings (v10 only)
|
|
88
|
+
* label localization settings (v10 only). `true` is equivalent to current locale.
|
|
83
89
|
*/
|
|
84
|
-
type LocalizeLabels =
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
type LocalizeLabels =
|
|
91
|
+
| {
|
|
92
|
+
/** locale code like `es` or `current` for the device's current locale */
|
|
93
|
+
locale: string;
|
|
94
|
+
/** layer id to localize. If not specified, all layers will be localized */
|
|
95
|
+
layerIds?: string[];
|
|
96
|
+
}
|
|
97
|
+
| true;
|
|
90
98
|
|
|
91
99
|
type Props = ViewProps & {
|
|
92
100
|
/**
|
|
@@ -100,7 +108,7 @@ type Props = ViewProps & {
|
|
|
100
108
|
projection?: 'mercator' | 'globe';
|
|
101
109
|
|
|
102
110
|
/**
|
|
103
|
-
* Style URL for map - notice, if non is set it _will_ default to `
|
|
111
|
+
* Style URL for map - notice, if non is set it _will_ default to `Mapbox.StyleURL.Street`
|
|
104
112
|
*/
|
|
105
113
|
styleURL?: string;
|
|
106
114
|
|
|
@@ -266,12 +274,12 @@ type Props = ViewProps & {
|
|
|
266
274
|
) => void;
|
|
267
275
|
|
|
268
276
|
/**
|
|
269
|
-
*
|
|
277
|
+
* v10 only, replaces onRegionIsChanging
|
|
270
278
|
*/
|
|
271
279
|
onCameraChanged?: (state: MapState) => void;
|
|
272
280
|
|
|
273
281
|
/**
|
|
274
|
-
*
|
|
282
|
+
* v10 only, replaces onRegionDidChange
|
|
275
283
|
*/
|
|
276
284
|
onMapIdle?: (state: MapState) => void;
|
|
277
285
|
|
|
@@ -467,12 +475,12 @@ class MapView extends NativeBridgeComponent(
|
|
|
467
475
|
}
|
|
468
476
|
|
|
469
477
|
_setHandledMapChangedEvents(props: Props) {
|
|
470
|
-
if (isAndroid() ||
|
|
478
|
+
if (isAndroid() || MGLModule.MapboxV10) {
|
|
471
479
|
const events: string[] = [];
|
|
472
480
|
|
|
473
481
|
function addIfHasHandler(name: CallbablePropKeysWithoutOn) {
|
|
474
482
|
if (props[`on${name}`] != null) {
|
|
475
|
-
if (
|
|
483
|
+
if (EventTypes[name] == null) {
|
|
476
484
|
if (name === 'DidFailLoadingMap') {
|
|
477
485
|
console.warn(
|
|
478
486
|
`rnmapbox maps: on${name} is deprecated, please use onMapLoadingError`,
|
|
@@ -481,7 +489,7 @@ class MapView extends NativeBridgeComponent(
|
|
|
481
489
|
console.warn(`rnmapbox maps: ${name} is not supported`);
|
|
482
490
|
}
|
|
483
491
|
} else {
|
|
484
|
-
events.push(
|
|
492
|
+
events.push(EventTypes[name]);
|
|
485
493
|
return true;
|
|
486
494
|
}
|
|
487
495
|
}
|
|
@@ -504,9 +512,9 @@ class MapView extends NativeBridgeComponent(
|
|
|
504
512
|
addIfHasHandler('DidFinishRenderingMapFully');
|
|
505
513
|
addIfHasHandler('DidFinishLoadingStyle');
|
|
506
514
|
|
|
507
|
-
if (addIfHasHandler('
|
|
515
|
+
if (addIfHasHandler('RegionDidChange')) {
|
|
508
516
|
console.warn(
|
|
509
|
-
'
|
|
517
|
+
'onRegionDidChange is deprecated and will be removed in next beta - please use onMapIdle',
|
|
510
518
|
);
|
|
511
519
|
if (props.onRegionDidChange) {
|
|
512
520
|
console.warn(
|
|
@@ -514,11 +522,11 @@ class MapView extends NativeBridgeComponent(
|
|
|
514
522
|
);
|
|
515
523
|
}
|
|
516
524
|
}
|
|
517
|
-
if (addIfHasHandler('
|
|
525
|
+
if (addIfHasHandler('RegionIsChanging')) {
|
|
518
526
|
console.warn(
|
|
519
|
-
'
|
|
527
|
+
'onRegionIsChanging is deprecated and will be removed in next beta - please use onCameraChanged',
|
|
520
528
|
);
|
|
521
|
-
if (props.
|
|
529
|
+
if (props.onCameraChanged) {
|
|
522
530
|
console.warn(
|
|
523
531
|
'rnmapbox/maps: only one of MapView.onRegionIsChanging or onCameraChanged is supported',
|
|
524
532
|
);
|
|
@@ -639,7 +647,7 @@ class MapView extends NativeBridgeComponent(
|
|
|
639
647
|
): Promise<GeoJSON.FeatureCollection | undefined> {
|
|
640
648
|
if (
|
|
641
649
|
bbox != null &&
|
|
642
|
-
(bbox.length === 4 || (
|
|
650
|
+
(bbox.length === 4 || (MGLModule.MapboxV10 && bbox.length === 0))
|
|
643
651
|
) {
|
|
644
652
|
const res = await this._runNative<{ data: GeoJSON.FeatureCollection }>(
|
|
645
653
|
'queryRenderedFeaturesInRect',
|
|
@@ -815,64 +823,64 @@ class MapView extends NativeBridgeComponent(
|
|
|
815
823
|
let deprecatedPropName: CallbablePropKeys | '' = '';
|
|
816
824
|
|
|
817
825
|
switch (type) {
|
|
818
|
-
case
|
|
826
|
+
case EventTypes.RegionWillChange:
|
|
819
827
|
if (regionWillChangeDebounceTime && regionWillChangeDebounceTime > 0) {
|
|
820
828
|
this._onDebouncedRegionWillChange(payload);
|
|
821
829
|
} else {
|
|
822
830
|
propName = 'onRegionWillChange';
|
|
823
831
|
}
|
|
824
832
|
break;
|
|
825
|
-
case
|
|
833
|
+
case EventTypes.RegionIsChanging:
|
|
826
834
|
propName = 'onRegionIsChanging';
|
|
827
835
|
break;
|
|
828
|
-
case
|
|
836
|
+
case EventTypes.RegionDidChange:
|
|
829
837
|
if (regionDidChangeDebounceTime && regionDidChangeDebounceTime > 0) {
|
|
830
838
|
this._onDebouncedRegionDidChange(payload);
|
|
831
839
|
} else {
|
|
832
840
|
propName = 'onRegionDidChange';
|
|
833
841
|
}
|
|
834
842
|
break;
|
|
835
|
-
case
|
|
843
|
+
case EventTypes.CameraChanged:
|
|
836
844
|
propName = 'onCameraChanged';
|
|
837
845
|
break;
|
|
838
|
-
case
|
|
846
|
+
case EventTypes.MapIdle:
|
|
839
847
|
propName = 'onMapIdle';
|
|
840
848
|
break;
|
|
841
|
-
case
|
|
849
|
+
case EventTypes.UserLocationUpdated:
|
|
842
850
|
propName = 'onUserLocationUpdate';
|
|
843
851
|
break;
|
|
844
|
-
case
|
|
852
|
+
case EventTypes.WillStartLoadingMap:
|
|
845
853
|
propName = 'onWillStartLoadingMap';
|
|
846
854
|
break;
|
|
847
|
-
case
|
|
855
|
+
case EventTypes.DidFinishLoadingMap:
|
|
848
856
|
propName = 'onDidFinishLoadingMap';
|
|
849
857
|
break;
|
|
850
|
-
case
|
|
858
|
+
case EventTypes.DidFailLoadingMap:
|
|
851
859
|
propName = 'onDidFailLoadingMap';
|
|
852
860
|
break;
|
|
853
|
-
case
|
|
861
|
+
case EventTypes.MapLoadingError:
|
|
854
862
|
propName = 'onMapLoadingError';
|
|
855
863
|
deprecatedPropName = 'onDidFailLoadingMap';
|
|
856
864
|
break;
|
|
857
|
-
case
|
|
865
|
+
case EventTypes.WillStartRenderingFrame:
|
|
858
866
|
propName = 'onWillStartRenderingFrame';
|
|
859
867
|
break;
|
|
860
|
-
case
|
|
868
|
+
case EventTypes.DidFinishRenderingFrame:
|
|
861
869
|
propName = 'onDidFinishRenderingFrame';
|
|
862
870
|
break;
|
|
863
|
-
case
|
|
871
|
+
case EventTypes.DidFinishRenderingFrameFully:
|
|
864
872
|
propName = 'onDidFinishRenderingFrameFully';
|
|
865
873
|
break;
|
|
866
|
-
case
|
|
874
|
+
case EventTypes.WillStartRenderingMap:
|
|
867
875
|
propName = 'onWillStartRenderingMap';
|
|
868
876
|
break;
|
|
869
|
-
case
|
|
877
|
+
case EventTypes.DidFinishRenderingMap:
|
|
870
878
|
propName = 'onDidFinishRenderingMap';
|
|
871
879
|
break;
|
|
872
|
-
case
|
|
880
|
+
case EventTypes.DidFinishRenderingMapFully:
|
|
873
881
|
propName = 'onDidFinishRenderingMapFully';
|
|
874
882
|
break;
|
|
875
|
-
case
|
|
883
|
+
case EventTypes.DidFinishLoadingStyle:
|
|
876
884
|
propName = 'onDidFinishLoadingStyle';
|
|
877
885
|
break;
|
|
878
886
|
default:
|
|
@@ -944,13 +952,10 @@ class MapView extends NativeBridgeComponent(
|
|
|
944
952
|
}
|
|
945
953
|
|
|
946
954
|
_setLocalizeLabels(props: Props) {
|
|
947
|
-
if (!
|
|
955
|
+
if (!MGLModule.MapboxV10) {
|
|
948
956
|
return;
|
|
949
957
|
}
|
|
950
958
|
if (typeof props.localizeLabels === 'boolean') {
|
|
951
|
-
console.warn(
|
|
952
|
-
'boolean value of localizeLabels is deprecated. Please set this as Locale object instead',
|
|
953
|
-
);
|
|
954
959
|
props.localizeLabels = {
|
|
955
960
|
locale: 'current',
|
|
956
961
|
};
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
import { Feature, Point } from 'geojson';
|
|
9
9
|
|
|
10
10
|
import { toJSONString, isFunction } from '../utils';
|
|
11
|
+
import checkRequiredProps from '../utils/checkRequiredProps';
|
|
11
12
|
import { makePoint } from '../utils/geoUtils';
|
|
12
13
|
import { type BaseProps } from '../types/BaseProps';
|
|
13
14
|
import { Position } from '../types/Position';
|
|
@@ -136,6 +137,7 @@ class PointAnnotation extends NativeBridgeComponent(
|
|
|
136
137
|
|
|
137
138
|
constructor(props: Props) {
|
|
138
139
|
super(props);
|
|
140
|
+
checkRequiredProps('PointAnnotation', props, ['id', 'coordinate']);
|
|
139
141
|
this._onSelected = this._onSelected.bind(this);
|
|
140
142
|
this._onDeselected = this._onDeselected.bind(this);
|
|
141
143
|
this._onDragStart = this._onDragStart.bind(this);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type RequiredKeys<T> = {
|
|
2
|
+
[k in keyof T]-?: undefined extends T[k] ? never : k;
|
|
3
|
+
}[keyof T];
|
|
4
|
+
|
|
5
|
+
export default function checkRequiredProps<
|
|
6
|
+
Props extends { [key: string]: unknown },
|
|
7
|
+
>(tag: string, props: Props, required: RequiredKeys<Props>[]) {
|
|
8
|
+
for (const key of required) {
|
|
9
|
+
if (props[key] === undefined) {
|
|
10
|
+
console.error(
|
|
11
|
+
`Error: ${tag} property: ${
|
|
12
|
+
key as string
|
|
13
|
+
} is required but it was missing.`,
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|