Skip to content

Commit 4f991b6

Browse files
Merge pull request react-native-maps#1157 from davidstoker/ios-google-maps-show-my-location
[iOS - Google Maps] Add `showsMyLocationButton` support
2 parents 2939af4 + c8c2639 commit 4f991b6

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

docs/mapview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
| `customMapStyle` | `Array` | | Adds custom styling to the map component. See [README](https://github.com/airbnb/react-native-maps#customizing-the-map-style) for more information.
1313
| `showsUserLocation` | `Boolean` | `false` | If `true` the app will ask for the user's location. **NOTE**: You need to add `NSLocationWhenInUseUsageDescription` key in Info.plist to enable geolocation, otherwise it is going to *fail silently*!
1414
| `followsUserLocation` | `Boolean` | `false` | If `true` the map will focus on the user's location. This only works if `showsUserLocation` is true and the user has shared their location. **Note**: iOS only.
15-
| `showsMyLocationButton` | `Boolean` | `true` | `Android only` If `false` hide the button to move map to the current user's location.
15+
| `showsMyLocationButton` | `Boolean` | `true` | If `false` hide the button to move map to the current user's location.
1616
| `showsPointsOfInterest` | `Boolean` | `true` | If `false` points of interest won't be displayed on the map.
1717
| `showsCompass` | `Boolean` | `true` | If `false` compass won't be displayed on the map.
1818
| `showsScale` | `Boolean` | `true` | A Boolean indicating whether the map shows scale information.

ios/AirGoogleMaps/AIRGoogleMap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
@property (nonatomic, assign) BOOL rotateEnabled;
3939
@property (nonatomic, assign) BOOL pitchEnabled;
4040
@property (nonatomic, assign) BOOL showsUserLocation;
41+
@property (nonatomic, assign) BOOL showsMyLocationButton;
4142

4243
- (BOOL)didTapMarker:(GMSMarker *)marker;
4344
- (void)didTapAtCoordinate:(CLLocationCoordinate2D)coordinate;

ios/AirGoogleMaps/AIRGoogleMap.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,15 @@ - (BOOL)showsUserLocation {
272272
return self.myLocationEnabled;
273273
}
274274

275+
- (void)setShowsMyLocationButton:(BOOL)showsMyLocationButton {
276+
self.settings.myLocationButton = showsMyLocationButton;
277+
}
278+
279+
- (BOOL)showsMyLocationButton {
280+
return self.settings.myLocationButton;
281+
}
282+
283+
275284
+ (MKCoordinateRegion) makeGMSCameraPositionFromMap:(GMSMapView *)map andGMSCameraPosition:(GMSCameraPosition *)position {
276285
// solution from here: http://stackoverflow.com/a/16587735/1102215
277286
GMSVisibleRegion visibleRegion = map.projection.visibleRegion;

ios/AirGoogleMaps/AIRGoogleMapManager.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ - (UIView *)view
5656
RCT_EXPORT_VIEW_PROPERTY(scrollEnabled, BOOL)
5757
RCT_EXPORT_VIEW_PROPERTY(pitchEnabled, BOOL)
5858
RCT_EXPORT_VIEW_PROPERTY(showsUserLocation, BOOL)
59+
RCT_EXPORT_VIEW_PROPERTY(showsMyLocationButton, BOOL)
5960
RCT_EXPORT_VIEW_PROPERTY(customMapStyleString, NSString)
6061
RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
6162
RCT_EXPORT_VIEW_PROPERTY(onLongPress, RCTBubblingEventBlock)

0 commit comments

Comments
 (0)