Skip to content
Open
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 |
| `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
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
5 changes: 5 additions & 0 deletions src/MapView.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
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