Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions android/src/main/java/com/luggmaps/LuggMapView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions android/src/main/java/com/luggmaps/LuggMapViewManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1197,6 +1203,7 @@ class GoogleMapProvider(private val context: Context) :
isScrollGesturesEnabled = scrollEnabled
isRotateGesturesEnabled = rotateEnabled
isTiltGesturesEnabled = pitchEnabled
isCompassEnabled = compassEnabled
isMyLocationButtonEnabled = userLocationButtonEnabled
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions docs/MAPVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 (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) |
Expand Down
10 changes: 5 additions & 5 deletions example/bare/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -2427,7 +2427,7 @@ SPEC CHECKSUMS:
FBLazyVector: 24e62c765683b8d89006a88a2c8f5cf019f0074d
GoogleMaps: 0608099d4870cac8754bdba9b6953db543432438
hermes-engine: a43fcac5345a0a468667778019547c5fd282c6e2
LuggMaps: 3b5eb2799949c9fa7fb821747a394cb66170ca64
LuggMaps: b69f00e83f91bd2e00fb32341dff2d2cc57e794a
RCTDeprecation: a4c521821fab57cbb125b36effe84d897d0dfa12
RCTRequired: 9f3a7e5645d4bc3f551593de7550bb66ab6e42bc
RCTSwiftUI: 239ed2eb9e73de5a6f518810630f0c95e01c8702
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions example/shared/src/screens/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
7 changes: 7 additions & 0 deletions ios/LuggMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ @implementation LuggMapView {
BOOL _scrollEnabled;
BOOL _rotateEnabled;
BOOL _pitchEnabled;
BOOL _compassEnabled;
BOOL _userLocationEnabled;
LuggMapViewMapType _mapType;
LuggMapViewTheme _theme;
Expand Down Expand Up @@ -68,6 +69,7 @@ - (instancetype)initWithFrame:(CGRect)frame {
_scrollEnabled = YES;
_rotateEnabled = YES;
_pitchEnabled = YES;
_compassEnabled = YES;
_userLocationEnabled = NO;
_poiEnabled = NO;
_poiFilterMode = LuggMapViewPoiFilterMode::Including;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand Down
4 changes: 4 additions & 0 deletions ios/core/AppleMapProvider.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions ios/core/GoogleMapProvider.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions ios/core/MapProviderDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/MapView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class MapView
scrollEnabled: true,
rotateEnabled: true,
pitchEnabled: true,
compassEnabled: true,
poiEnabled: true,
theme: 'system',
};
Expand Down Expand Up @@ -92,6 +93,7 @@ export class MapView
scrollEnabled,
rotateEnabled,
pitchEnabled,
compassEnabled,
edgeInsets,
userLocationEnabled,
userLocationButtonEnabled,
Expand Down Expand Up @@ -123,6 +125,7 @@ export class MapView
scrollEnabled={scrollEnabled}
rotateEnabled={rotateEnabled}
pitchEnabled={pitchEnabled}
compassEnabled={compassEnabled}
edgeInsets={edgeInsets}
userLocationEnabled={userLocationEnabled}
userLocationButtonEnabled={userLocationButtonEnabled}
Expand Down
6 changes: 6 additions & 0 deletions src/MapView.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ export interface MapViewProps extends ViewProps {
* @default true
*/
pitchEnabled?: boolean;
/**
* Show compass on the map.
* On web (Google Maps) this toggles the rotate/compass control.
* @default true
*/
compassEnabled?: boolean;
/**
* Map content edge insets
*/
Expand Down
2 changes: 2 additions & 0 deletions src/MapView.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export const MapView = memo(
zoomEnabled = true,
scrollEnabled = true,
pitchEnabled = true,
compassEnabled = true,
edgeInsets,
userLocationEnabled,
theme = 'system',
Expand Down Expand Up @@ -488,6 +489,7 @@ export const MapView = memo(
gestureHandling={gestureHandling}
colorScheme={colorScheme}
disableDefaultUI
rotateControl={compassEnabled}
isFractionalZoomEnabled
tilt={pitchEnabled === false ? 0 : undefined}
onClick={handleClick}
Expand Down
1 change: 1 addition & 0 deletions src/fabric/LuggMapViewNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export interface NativeProps extends ViewProps {
scrollEnabled?: WithDefault<boolean, true>;
rotateEnabled?: WithDefault<boolean, true>;
pitchEnabled?: WithDefault<boolean, true>;
compassEnabled?: WithDefault<boolean, true>;
edgeInsets?: EdgeInsets;
userLocationEnabled?: boolean;
userLocationButtonEnabled?: boolean;
Expand Down
Loading