From 4dbe1bba9b627774125e69189bb459fe1e828f98 Mon Sep 17 00:00:00 2001 From: Kirill Kaverin <89150690390@yandex.ru> Date: Fri, 15 May 2026 19:55:24 +0300 Subject: [PATCH 1/2] feat(mapview): add compassEnabled prop for iOS and Android --- android/src/main/java/com/luggmaps/LuggMapView.kt | 8 ++++++++ android/src/main/java/com/luggmaps/LuggMapViewManager.kt | 5 +++++ .../src/main/java/com/luggmaps/core/GoogleMapProvider.kt | 7 +++++++ .../main/java/com/luggmaps/core/MapProviderDelegate.kt | 1 + docs/MAPVIEW.md | 1 + example/shared/src/screens/HomeScreen.tsx | 1 + ios/LuggMapView.mm | 7 +++++++ ios/core/AppleMapProvider.mm | 4 ++++ ios/core/GoogleMapProvider.mm | 4 ++++ ios/core/MapProviderDelegate.h | 1 + src/MapView.tsx | 3 +++ src/MapView.types.ts | 5 +++++ src/fabric/LuggMapViewNativeComponent.ts | 1 + 13 files changed, 48 insertions(+) diff --git a/android/src/main/java/com/luggmaps/LuggMapView.kt b/android/src/main/java/com/luggmaps/LuggMapView.kt index a05b638..b60b7b4 100644 --- a/android/src/main/java/com/luggmaps/LuggMapView.kt +++ b/android/src/main/java/com/luggmaps/LuggMapView.kt @@ -64,6 +64,7 @@ class LuggMapView(private val reactContext: ThemedReactContext) : private var scrollEnabled: Boolean = true private var rotateEnabled: Boolean = true private var pitchEnabled: Boolean = true + private var compassEnabled: Boolean = true private var userLocationEnabled: Boolean = false private var userLocationButtonEnabled: Boolean = false private var poiEnabled: Boolean = true @@ -186,6 +187,7 @@ class LuggMapView(private val reactContext: ThemedReactContext) : provider?.setScrollEnabled(scrollEnabled) provider?.setRotateEnabled(rotateEnabled) provider?.setPitchEnabled(pitchEnabled) + provider?.setCompassEnabled(compassEnabled) provider?.setUserLocationEnabled(userLocationEnabled) provider?.setUserLocationButtonEnabled(userLocationButtonEnabled) provider?.setMapType(mapType) @@ -243,6 +245,12 @@ class LuggMapView(private val reactContext: ThemedReactContext) : provider?.setPitchEnabled(enabled) } + fun setCompassEnabled(enabled: Boolean) { + if (compassEnabled == enabled) return + compassEnabled = enabled + provider?.setCompassEnabled(enabled) + } + fun setUserLocationEnabled(enabled: Boolean) { if (userLocationEnabled == enabled) return userLocationEnabled = enabled diff --git a/android/src/main/java/com/luggmaps/LuggMapViewManager.kt b/android/src/main/java/com/luggmaps/LuggMapViewManager.kt index f0e41c3..eadd0eb 100644 --- a/android/src/main/java/com/luggmaps/LuggMapViewManager.kt +++ b/android/src/main/java/com/luggmaps/LuggMapViewManager.kt @@ -132,6 +132,11 @@ class LuggMapViewManager : view.setPitchEnabled(value) } + @ReactProp(name = "compassEnabled", defaultBoolean = true) + override fun setCompassEnabled(view: LuggMapView, value: Boolean) { + view.setCompassEnabled(value) + } + @ReactProp(name = "userLocationEnabled", defaultBoolean = false) override fun setUserLocationEnabled(view: LuggMapView, value: Boolean) { view.setUserLocationEnabled(value) diff --git a/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt b/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt index 0283d3e..7088cc5 100644 --- a/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt +++ b/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt @@ -108,6 +108,7 @@ class GoogleMapProvider(private val context: Context) : private var scrollEnabled: Boolean = true private var rotateEnabled: Boolean = true private var pitchEnabled: Boolean = true + private var compassEnabled: Boolean = true private var userLocationEnabled: Boolean = false private var userLocationButtonEnabled: Boolean = false @@ -458,6 +459,11 @@ class GoogleMapProvider(private val context: Context) : googleMap?.uiSettings?.isTiltGesturesEnabled = enabled } + override fun setCompassEnabled(enabled: Boolean) { + compassEnabled = enabled + googleMap?.uiSettings?.isCompassEnabled = enabled + } + @SuppressLint("MissingPermission") override fun setUserLocationEnabled(enabled: Boolean) { userLocationEnabled = enabled @@ -1197,6 +1203,7 @@ class GoogleMapProvider(private val context: Context) : isScrollGesturesEnabled = scrollEnabled isRotateGesturesEnabled = rotateEnabled isTiltGesturesEnabled = pitchEnabled + isCompassEnabled = compassEnabled isMyLocationButtonEnabled = userLocationButtonEnabled } } diff --git a/android/src/main/java/com/luggmaps/core/MapProviderDelegate.kt b/android/src/main/java/com/luggmaps/core/MapProviderDelegate.kt index 73537c8..7c0a132 100644 --- a/android/src/main/java/com/luggmaps/core/MapProviderDelegate.kt +++ b/android/src/main/java/com/luggmaps/core/MapProviderDelegate.kt @@ -30,6 +30,7 @@ interface MapProvider { fun setScrollEnabled(enabled: Boolean) fun setRotateEnabled(enabled: Boolean) fun setPitchEnabled(enabled: Boolean) + fun setCompassEnabled(enabled: Boolean) fun setUserLocationEnabled(enabled: Boolean) fun setUserLocationButtonEnabled(enabled: Boolean) fun setMapType(value: String) diff --git a/docs/MAPVIEW.md b/docs/MAPVIEW.md index da65e1a..1d660b9 100644 --- a/docs/MAPVIEW.md +++ b/docs/MAPVIEW.md @@ -32,6 +32,7 @@ import { MapView } from '@lugg/maps'; | `scrollEnabled` | `boolean` | `true` | Enable scroll/pan gestures | | `rotateEnabled` | `boolean` | `true` | Enable rotation gestures | | `pitchEnabled` | `boolean` | `true` | Enable pitch/tilt gestures | +| `compassEnabled` | `boolean` | `true` | Show compass on the map | | `edgeInsets` | `EdgeInsets` | - | Map content edge insets | | `userLocationEnabled` | `boolean` | `false` | Show current user location on the map | | `userLocationButtonEnabled` | `boolean` | `false` | Show native my-location button (Android only) | diff --git a/example/shared/src/screens/HomeScreen.tsx b/example/shared/src/screens/HomeScreen.tsx index d9138ed..c2012bb 100644 --- a/example/shared/src/screens/HomeScreen.tsx +++ b/example/shared/src/screens/HomeScreen.tsx @@ -242,6 +242,7 @@ const HomeContent = ({ onMarkerPress: onMarkerPressProp }: HomeProps) => { geojson={geojson} animatedPosition={controlSheetRef.current?.animatedPosition} userLocationEnabled={locationPermission} + compassEnabled={false} onReady={handleMapReady} onPress={handlePress} onLongPress={handleLongPress} diff --git a/ios/LuggMapView.mm b/ios/LuggMapView.mm index b378b8c..bf3db75 100644 --- a/ios/LuggMapView.mm +++ b/ios/LuggMapView.mm @@ -39,6 +39,7 @@ @implementation LuggMapView { BOOL _scrollEnabled; BOOL _rotateEnabled; BOOL _pitchEnabled; + BOOL _compassEnabled; BOOL _userLocationEnabled; LuggMapViewMapType _mapType; LuggMapViewTheme _theme; @@ -68,6 +69,7 @@ - (instancetype)initWithFrame:(CGRect)frame { _scrollEnabled = YES; _rotateEnabled = YES; _pitchEnabled = YES; + _compassEnabled = YES; _userLocationEnabled = NO; _poiEnabled = NO; _poiFilterMode = LuggMapViewPoiFilterMode::Including; @@ -281,6 +283,7 @@ - (void)applyProps { [_provider setScrollEnabled:_scrollEnabled]; [_provider setRotateEnabled:_rotateEnabled]; [_provider setPitchEnabled:_pitchEnabled]; + [_provider setCompassEnabled:_compassEnabled]; [_provider setUserLocationEnabled:_userLocationEnabled]; [_provider setMapType:_mapType]; [_provider setTheme:_theme]; @@ -323,6 +326,10 @@ - (void)updateProps:(Props::Shared const &)props _pitchEnabled = newViewProps.pitchEnabled; [_provider setPitchEnabled:_pitchEnabled]; } + if (newViewProps.compassEnabled != prevViewProps.compassEnabled) { + _compassEnabled = newViewProps.compassEnabled; + [_provider setCompassEnabled:_compassEnabled]; + } if (newViewProps.userLocationEnabled != prevViewProps.userLocationEnabled) { _userLocationEnabled = newViewProps.userLocationEnabled; [_provider setUserLocationEnabled:_userLocationEnabled]; diff --git a/ios/core/AppleMapProvider.mm b/ios/core/AppleMapProvider.mm index 73cb43c..a2a5781 100644 --- a/ios/core/AppleMapProvider.mm +++ b/ios/core/AppleMapProvider.mm @@ -245,6 +245,10 @@ - (void)setPitchEnabled:(BOOL)enabled { _mapView.pitchEnabled = enabled; } +- (void)setCompassEnabled:(BOOL)enabled { + _mapView.showsCompass = enabled; +} + - (void)setUserLocationEnabled:(BOOL)enabled { _mapView.showsUserLocation = enabled; } diff --git a/ios/core/GoogleMapProvider.mm b/ios/core/GoogleMapProvider.mm index 273272d..595e8ba 100644 --- a/ios/core/GoogleMapProvider.mm +++ b/ios/core/GoogleMapProvider.mm @@ -166,6 +166,10 @@ - (void)setPitchEnabled:(BOOL)enabled { _mapView.settings.tiltGestures = enabled; } +- (void)setCompassEnabled:(BOOL)enabled { + _mapView.settings.compassButton = enabled; +} + - (void)setUserLocationEnabled:(BOOL)enabled { _mapView.myLocationEnabled = enabled; } diff --git a/ios/core/MapProviderDelegate.h b/ios/core/MapProviderDelegate.h index f7e135a..87193ab 100644 --- a/ios/core/MapProviderDelegate.h +++ b/ios/core/MapProviderDelegate.h @@ -48,6 +48,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)setScrollEnabled:(BOOL)enabled; - (void)setRotateEnabled:(BOOL)enabled; - (void)setPitchEnabled:(BOOL)enabled; +- (void)setCompassEnabled:(BOOL)enabled; - (void)setUserLocationEnabled:(BOOL)enabled; - (void)setMapType:(facebook::react::LuggMapViewMapType)mapType; - (void)setTheme:(facebook::react::LuggMapViewTheme)theme; diff --git a/src/MapView.tsx b/src/MapView.tsx index 481bd83..69cb7e7 100644 --- a/src/MapView.tsx +++ b/src/MapView.tsx @@ -25,6 +25,7 @@ export class MapView scrollEnabled: true, rotateEnabled: true, pitchEnabled: true, + compassEnabled: true, poiEnabled: true, theme: 'system', }; @@ -92,6 +93,7 @@ export class MapView scrollEnabled, rotateEnabled, pitchEnabled, + compassEnabled, edgeInsets, userLocationEnabled, userLocationButtonEnabled, @@ -123,6 +125,7 @@ export class MapView scrollEnabled={scrollEnabled} rotateEnabled={rotateEnabled} pitchEnabled={pitchEnabled} + compassEnabled={compassEnabled} edgeInsets={edgeInsets} userLocationEnabled={userLocationEnabled} userLocationButtonEnabled={userLocationButtonEnabled} diff --git a/src/MapView.types.ts b/src/MapView.types.ts index 469e1df..b5e2ea5 100644 --- a/src/MapView.types.ts +++ b/src/MapView.types.ts @@ -204,6 +204,11 @@ export interface MapViewProps extends ViewProps { * @default true */ pitchEnabled?: boolean; + /** + * Show compass on the map. + * @default true + */ + compassEnabled?: boolean; /** * Map content edge insets */ diff --git a/src/fabric/LuggMapViewNativeComponent.ts b/src/fabric/LuggMapViewNativeComponent.ts index 74c1ecf..d747825 100644 --- a/src/fabric/LuggMapViewNativeComponent.ts +++ b/src/fabric/LuggMapViewNativeComponent.ts @@ -75,6 +75,7 @@ export interface NativeProps extends ViewProps { scrollEnabled?: WithDefault; rotateEnabled?: WithDefault; pitchEnabled?: WithDefault; + compassEnabled?: WithDefault; edgeInsets?: EdgeInsets; userLocationEnabled?: boolean; userLocationButtonEnabled?: boolean; From d62f96f81e3759d6fba0d4f0cccfc15cf1d69b7d Mon Sep 17 00:00:00 2001 From: Jovanni Lo Date: Thu, 28 May 2026 04:16:01 +0800 Subject: [PATCH 2/2] feat(mapview): support compassEnabled on web --- docs/MAPVIEW.md | 2 +- example/bare/ios/Podfile.lock | 10 +++++----- src/MapView.types.ts | 1 + src/MapView.web.tsx | 2 ++ 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/MAPVIEW.md b/docs/MAPVIEW.md index 1d660b9..097dab9 100644 --- a/docs/MAPVIEW.md +++ b/docs/MAPVIEW.md @@ -32,7 +32,7 @@ import { MapView } from '@lugg/maps'; | `scrollEnabled` | `boolean` | `true` | Enable scroll/pan gestures | | `rotateEnabled` | `boolean` | `true` | Enable rotation gestures | | `pitchEnabled` | `boolean` | `true` | Enable pitch/tilt gestures | -| `compassEnabled` | `boolean` | `true` | Show compass on the map | +| `compassEnabled` | `boolean` | `true` | Show compass on the map (rotate control on web) | | `edgeInsets` | `EdgeInsets` | - | Map content edge insets | | `userLocationEnabled` | `boolean` | `false` | Show current user location on the map | | `userLocationButtonEnabled` | `boolean` | `false` | Show native my-location button (Android only) | diff --git a/example/bare/ios/Podfile.lock b/example/bare/ios/Podfile.lock index 2c65462..2f0387a 100644 --- a/example/bare/ios/Podfile.lock +++ b/example/bare/ios/Podfile.lock @@ -6,7 +6,7 @@ PODS: - hermes-engine (250829098.0.10): - hermes-engine/Pre-built (= 250829098.0.10) - hermes-engine/Pre-built (250829098.0.10) - - LuggMaps (1.0.0-beta.13): + - LuggMaps (1.0.0-beta.14): - GoogleMaps - hermes-engine - RCTRequired @@ -2072,7 +2072,7 @@ PODS: - ReactCommon/turbomodule/core - ReactNativeDependencies - Yoga - - RNTrueSheet (3.9.0-beta.1): + - RNTrueSheet (3.11.0-beta.10): - hermes-engine - RCTRequired - RCTTypeSafety @@ -2427,7 +2427,7 @@ SPEC CHECKSUMS: FBLazyVector: 24e62c765683b8d89006a88a2c8f5cf019f0074d GoogleMaps: 0608099d4870cac8754bdba9b6953db543432438 hermes-engine: a43fcac5345a0a468667778019547c5fd282c6e2 - LuggMaps: 3b5eb2799949c9fa7fb821747a394cb66170ca64 + LuggMaps: b69f00e83f91bd2e00fb32341dff2d2cc57e794a RCTDeprecation: a4c521821fab57cbb125b36effe84d897d0dfa12 RCTRequired: 9f3a7e5645d4bc3f551593de7550bb66ab6e42bc RCTSwiftUI: 239ed2eb9e73de5a6f518810630f0c95e01c8702 @@ -2504,10 +2504,10 @@ SPEC CHECKSUMS: RNReanimated: f735b1747a7a93bda7ca102c6d37a3cf54b6d5e8 RNScreens: 991cc417cd396602a6cf59a42139e5a9d91462a9 RNSVG: 04044c3abcf177fd674a1a3d13097efa1adebcbe - RNTrueSheet: 6c809ea25633bc602542a06ff60e9cf71464a10c + RNTrueSheet: 5eae7c5e0ecfb056c2c6394d5429d3061a5180e8 RNWorklets: 4931990f73bc8f347586918b2e13f11dfadf3b75 Yoga: 77dfa8673de2874e1855002ae59c68b8be9b007b PODFILE CHECKSUM: a8c918957730cfd546eb917e7563885b57095460 -COCOAPODS: 1.16.2 +COCOAPODS: 1.15.2 diff --git a/src/MapView.types.ts b/src/MapView.types.ts index b5e2ea5..41986ad 100644 --- a/src/MapView.types.ts +++ b/src/MapView.types.ts @@ -206,6 +206,7 @@ export interface MapViewProps extends ViewProps { pitchEnabled?: boolean; /** * Show compass on the map. + * On web (Google Maps) this toggles the rotate/compass control. * @default true */ compassEnabled?: boolean; diff --git a/src/MapView.web.tsx b/src/MapView.web.tsx index 2182586..b0fe5d8 100644 --- a/src/MapView.web.tsx +++ b/src/MapView.web.tsx @@ -110,6 +110,7 @@ export const MapView = memo( zoomEnabled = true, scrollEnabled = true, pitchEnabled = true, + compassEnabled = true, edgeInsets, userLocationEnabled, theme = 'system', @@ -488,6 +489,7 @@ export const MapView = memo( gestureHandling={gestureHandling} colorScheme={colorScheme} disableDefaultUI + rotateControl={compassEnabled} isFractionalZoomEnabled tilt={pitchEnabled === false ? 0 : undefined} onClick={handleClick}