Skip to content

Commit

Permalink
take prop to hide the my location button in Android (react-native-map…
Browse files Browse the repository at this point in the history
…s#382)

this button is enabled by default when showsUserLocation is true.

useful if you want to implement that yourself in React Native, for
instance
  • Loading branch information
Pedro Belo authored and Adel Grimm committed Dec 1, 2016
1 parent 2d00b39 commit 5e02484
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ public void setShowsUserLocation(AirMapView view, boolean showUserLocation) {
view.setShowsUserLocation(showUserLocation);
}

@ReactProp(name = "showsMyLocationButton", defaultBoolean = true)
public void setShowsMyLocationButton(AirMapView view, boolean showMyLocationButton) {
view.setShowsMyLocationButton(showMyLocationButton);
}

@ReactProp(name = "toolbarEnabled", defaultBoolean = true)
public void setToolbarEnabled(AirMapView view, boolean toolbarEnabled) {
view.setToolbarEnabled(toolbarEnabled);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ public void setShowsUserLocation(boolean showUserLocation) {
}
}

public void setShowsMyLocationButton(boolean showMyLocationButton) {
if (hasPermissions()) {
map.getUiSettings().setMyLocationButtonEnabled(showMyLocationButton);
}
}

public void setToolbarEnabled(boolean toolbarEnabled) {
if (hasPermissions()) {
map.getUiSettings().setMapToolbarEnabled(toolbarEnabled);
Expand Down
8 changes: 8 additions & 0 deletions components/MapView.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ var MapView = React.createClass({
*/
showsUserLocation: PropTypes.bool,

/**
* If `false` hide the button to move map to the current user's location.
* Default value is `true`.
*
* @platform android
*/
showsMyLocationButton: PropTypes.bool,

/**
* 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.
Expand Down

0 comments on commit 5e02484

Please sign in to comment.