Expose pitchEnabled property (#407)

* Expose the 'pitchEnabled' property, so developer can turn off 'two-fingers to tile map' feature. iOS-only so far.

* Add `pitchEnabled` property to Android implementation

* add `pitchEnabled` to docs
This commit is contained in:
Ben Clayton
2016-08-29 14:09:14 -07:00
committed by Bobby Sudekum
parent a3e8202828
commit 3ee56f5075
6 changed files with 30 additions and 2 deletions
@@ -131,6 +131,11 @@ public class ReactNativeMapboxGLManager extends SimpleViewManager<ReactNativeMap
view.setZoomEnabled(value);
}
@ReactProp(name = "pitchEnabled")
public void setPitchEnabled(ReactNativeMapboxGLView view, boolean value) {
view.setPitchEnabled(value);
}
@ReactProp(name = "showsUserLocation")
public void setShowsUserLocation(ReactNativeMapboxGLView view, boolean value) {
view.setShowsUserLocation(value);
@@ -56,6 +56,7 @@ public class ReactNativeMapboxGLView extends RelativeLayout implements
private boolean _trackingModeUpdateScheduled = false;
private boolean _showsUserLocation;
private boolean _zoomEnabled = true;
private boolean _pitchEnabled = true;
private boolean _scrollEnabled = true;
private boolean _rotateEnabled = true;
private boolean _enableOnRegionWillChange = false;
@@ -148,6 +149,7 @@ public class ReactNativeMapboxGLView extends RelativeLayout implements
uiSettings.setZoomGesturesEnabled(_zoomEnabled);
uiSettings.setScrollGesturesEnabled(_scrollEnabled);
uiSettings.setRotateGesturesEnabled(_rotateEnabled);
uiSettings.setTiltGesturesEnabled(_pitchEnabled);
// If these settings changed between setupMapView() and onMapReady(), coerce them to their right values
// This doesn't happen in the current implementation of MapView, but let's be future proof
@@ -252,6 +254,14 @@ public class ReactNativeMapboxGLView extends RelativeLayout implements
}
}
public void setPitchEnabled(boolean value) {
if (_pitchEnabled == value) { return; }
_pitchEnabled = value;
if (_map != null) {
_map.getUiSettings().setTiltGesturesEnabled(value);
}
}
public void setStyleURL(String styleURL) {
if (styleURL.equals(_mapOptions.getStyle())) { return; }
_mapOptions.styleUrl(styleURL);