From 6953298380507ed45e637e2399a22635cec7b28c Mon Sep 17 00:00:00 2001 From: g4rb4g3 Date: Tue, 14 Nov 2023 11:45:31 +0100 Subject: [PATCH 1/3] [android] add heading to custom location provider --- .../RNMBXCustomLocationProviderManager.kt | 9 +++++ ...CustomLocationProviderManagerDelegate.java | 3 ++ ...ustomLocationProviderManagerInterface.java | 1 + docs/CustomLocationProvider.md | 39 +++++++++++++++++++ docs/NativeUserLocation.md | 2 +- docs/docs.json | 11 +++++- src/components/CustomLocationProvider.tsx | 8 ++++ src/components/NativeUserLocation.tsx | 4 +- ...BXCustomLocationProviderNativeComponent.ts | 1 + 9 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 docs/CustomLocationProvider.md diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/location/RNMBXCustomLocationProviderManager.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/location/RNMBXCustomLocationProviderManager.kt index 55c55a817..5ff144b10 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/location/RNMBXCustomLocationProviderManager.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/location/RNMBXCustomLocationProviderManager.kt @@ -32,6 +32,15 @@ class RNMBXCustomLocationProviderManager : ViewGroupManager { void setCoordinate(T view, Dynamic value); + void setHeading(T view, Dynamic value); } diff --git a/docs/CustomLocationProvider.md b/docs/CustomLocationProvider.md new file mode 100644 index 000000000..27ee1e321 --- /dev/null +++ b/docs/CustomLocationProvider.md @@ -0,0 +1,39 @@ + + + + +```tsx +import { CustomLocationProvider } from '@rnmapbox/maps'; + +CustomLocationProvider + +``` + + +## props + + +### coordinate + +```tsx +Position +``` +longitude and latitude to use for the custom location provider that gets applied to the NativeUserLocation + + + +### heading + +```tsx +number +``` +heading/bearing to use for custom location provider that gets applied to the NativeUserLocation + + + + + + + + + diff --git a/docs/NativeUserLocation.md b/docs/NativeUserLocation.md index e0b157d48..32be74669 100644 --- a/docs/NativeUserLocation.md +++ b/docs/NativeUserLocation.md @@ -85,7 +85,7 @@ The name of image to use as the middle layer for the location indicator. Images ```tsx string ``` -The name of image asset to use as the background0 for the location indicator. Images component should define this image. +The name of image to use as the background for the location indicator. Images component should define this image. diff --git a/docs/docs.json b/docs/docs.json index 6c2040a9d..c41a03077 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -1333,7 +1333,14 @@ "required": false, "type": "Position", "default": "none", - "description": "FIX ME NO DESCRIPTION" + "description": "longitude and latitude to use for the custom location provider that gets applied to the NativeUserLocation" + }, + { + "name": "heading", + "required": false, + "type": "number", + "default": "none", + "description": "heading/bearing to use for custom location provider that gets applied to the NativeUserLocation" } ], "fileNameWithExt": "CustomLocationProvider.tsx", @@ -4169,7 +4176,7 @@ "required": false, "type": "string", "default": "none", - "description": "The name of image asset to use as the background0 for the location indicator. Images component should define this image." + "description": "The name of image to use as the background for the location indicator. Images component should define this image." }, { "name": "scale", diff --git a/src/components/CustomLocationProvider.tsx b/src/components/CustomLocationProvider.tsx index ca904d43f..50c71e63f 100644 --- a/src/components/CustomLocationProvider.tsx +++ b/src/components/CustomLocationProvider.tsx @@ -4,7 +4,15 @@ import RNMBXCustomLocationProvider from '../specs/RNMBXCustomLocationProviderNat import { Position } from '../types/Position'; export type Props = { + /** + * longitude and latitude to use for the custom location provider that gets applied to the NativeUserLocation + */ coordinate?: Position; + + /** + * heading/bearing to use for custom location provider that gets applied to the NativeUserLocation + */ + heading?: number; }; const CustomLocationProvider = memo((props: Props) => { diff --git a/src/components/NativeUserLocation.tsx b/src/components/NativeUserLocation.tsx index 3cf2b6b54..bc4c50368 100644 --- a/src/components/NativeUserLocation.tsx +++ b/src/components/NativeUserLocation.tsx @@ -52,7 +52,7 @@ export type Props = { bearingImage?: string; /** - * The name of image asset to use as the background0 for the location indicator. Images component should define this image. + * The name of image to use as the background for the location indicator. Images component should define this image. */ shadowImage?: string; @@ -81,7 +81,7 @@ const NativeUserLocation = memo((props: Props) => { let baseProps: NativeProps = { ...defaultProps }; if (iosShowsUserHeadingIndicator) { console.warn( - 'NativeUserLocation: iosShowsUserHeadingIndicator is deprecated, use puckBearingEnabled={true} puckBrearing="heading" instead', + 'NativeUserLocation: iosShowsUserHeadingIndicator is deprecated, use puckBearingEnabled={true} puckBearing="heading" instead', ); baseProps = { ...baseProps, diff --git a/src/specs/RNMBXCustomLocationProviderNativeComponent.ts b/src/specs/RNMBXCustomLocationProviderNativeComponent.ts index 0dd5065b0..e126ea618 100644 --- a/src/specs/RNMBXCustomLocationProviderNativeComponent.ts +++ b/src/specs/RNMBXCustomLocationProviderNativeComponent.ts @@ -10,6 +10,7 @@ type OptionalProp = UnsafeMixed; export interface NativeProps extends ViewProps { coordinate?: OptionalProp; + heading?: OptionalProp; } export default codegenNativeComponent( From bf64c450bc5595972a052232a10743930198f447 Mon Sep 17 00:00:00 2001 From: g4rb4g3 Date: Tue, 14 Nov 2023 13:09:05 +0100 Subject: [PATCH 2/3] [ios] add heading to custom location provider --- ios/RNMBX/RNMBXCustomLocationProvider.swift | 7 ++++++- ios/RNMBX/RNMBXCustomLocationProviderViewManager.m | 1 + src/specs/RNMBXCustomLocationProviderNativeComponent.ts | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ios/RNMBX/RNMBXCustomLocationProvider.swift b/ios/RNMBX/RNMBXCustomLocationProvider.swift index cd2937341..8706ded4f 100644 --- a/ios/RNMBX/RNMBXCustomLocationProvider.swift +++ b/ios/RNMBX/RNMBXCustomLocationProvider.swift @@ -22,6 +22,11 @@ public class RNMBXCustomLocationProvider: UIView, RNMBXMapComponent { public var coordinate: [Double] = [] { didSet { changed(.coordinate) } } + + @objc + public var heading: NSNumber = 0.0 { + didSet { changed(.heading) } + } func changed(_ property: Property) { changes.add(name: property.rawValue, update: property.apply) @@ -50,7 +55,7 @@ public class RNMBXCustomLocationProvider: UIView, RNMBXMapComponent { } private func applyHeading() { - // updateHeading() + updateHeading(heading: heading.doubleValue) } func removeFromMap(_ map: RNMBXMapView, reason: RemovalReason) -> Bool { diff --git a/ios/RNMBX/RNMBXCustomLocationProviderViewManager.m b/ios/RNMBX/RNMBXCustomLocationProviderViewManager.m index 27b9bd1d4..87ceaa89f 100644 --- a/ios/RNMBX/RNMBXCustomLocationProviderViewManager.m +++ b/ios/RNMBX/RNMBXCustomLocationProviderViewManager.m @@ -5,5 +5,6 @@ @interface RCT_EXTERN_REMAP_MODULE(RNMBXCustomLocationProvider, RNMBXCustomLocat // circle layer props RCT_EXPORT_VIEW_PROPERTY(coordinate, NSArray) +RCT_EXPORT_VIEW_PROPERTY(heading, NSNumber) @end diff --git a/src/specs/RNMBXCustomLocationProviderNativeComponent.ts b/src/specs/RNMBXCustomLocationProviderNativeComponent.ts index e126ea618..719ed392b 100644 --- a/src/specs/RNMBXCustomLocationProviderNativeComponent.ts +++ b/src/specs/RNMBXCustomLocationProviderNativeComponent.ts @@ -1,5 +1,6 @@ import type { HostComponent, ViewProps } from 'react-native'; import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; +import { Double } from 'react-native/Libraries/Types/CodegenTypes'; import type { Position } from '../types/Position'; @@ -10,7 +11,7 @@ type OptionalProp = UnsafeMixed; export interface NativeProps extends ViewProps { coordinate?: OptionalProp; - heading?: OptionalProp; + heading?: OptionalProp; } export default codegenNativeComponent( From 8f749d0f06e94e01f1b55c43b88f22a2fb1a9620 Mon Sep 17 00:00:00 2001 From: g4rb4g3 Date: Tue, 14 Nov 2023 14:08:01 +0100 Subject: [PATCH 3/3] export CameraStop --- src/Mapbox.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Mapbox.ts b/src/Mapbox.ts index dd87ee1e8..6ed004487 100644 --- a/src/Mapbox.ts +++ b/src/Mapbox.ts @@ -5,6 +5,7 @@ export { type CameraPadding, type CameraAnimationMode, type CameraBounds, + type CameraStop, } from './components/Camera'; export { Atmosphere } from './components/Atmosphere'; export { default as MapView, type MapState } from './components/MapView';