Skip to content

Commit 5645726

Browse files
Pedro Beloalvinthen
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 be916aa commit 5645726

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
@@ -328,6 +328,12 @@ public void setShowsUserLocation(boolean showUserLocation) {
328328
}
329329
}
330330

331+
public void setShowsMyLocationButton(boolean showMyLocationButton) {
332+
if (hasPermissions()) {
333+
map.getUiSettings().setMyLocationButtonEnabled(showMyLocationButton);
334+
}
335+
}
336+
331337
public void setToolbarEnabled(boolean toolbarEnabled) {
332338
if (hasPermissions()) {
333339
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)