@rnmapbox/maps 10.0.0-beta.72 → 10.0.0-beta.74
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/src/main/java-v10/com/mapbox/rctmgl/RCTMGLPackage.java +2 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLPointAnnotation.kt +0 -1
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/images/RCTMGLImage.kt +74 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/images/RCTMGLImageManager.kt +67 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/images/RCTMGLImages.kt +62 -35
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/images/RCTMGLImagesManager.kt +216 -0
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/location/LocationComponentManager.kt +4 -2
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTLayer.kt +9 -3
- package/index.d.ts +22 -74
- package/javascript/components/AbstractLayer.tsx +2 -1
- package/javascript/components/AbstractSource.tsx +3 -1
- package/javascript/components/Atmosphere.tsx +2 -1
- package/javascript/components/Camera.tsx +6 -4
- package/javascript/components/Image.tsx +12 -4
- package/javascript/components/Images.tsx +1 -1
- package/javascript/components/Light.tsx +60 -0
- package/javascript/components/PointAnnotation.tsx +2 -1
- package/javascript/components/ShapeSource.tsx +1 -11
- package/javascript/components/Terrain.tsx +2 -1
- package/javascript/components/VectorSource.tsx +209 -0
- package/javascript/components/annotations/Annotation.js +9 -10
- package/javascript/modules/location/locationManager.ts +2 -2
- package/javascript/types/BaseProps.ts +3 -0
- package/javascript/types/OnPressEvent.ts +11 -0
- package/javascript/utils/{Logger.js → Logger.ts} +32 -14
- package/javascript/utils/MapboxStyles.d.ts +1 -1
- package/javascript/utils/deprecation.ts +3 -3
- package/javascript/utils/nativeRef.ts +28 -0
- package/lib/commonjs/components/AbstractLayer.js.map +1 -1
- package/lib/commonjs/components/AbstractSource.js.map +1 -1
- package/lib/commonjs/components/Atmosphere.js.map +1 -1
- package/lib/commonjs/components/Camera.js +4 -4
- package/lib/commonjs/components/Camera.js.map +1 -1
- package/lib/commonjs/components/Image.js.map +1 -1
- package/lib/commonjs/components/Images.js +1 -1
- package/lib/commonjs/components/Images.js.map +1 -1
- package/lib/commonjs/components/Light.js +32 -33
- package/lib/commonjs/components/Light.js.map +1 -1
- package/lib/commonjs/components/PointAnnotation.js.map +1 -1
- package/lib/commonjs/components/ShapeSource.js.map +1 -1
- package/lib/commonjs/components/Terrain.js.map +1 -1
- package/lib/commonjs/components/VectorSource.js +15 -74
- package/lib/commonjs/components/VectorSource.js.map +1 -1
- package/lib/commonjs/components/annotations/Annotation.js +6 -9
- package/lib/commonjs/components/annotations/Annotation.js.map +1 -1
- package/lib/commonjs/modules/location/locationManager.js +2 -1
- package/lib/commonjs/modules/location/locationManager.js.map +1 -1
- package/lib/commonjs/types/BaseProps.js +2 -0
- package/lib/commonjs/types/BaseProps.js.map +1 -0
- package/lib/commonjs/types/OnPressEvent.js +2 -0
- package/lib/commonjs/types/OnPressEvent.js.map +1 -0
- package/lib/commonjs/utils/Logger.js +7 -7
- package/lib/commonjs/utils/Logger.js.map +1 -1
- package/lib/commonjs/utils/deprecation.js +2 -2
- package/lib/commonjs/utils/nativeRef.js +27 -0
- package/lib/commonjs/utils/nativeRef.js.map +1 -0
- package/lib/module/components/AbstractLayer.js.map +1 -1
- package/lib/module/components/AbstractSource.js.map +1 -1
- package/lib/module/components/Atmosphere.js.map +1 -1
- package/lib/module/components/Camera.js +4 -4
- package/lib/module/components/Camera.js.map +1 -1
- package/lib/module/components/Image.js.map +1 -1
- package/lib/module/components/Images.js +1 -1
- package/lib/module/components/Images.js.map +1 -1
- package/lib/module/components/Light.js +29 -32
- package/lib/module/components/Light.js.map +1 -1
- package/lib/module/components/PointAnnotation.js.map +1 -1
- package/lib/module/components/ShapeSource.js.map +1 -1
- package/lib/module/components/Terrain.js.map +1 -1
- package/lib/module/components/VectorSource.js +15 -74
- package/lib/module/components/VectorSource.js.map +1 -1
- package/lib/module/components/annotations/Annotation.js +6 -9
- package/lib/module/components/annotations/Annotation.js.map +1 -1
- package/lib/module/modules/location/locationManager.js +1 -1
- package/lib/module/modules/location/locationManager.js.map +1 -1
- package/lib/module/types/BaseProps.js +2 -0
- package/lib/module/types/BaseProps.js.map +1 -0
- package/lib/module/types/OnPressEvent.js +2 -0
- package/lib/module/types/OnPressEvent.js.map +1 -0
- package/lib/module/utils/Logger.js +7 -7
- package/lib/module/utils/Logger.js.map +1 -1
- package/lib/module/utils/deprecation.js +2 -2
- package/lib/module/utils/nativeRef.js +21 -0
- package/lib/module/utils/nativeRef.js.map +1 -0
- package/lib/typescript/components/AbstractLayer.d.ts +2 -1
- package/lib/typescript/components/AbstractLayer.d.ts.map +1 -1
- package/lib/typescript/components/AbstractSource.d.ts +2 -1
- package/lib/typescript/components/AbstractSource.d.ts.map +1 -1
- package/lib/typescript/components/Atmosphere.d.ts +2 -1
- package/lib/typescript/components/Atmosphere.d.ts.map +1 -1
- package/lib/typescript/components/Camera.d.ts.map +1 -1
- package/lib/typescript/components/Image.d.ts +10 -4
- package/lib/typescript/components/Image.d.ts.map +1 -1
- package/lib/typescript/components/Images.d.ts +1 -1
- package/lib/typescript/components/Images.d.ts.map +1 -1
- package/lib/typescript/components/Light.d.ts +17 -0
- package/lib/typescript/components/Light.d.ts.map +1 -0
- package/lib/typescript/components/PointAnnotation.d.ts +2 -1
- package/lib/typescript/components/PointAnnotation.d.ts.map +1 -1
- package/lib/typescript/components/ShapeSource.d.ts +3 -13
- package/lib/typescript/components/ShapeSource.d.ts.map +1 -1
- package/lib/typescript/components/Terrain.d.ts +2 -1
- package/lib/typescript/components/Terrain.d.ts.map +1 -1
- package/lib/typescript/components/VectorSource.d.ts +144 -0
- package/lib/typescript/components/VectorSource.d.ts.map +1 -0
- package/lib/typescript/modules/location/locationManager.d.ts +2 -2
- package/lib/typescript/modules/location/locationManager.d.ts.map +1 -1
- package/lib/typescript/types/BaseProps.d.ts +4 -0
- package/lib/typescript/types/BaseProps.d.ts.map +1 -0
- package/lib/typescript/types/OnPressEvent.d.ts +12 -0
- package/lib/typescript/types/OnPressEvent.d.ts.map +1 -0
- package/lib/typescript/utils/Logger.d.ts +53 -0
- package/lib/typescript/utils/Logger.d.ts.map +1 -0
- package/lib/typescript/utils/deprecation.d.ts +4 -3
- package/lib/typescript/utils/deprecation.d.ts.map +1 -1
- package/lib/typescript/utils/nativeRef.d.ts +21 -0
- package/lib/typescript/utils/nativeRef.d.ts.map +1 -0
- package/package.json +1 -1
- package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/images/RCTMGLImagesManager.java +0 -103
- package/javascript/components/Light.js +0 -47
- package/javascript/components/VectorSource.js +0 -203
package/index.d.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
declare module 'react-native-mapbox-gl__maps';
|
|
2
2
|
|
|
3
3
|
import { Component, FC, ReactNode } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
ViewProps,
|
|
6
|
-
ViewStyle,
|
|
7
|
-
StyleProp,
|
|
8
|
-
TextStyle,
|
|
9
|
-
ImageSourcePropType,
|
|
10
|
-
} from 'react-native';
|
|
4
|
+
import { ViewProps, ViewStyle, StyleProp, TextStyle } from 'react-native';
|
|
11
5
|
import ReactNative from 'react-native';
|
|
12
6
|
import {
|
|
13
7
|
Geometry,
|
|
@@ -70,6 +64,8 @@ import {
|
|
|
70
64
|
ShapeSource as _ShapeSource,
|
|
71
65
|
Props as _ShapeSourceProps,
|
|
72
66
|
} from './javascript/components/ShapeSource';
|
|
67
|
+
import _VectorSource from './javascript/components/VectorSource';
|
|
68
|
+
import _Light from './javascript/components/Light';
|
|
73
69
|
import type {
|
|
74
70
|
MapboxGLEvent as _MapboxGLEvent,
|
|
75
71
|
AnimatedPoint as _AnimatedPoint,
|
|
@@ -78,9 +74,15 @@ import type {
|
|
|
78
74
|
import type { requestAndroidLocationPermissions as _requestAndroidLocationPermissions } from './javascript/requestAndroidLocationPermissions';
|
|
79
75
|
import type {
|
|
80
76
|
Location as _Location,
|
|
81
|
-
Coordinates as _Coordinates,
|
|
82
77
|
LocationManager,
|
|
83
78
|
} from './javascript/modules/location/locationManager';
|
|
79
|
+
import type { OnPressEvent as _OnPressEvent } from './javascript/types/OnPressEvent';
|
|
80
|
+
import {
|
|
81
|
+
type LogLevel,
|
|
82
|
+
type LogObject,
|
|
83
|
+
type LogCallback,
|
|
84
|
+
Logger as _Logger,
|
|
85
|
+
} from './javascript/utils/Logger';
|
|
84
86
|
|
|
85
87
|
// prettier-ignore
|
|
86
88
|
type ExpressionName =
|
|
@@ -131,17 +133,7 @@ type Visibility = 'visible' | 'none';
|
|
|
131
133
|
type Alignment = 'map' | 'viewport';
|
|
132
134
|
type AutoAlignment = Alignment | 'auto';
|
|
133
135
|
|
|
134
|
-
export type OnPressEvent =
|
|
135
|
-
features: Array<GeoJSON.Feature>;
|
|
136
|
-
coordinates: {
|
|
137
|
-
latitude: number;
|
|
138
|
-
longitude: number;
|
|
139
|
-
};
|
|
140
|
-
point: {
|
|
141
|
-
x: number;
|
|
142
|
-
y: number;
|
|
143
|
-
};
|
|
144
|
-
};
|
|
136
|
+
export type OnPressEvent = _OnPressEvent;
|
|
145
137
|
|
|
146
138
|
declare namespace MapboxGL {
|
|
147
139
|
function removeCustomHeader(headerName: string): void;
|
|
@@ -157,6 +149,8 @@ declare namespace MapboxGL {
|
|
|
157
149
|
const getAnnotationsLayerID = _getAnnotationsLayerID;
|
|
158
150
|
type getAnnotationsLayerID = _getAnnotationsLayerID;
|
|
159
151
|
|
|
152
|
+
const Logger = _Logger;
|
|
153
|
+
type Logger = _Logger;
|
|
160
154
|
const Camera = _Camera;
|
|
161
155
|
type Camera = _Camera;
|
|
162
156
|
type CameraStop = _CameraStop;
|
|
@@ -180,7 +174,9 @@ declare namespace MapboxGL {
|
|
|
180
174
|
type UserTrackingMode = _UserTrackingMode;
|
|
181
175
|
type UserTrackingModeChangeCallback = _UserTrackingModeChangeCallback;
|
|
182
176
|
type Location = _Location;
|
|
183
|
-
|
|
177
|
+
|
|
178
|
+
/** @deprecated This will be removed in a future release. Use `Location['coords']` instead. */
|
|
179
|
+
type Coordinates = Location['coords'];
|
|
184
180
|
|
|
185
181
|
const offlineManager: OfflineManager;
|
|
186
182
|
const snapshotManager: SnapshotManager;
|
|
@@ -333,7 +329,7 @@ declare namespace MapboxGL {
|
|
|
333
329
|
|
|
334
330
|
class UserLocation extends Component<UserLocationProps> {}
|
|
335
331
|
|
|
336
|
-
|
|
332
|
+
const Light = _Light;
|
|
337
333
|
|
|
338
334
|
class Callout extends Component<CalloutProps> {}
|
|
339
335
|
type Style = FC<StyleProps>;
|
|
@@ -341,7 +337,8 @@ declare namespace MapboxGL {
|
|
|
341
337
|
/**
|
|
342
338
|
* Sources
|
|
343
339
|
*/
|
|
344
|
-
|
|
340
|
+
type VectorSource = typeof _VectorSource;
|
|
341
|
+
const VectorSource = _VectorSource;
|
|
345
342
|
class RasterSource extends Component<RasterSourceProps> {}
|
|
346
343
|
class RasterDemSource extends Component<RasterSourceProps> {}
|
|
347
344
|
|
|
@@ -642,14 +639,6 @@ export interface TileSourceProps extends ViewProps {
|
|
|
642
639
|
maxZoomLevel?: number;
|
|
643
640
|
}
|
|
644
641
|
|
|
645
|
-
export interface VectorSourceProps extends TileSourceProps {
|
|
646
|
-
onPress?: (event: OnPressEvent) => void;
|
|
647
|
-
hitbox?: {
|
|
648
|
-
width: number;
|
|
649
|
-
height: number;
|
|
650
|
-
};
|
|
651
|
-
}
|
|
652
|
-
|
|
653
642
|
export interface RasterSourceProps extends TileSourceProps {
|
|
654
643
|
tileSize?: number;
|
|
655
644
|
}
|
|
@@ -666,35 +655,6 @@ export interface LayerBaseProps<T = object> extends Omit<ViewProps, 'style'> {
|
|
|
666
655
|
maxZoomLevel?: number;
|
|
667
656
|
}
|
|
668
657
|
|
|
669
|
-
export interface BackgroundLayerProps extends LayerBaseProps {
|
|
670
|
-
style?: StyleProp<BackgroundLayerStyle>;
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
export interface CircleLayerProps extends LayerBaseProps {
|
|
674
|
-
style?: StyleProp<CircleLayerStyle>;
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
export interface FillExtrusionLayerProps extends Omit<LayerBaseProps, 'id'> {
|
|
678
|
-
id: string;
|
|
679
|
-
style?: StyleProp<FillExtrusionLayerStyle>;
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
export interface FillLayerProps extends LayerBaseProps {
|
|
683
|
-
style?: StyleProp<FillLayerStyle>;
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
export interface LineLayerProps extends LayerBaseProps {
|
|
687
|
-
style?: StyleProp<LineLayerStyle>;
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
export interface RasterLayerProps extends LayerBaseProps {
|
|
691
|
-
style?: StyleProp<RasterLayerStyle>;
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
export interface HeatmapLayerProps extends LayerBaseProps {
|
|
695
|
-
style?: StyleProp<HeatmapLayerStyle>;
|
|
696
|
-
}
|
|
697
|
-
|
|
698
658
|
export interface ImageSourceProps extends ViewProps {
|
|
699
659
|
id: string;
|
|
700
660
|
url?: number | string;
|
|
@@ -731,21 +691,7 @@ export interface SkyLayerProps extends LayerBaseProps {
|
|
|
731
691
|
style?: StyleProp<SkyLayerStyle>;
|
|
732
692
|
}
|
|
733
693
|
|
|
734
|
-
|
|
735
|
-
type LogLevel = 'error' | 'warning' | 'info' | 'debug' | 'verbose';
|
|
736
|
-
|
|
737
|
-
interface LogObject {
|
|
738
|
-
level: LogLevel;
|
|
739
|
-
message: string;
|
|
740
|
-
tag: string;
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
type LogCallback = (object: LogObject) => void;
|
|
744
|
-
|
|
745
|
-
export class Logger {
|
|
746
|
-
public static setLogCallback: (cb: LogCallback) => boolean;
|
|
747
|
-
public static setLogLevel: (level: LogLevel) => void;
|
|
748
|
-
}
|
|
694
|
+
export import Logger = MapboxGL.Logger;
|
|
749
695
|
|
|
750
696
|
export import MapView = MapboxGL.MapView;
|
|
751
697
|
|
|
@@ -789,6 +735,8 @@ export import AnimatedMapPoint = MapboxGL.AnimatedPoint;
|
|
|
789
735
|
export import AnimatedShape = MapboxGL.AnimatedShape;
|
|
790
736
|
export import Images = MapboxGL.Images;
|
|
791
737
|
export import Image = MapboxGL.Image;
|
|
738
|
+
export import Light = MapboxGL.Light;
|
|
739
|
+
export import VectorSource = MapboxGL.VectorSource;
|
|
792
740
|
|
|
793
741
|
export const { offlineManager } = MapboxGL;
|
|
794
742
|
|
|
@@ -5,8 +5,9 @@ import { NativeMethods, processColor } from 'react-native';
|
|
|
5
5
|
import { getFilter } from '../utils/filterUtils';
|
|
6
6
|
import { AllLayerStyleProps, FilterExpression } from '../utils/MapboxStyles';
|
|
7
7
|
import { transformStyle } from '../utils/StyleValue';
|
|
8
|
+
import type { BaseProps } from '../types/BaseProps';
|
|
8
9
|
|
|
9
|
-
type PropsBase = {
|
|
10
|
+
type PropsBase = BaseProps & {
|
|
10
11
|
id: string;
|
|
11
12
|
sourceID?: string;
|
|
12
13
|
minZoomLevel?: number;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { NativeMethods } from 'react-native';
|
|
3
3
|
|
|
4
|
+
import type { BaseProps } from '../types/BaseProps';
|
|
5
|
+
|
|
4
6
|
class AbstractSource<
|
|
5
7
|
PropsType,
|
|
6
8
|
NativePropsType extends object,
|
|
7
|
-
> extends React.PureComponent<PropsType> {
|
|
9
|
+
> extends React.PureComponent<PropsType & BaseProps> {
|
|
8
10
|
_nativeRef?: React.Component<NativePropsType> & Readonly<NativeMethods>;
|
|
9
11
|
|
|
10
12
|
setNativeProps(props: NativePropsType) {
|
|
@@ -3,10 +3,11 @@ import { requireNativeComponent } from 'react-native';
|
|
|
3
3
|
|
|
4
4
|
import type { AtmosphereLayerStyleProps } from '../utils/MapboxStyles';
|
|
5
5
|
import { StyleValue, transformStyle } from '../utils/StyleValue';
|
|
6
|
+
import type { BaseProps } from '../types/BaseProps';
|
|
6
7
|
|
|
7
8
|
export const NATIVE_MODULE_NAME = 'RCTMGLAtmosphere';
|
|
8
9
|
|
|
9
|
-
type Props = {
|
|
10
|
+
type Props = BaseProps & {
|
|
10
11
|
style: AtmosphereLayerStyleProps;
|
|
11
12
|
};
|
|
12
13
|
|
|
@@ -11,6 +11,7 @@ import { NativeModules, requireNativeComponent } from 'react-native';
|
|
|
11
11
|
|
|
12
12
|
import { MapboxGLEvent } from '../types';
|
|
13
13
|
import { makeLatLngBounds, makePoint } from '../utils/geoUtils';
|
|
14
|
+
import { type NativeRefType } from '../utils/nativeRef';
|
|
14
15
|
|
|
15
16
|
const NativeModule = NativeModules.MGLModule;
|
|
16
17
|
|
|
@@ -240,8 +241,9 @@ export const Camera = memo(
|
|
|
240
241
|
onUserTrackingModeChange,
|
|
241
242
|
} = props;
|
|
242
243
|
|
|
243
|
-
|
|
244
|
-
|
|
244
|
+
const nativeCamera = useRef<typeof RCTMGLCamera>(
|
|
245
|
+
null,
|
|
246
|
+
) as NativeRefType<NativeCameraProps>;
|
|
245
247
|
|
|
246
248
|
const buildNativeStop = useCallback(
|
|
247
249
|
(
|
|
@@ -352,14 +354,14 @@ export const Camera = memo(
|
|
|
352
354
|
if (_nativeStop) {
|
|
353
355
|
_nativeStops = [..._nativeStops, _nativeStop];
|
|
354
356
|
}
|
|
355
|
-
nativeCamera.current
|
|
357
|
+
nativeCamera.current?.setNativeProps({
|
|
356
358
|
stop: { stops: _nativeStops },
|
|
357
359
|
});
|
|
358
360
|
}
|
|
359
361
|
} else if (config.type === 'CameraStop') {
|
|
360
362
|
const _nativeStop = buildNativeStop(config);
|
|
361
363
|
if (_nativeStop) {
|
|
362
|
-
nativeCamera.current
|
|
364
|
+
nativeCamera.current?.setNativeProps({ stop: _nativeStop });
|
|
363
365
|
}
|
|
364
366
|
}
|
|
365
367
|
};
|
|
@@ -2,19 +2,27 @@ import React, { memo, forwardRef, ReactElement } from 'react';
|
|
|
2
2
|
import { requireNativeComponent } from 'react-native';
|
|
3
3
|
|
|
4
4
|
interface Props {
|
|
5
|
-
/**
|
|
5
|
+
/** ID of the image */
|
|
6
6
|
name: string;
|
|
7
7
|
|
|
8
8
|
/** Make image an sdf optional - see [SDF icons](https://docs.mapbox.com/help/troubleshooting/using-recolorable-images-in-mapbox-maps/) */
|
|
9
9
|
sdf?: boolean;
|
|
10
10
|
|
|
11
|
-
/**
|
|
11
|
+
/** An array of two-element arrays, consisting of two numbers that represent, the from position and the to position of areas that can be stretched horizontally. */
|
|
12
12
|
stretchX?: [number, number][];
|
|
13
13
|
|
|
14
|
-
/**
|
|
14
|
+
/** An array of two-element arrays, consisting of two numbers that represent, the from position and the to position of areas that can be stretched vertically. */
|
|
15
15
|
stretchY?: [number, number][];
|
|
16
16
|
|
|
17
|
-
/**
|
|
17
|
+
/** An array of four numbers, with the first two specifying the left, top
|
|
18
|
+
* corner, and the last two specifying the right, bottom corner. If present, and if the
|
|
19
|
+
* icon uses icon-text-fit, the symbol's text will be fit inside the content box. */
|
|
20
|
+
content?: [number, number, number, number];
|
|
21
|
+
|
|
22
|
+
/** Scale factor for the image. */
|
|
23
|
+
scale?: number;
|
|
24
|
+
|
|
25
|
+
/** Single react native view rendering the image */
|
|
18
26
|
children: ReactElement;
|
|
19
27
|
}
|
|
20
28
|
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React, { forwardRef, memo, useImperativeHandle, useRef } from 'react';
|
|
2
|
+
import { requireNativeComponent } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { LightLayerStyleProps } from '../utils/MapboxStyles';
|
|
5
|
+
import { StyleValue } from '../utils/StyleValue';
|
|
6
|
+
import { type BaseProps } from '../types/BaseProps';
|
|
7
|
+
import { transformStyle } from '../utils/StyleValue';
|
|
8
|
+
import nativeRef from '../utils/nativeRef';
|
|
9
|
+
|
|
10
|
+
export const NATIVE_MODULE_NAME = 'RCTMGLLight';
|
|
11
|
+
|
|
12
|
+
type Props = BaseProps & {
|
|
13
|
+
/**
|
|
14
|
+
* Customizable style attributes
|
|
15
|
+
*/
|
|
16
|
+
style: LightLayerStyleProps;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type NativeProps = Omit<Props, 'style'> & {
|
|
20
|
+
reactStyle?: { [key: string]: StyleValue };
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
interface LightMethods {
|
|
24
|
+
setNativeProps(props: { [key: string]: unknown }): void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Light represents the light source for extruded geometries
|
|
29
|
+
*/
|
|
30
|
+
function Light(props: Props, ref: React.ForwardedRef<LightMethods>) {
|
|
31
|
+
const { style, ...propWithoutStyle } = props;
|
|
32
|
+
|
|
33
|
+
const nativeLightRef = nativeRef(useRef<typeof RCTMGLLight>(null));
|
|
34
|
+
|
|
35
|
+
useImperativeHandle(ref, () => ({
|
|
36
|
+
setNativeProps(_props: { [key: string]: unknown }) {
|
|
37
|
+
let propsToPass = _props;
|
|
38
|
+
if (_props.style) {
|
|
39
|
+
propsToPass = {
|
|
40
|
+
..._props,
|
|
41
|
+
reactStyle: transformStyle(_props.style),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
nativeLightRef.current?.setNativeProps(propsToPass);
|
|
45
|
+
},
|
|
46
|
+
}));
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<RCTMGLLight
|
|
50
|
+
ref={nativeLightRef}
|
|
51
|
+
testID="rctmglLight"
|
|
52
|
+
{...propWithoutStyle}
|
|
53
|
+
reactStyle={transformStyle(style)}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const RCTMGLLight = requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
|
|
59
|
+
|
|
60
|
+
export default memo(forwardRef(Light));
|
|
@@ -9,6 +9,7 @@ import { type Feature } from 'geojson';
|
|
|
9
9
|
|
|
10
10
|
import { toJSONString, isFunction } from '../utils';
|
|
11
11
|
import { makePoint } from '../utils/geoUtils';
|
|
12
|
+
import { type BaseProps } from '../types/BaseProps';
|
|
12
13
|
|
|
13
14
|
import NativeBridgeComponent, { type RNMBEvent } from './NativeBridgeComponent';
|
|
14
15
|
|
|
@@ -26,7 +27,7 @@ type FeaturePayload = {
|
|
|
26
27
|
feature: Feature;
|
|
27
28
|
};
|
|
28
29
|
|
|
29
|
-
type Props = {
|
|
30
|
+
type Props = BaseProps & {
|
|
30
31
|
/**
|
|
31
32
|
* A string that uniquely identifies the annotation
|
|
32
33
|
*/
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
isAndroid,
|
|
15
15
|
} from '../utils';
|
|
16
16
|
import { copyPropertiesAsDeprecated } from '../utils/deprecation';
|
|
17
|
+
import { OnPressEvent } from '../types/OnPressEvent';
|
|
17
18
|
|
|
18
19
|
import AbstractSource from './AbstractSource';
|
|
19
20
|
import NativeBridgeComponent from './NativeBridgeComponent';
|
|
@@ -22,17 +23,6 @@ const MapboxGL = NativeModules.MGLModule;
|
|
|
22
23
|
|
|
23
24
|
export const NATIVE_MODULE_NAME = 'RCTMGLShapeSource';
|
|
24
25
|
|
|
25
|
-
export type OnPressEvent = {
|
|
26
|
-
features: Array<GeoJSON.Feature>;
|
|
27
|
-
coordinates: {
|
|
28
|
-
latitude: number;
|
|
29
|
-
longitude: number;
|
|
30
|
-
};
|
|
31
|
-
point: {
|
|
32
|
-
x: number;
|
|
33
|
-
y: number;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
26
|
type OnPressEventDeprecated = OnPressEvent & {
|
|
37
27
|
nativeEvent?: OnPressEvent;
|
|
38
28
|
};
|
|
@@ -3,10 +3,11 @@ import { HostComponent, requireNativeComponent } from 'react-native';
|
|
|
3
3
|
|
|
4
4
|
import type { TerrainLayerStyleProps, Value } from '../utils/MapboxStyles';
|
|
5
5
|
import { StyleValue, transformStyle } from '../utils/StyleValue';
|
|
6
|
+
import type { BaseProps } from '../types/BaseProps';
|
|
6
7
|
|
|
7
8
|
export const NATIVE_MODULE_NAME = 'RCTMGLTerrain';
|
|
8
9
|
|
|
9
|
-
type Props = {
|
|
10
|
+
type Props = BaseProps & {
|
|
10
11
|
/**
|
|
11
12
|
* Name of a source of raster_dem type to be used for terrain elevation.
|
|
12
13
|
*/
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
NativeMethods,
|
|
4
|
+
NativeModules,
|
|
5
|
+
NativeSyntheticEvent,
|
|
6
|
+
requireNativeComponent,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
|
|
9
|
+
import { cloneReactChildrenWithProps, isFunction, isAndroid } from '../utils';
|
|
10
|
+
import { getFilter } from '../utils/filterUtils';
|
|
11
|
+
import { copyPropertiesAsDeprecated } from '../utils/deprecation';
|
|
12
|
+
import { OnPressEvent } from '../types/OnPressEvent';
|
|
13
|
+
|
|
14
|
+
import AbstractSource from './AbstractSource';
|
|
15
|
+
import NativeBridgeComponent from './NativeBridgeComponent';
|
|
16
|
+
|
|
17
|
+
const MapboxGL = NativeModules.MGLModule;
|
|
18
|
+
|
|
19
|
+
export const NATIVE_MODULE_NAME = 'RCTMGLVectorSource';
|
|
20
|
+
|
|
21
|
+
interface Props {
|
|
22
|
+
/**
|
|
23
|
+
* A string that uniquely identifies the source.
|
|
24
|
+
*/
|
|
25
|
+
id: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A URL to a TileJSON configuration file describing the source’s contents and other metadata.
|
|
29
|
+
*/
|
|
30
|
+
url?: string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* An array of tile URL templates. If multiple endpoints are specified, clients may use any combination of endpoints.
|
|
34
|
+
* Example: https://example.com/vector-tiles/{z}/{x}/{y}.pbf
|
|
35
|
+
*/
|
|
36
|
+
tileUrlTemplates?: string[];
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* An unsigned integer that specifies the minimum zoom level at which to display tiles from the source.
|
|
40
|
+
* The value should be between 0 and 22, inclusive, and less than
|
|
41
|
+
* maxZoomLevel, if specified. The default value for this option is 0.
|
|
42
|
+
*/
|
|
43
|
+
minZoomLevel?: number;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* An unsigned integer that specifies the maximum zoom level at which to display tiles from the source.
|
|
47
|
+
* The value should be between 0 and 22, inclusive, and less than
|
|
48
|
+
* minZoomLevel, if specified. The default value for this option is 22.
|
|
49
|
+
*/
|
|
50
|
+
maxZoomLevel?: number;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Influences the y direction of the tile coordinates. (tms inverts y axis)
|
|
54
|
+
*/
|
|
55
|
+
tms?: boolean;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* An HTML or literal text string defining the buttons to be displayed in an action sheet when the
|
|
59
|
+
* source is part of a map view’s style and the map view’s attribution button is pressed.
|
|
60
|
+
*/
|
|
61
|
+
attribution?: string;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Source press listener, gets called when a user presses one of the children layers only
|
|
65
|
+
* if that layer has a higher z-index than another source layers
|
|
66
|
+
*
|
|
67
|
+
* @param {Object} event
|
|
68
|
+
* @param {Object[]} event.features - the geojson features that have hit by the press (might be multiple)
|
|
69
|
+
* @param {Object} event.coordinates - the coordinates of the click
|
|
70
|
+
* @param {Object} event.point - the point of the click
|
|
71
|
+
*/
|
|
72
|
+
onPress?: (event: OnPressEvent) => void;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Overrides the default touch hitbox(44x44 pixels) for the source layers
|
|
76
|
+
*/
|
|
77
|
+
hitbox?: {
|
|
78
|
+
/**
|
|
79
|
+
* `width` of hitbox
|
|
80
|
+
*/
|
|
81
|
+
width: number;
|
|
82
|
+
/**
|
|
83
|
+
* `height` of hitbox
|
|
84
|
+
*/
|
|
85
|
+
height: number;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
children: React.ReactElement | React.ReactElement[];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
//interface NativeProps extends Omit<Props, 'children'> {}
|
|
92
|
+
type NativeProps = Props; // Omit<Props, 'children'>;
|
|
93
|
+
/**
|
|
94
|
+
* VectorSource is a map content source that supplies tiled vector data in Mapbox Vector Tile format to be shown on the map.
|
|
95
|
+
* 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.
|
|
96
|
+
*/
|
|
97
|
+
class VectorSource extends NativeBridgeComponent(
|
|
98
|
+
AbstractSource<Props, NativeProps>,
|
|
99
|
+
NATIVE_MODULE_NAME,
|
|
100
|
+
) {
|
|
101
|
+
static defaultProps = {
|
|
102
|
+
id: MapboxGL.StyleSource.DefaultSourceID,
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
constructor(props: Props) {
|
|
106
|
+
super(props);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
_setNativeRef(
|
|
110
|
+
nativeRef: (React.Component<NativeProps> & Readonly<NativeMethods>) | null,
|
|
111
|
+
) {
|
|
112
|
+
if (nativeRef) {
|
|
113
|
+
this.setNativeRef(nativeRef);
|
|
114
|
+
// this._nativeRef = nativeRef;
|
|
115
|
+
super._runPendingNativeCommands(nativeRef);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Returns all features that match the query parameters regardless of whether or not the feature is
|
|
121
|
+
* currently rendered on the map. The domain of the query includes all currently-loaded vector tiles
|
|
122
|
+
* and GeoJSON source tiles. This function does not check tiles outside of the visible viewport.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* vectorSource.features(['id1', 'id2'])
|
|
126
|
+
*
|
|
127
|
+
* @param {Array=} layerIDs - 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.
|
|
128
|
+
* @param {Array=} filter - an optional filter statement to filter the returned Features.
|
|
129
|
+
* @return {FeatureCollection}
|
|
130
|
+
*/
|
|
131
|
+
async features(layerIDs = [], filter = []) {
|
|
132
|
+
const res: { data: string } = await this._runNativeCommand(
|
|
133
|
+
'features',
|
|
134
|
+
this._nativeRef,
|
|
135
|
+
[layerIDs, getFilter(filter)],
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
if (isAndroid()) {
|
|
139
|
+
return JSON.parse(res.data);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return res.data;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
onPress(
|
|
146
|
+
event: NativeSyntheticEvent<{
|
|
147
|
+
payload: OnPressEvent;
|
|
148
|
+
}>,
|
|
149
|
+
) {
|
|
150
|
+
const {
|
|
151
|
+
nativeEvent: {
|
|
152
|
+
payload: { features, coordinates, point },
|
|
153
|
+
},
|
|
154
|
+
} = event;
|
|
155
|
+
let newEvent = {
|
|
156
|
+
features,
|
|
157
|
+
coordinates,
|
|
158
|
+
point,
|
|
159
|
+
};
|
|
160
|
+
newEvent = copyPropertiesAsDeprecated(
|
|
161
|
+
event,
|
|
162
|
+
newEvent,
|
|
163
|
+
(key) => {
|
|
164
|
+
console.warn(
|
|
165
|
+
`event.${key} is deprecated on VectorSource#onPress, please use event.features`,
|
|
166
|
+
);
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
nativeEvent: (origNativeEvent: unknown) => ({
|
|
170
|
+
...(origNativeEvent as OnPressEvent),
|
|
171
|
+
payload: features[0],
|
|
172
|
+
}),
|
|
173
|
+
},
|
|
174
|
+
);
|
|
175
|
+
const { onPress } = this.props;
|
|
176
|
+
if (onPress) {
|
|
177
|
+
onPress(newEvent);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
render() {
|
|
182
|
+
const props = {
|
|
183
|
+
id: this.props.id,
|
|
184
|
+
url: this.props.url,
|
|
185
|
+
tileUrlTemplates: this.props.tileUrlTemplates,
|
|
186
|
+
minZoomLevel: this.props.minZoomLevel,
|
|
187
|
+
maxZoomLevel: this.props.maxZoomLevel,
|
|
188
|
+
tms: this.props.tms,
|
|
189
|
+
attribution: this.props.attribution,
|
|
190
|
+
hitbox: this.props.hitbox,
|
|
191
|
+
hasPressListener: isFunction(this.props.onPress),
|
|
192
|
+
onMapboxVectorSourcePress: this.onPress.bind(this),
|
|
193
|
+
onPress: undefined,
|
|
194
|
+
onAndroidCallback: isAndroid() ? this._onAndroidCallback : undefined,
|
|
195
|
+
};
|
|
196
|
+
return (
|
|
197
|
+
<RCTMGLVectorSource ref={(r) => this._setNativeRef(r)} {...props}>
|
|
198
|
+
{cloneReactChildrenWithProps(this.props.children, {
|
|
199
|
+
sourceID: this.props.id,
|
|
200
|
+
})}
|
|
201
|
+
</RCTMGLVectorSource>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const RCTMGLVectorSource =
|
|
207
|
+
requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
|
|
208
|
+
|
|
209
|
+
export default VectorSource;
|
|
@@ -51,11 +51,16 @@ class Annotation extends React.Component {
|
|
|
51
51
|
prevProps.coordinates[0] !== this.props.coordinates[0] ||
|
|
52
52
|
prevProps.coordinates[1] !== this.props.coordinates[1];
|
|
53
53
|
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
if (
|
|
55
|
+
prevProps.animated !== this.props.animated ||
|
|
56
|
+
(hasCoordChanged && (!this.state.shape || !this.props.animated))
|
|
57
|
+
) {
|
|
58
|
+
const shape = this._getShapeFromProps(this.props);
|
|
57
59
|
|
|
58
|
-
|
|
60
|
+
this.setState({
|
|
61
|
+
shape: this.props.animated ? new AnimatedPoint(shape) : shape,
|
|
62
|
+
});
|
|
63
|
+
} else if (hasCoordChanged && this.props.animated && this.state.shape) {
|
|
59
64
|
// flush current animations
|
|
60
65
|
this.state.shape.stopAnimation();
|
|
61
66
|
|
|
@@ -66,12 +71,6 @@ class Annotation extends React.Component {
|
|
|
66
71
|
duration: this.props.animationDuration,
|
|
67
72
|
})
|
|
68
73
|
.start();
|
|
69
|
-
} else if (!this.state.shape || !this.props.animated) {
|
|
70
|
-
const shape = this._getShapeFromProps(this.props);
|
|
71
|
-
|
|
72
|
-
this.setState({
|
|
73
|
-
shape: this.props.animated ? new AnimatedPoint(shape) : shape,
|
|
74
|
-
});
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
76
|
|
|
@@ -25,7 +25,7 @@ export interface Location {
|
|
|
25
25
|
/**
|
|
26
26
|
* Coorinates sent by locationManager
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
interface Coordinates {
|
|
29
29
|
/**
|
|
30
30
|
* The heading (measured in degrees) relative to true north.
|
|
31
31
|
* Heading is used to describe the direction the device is pointing to (the value of the compass).
|
|
@@ -69,7 +69,7 @@ export interface Coordinates {
|
|
|
69
69
|
/**
|
|
70
70
|
* LocationManager is a singleton, see `locationManager`
|
|
71
71
|
*/
|
|
72
|
-
class LocationManager {
|
|
72
|
+
export class LocationManager {
|
|
73
73
|
_listeners: ((location: Location) => void)[];
|
|
74
74
|
_lastKnownLocation: Location | null;
|
|
75
75
|
_isListening: boolean;
|