Skip to content

Commit b44a954

Browse files
Pedro Belochristopherdro
authored andcommitted
take prop to hide the my location button in Android (react-native-maps#382)
this button is enabled by default when showsUserLocation is true. useful if you want to implement that yourself in React Native, for instance
1 parent 0b5db60 commit b44a954

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

android/lib/src/main/java/com/airbnb/android/react/maps/AirMapManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ public void setShowsUserLocation(AirMapView view, boolean showUserLocation) {
9797
view.setShowsUserLocation(showUserLocation);
9898
}
9999

100+
@ReactProp(name = "showsMyLocationButton", defaultBoolean = true)
101+
public void setShowsMyLocationButton(AirMapView view, boolean showMyLocationButton) {
102+
view.setShowsMyLocationButton(showMyLocationButton);
103+
}
104+
100105
@ReactProp(name = "toolbarEnabled", defaultBoolean = true)
101106
public void setToolbarEnabled(AirMapView view, boolean toolbarEnabled) {
102107
view.setToolbarEnabled(toolbarEnabled);

android/lib/src/main/java/com/airbnb/android/react/maps/AirMapView.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,12 @@ public void setShowsUserLocation(boolean showUserLocation) {
321321
}
322322
}
323323

324+
public void setShowsMyLocationButton(boolean showMyLocationButton) {
325+
if (hasPermissions()) {
326+
map.getUiSettings().setMyLocationButtonEnabled(showMyLocationButton);
327+
}
328+
}
329+
324330
public void setToolbarEnabled(boolean toolbarEnabled) {
325331
if (hasPermissions()) {
326332
map.getUiSettings().setMapToolbarEnabled(toolbarEnabled);

components/MapView.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ var MapView = React.createClass({
5151
*/
5252
showsUserLocation: PropTypes.bool,
5353

54+
/**
55+
* If `false` hide the button to move map to the current user's location.
56+
* Default value is `true`.
57+
*
58+
* @platform android
59+
*/
60+
showsMyLocationButton: PropTypes.bool,
61+
5462
/**
5563
* If `true` the map will focus on the user's location. This only works if
5664
* `showsUserLocation` is true and the user has shared their location.

0 commit comments

Comments
 (0)