mirror of
https://github.com/status-im/react-native-mapbox-gl.git
synced 2026-08-31 13:01:15 +00:00
Disable onRegionChange events when not in use
This commit is contained in:
@@ -55,6 +55,8 @@ public class ReactNativeMapboxGLView extends RelativeLayout implements
|
||||
private boolean _zoomEnabled = true;
|
||||
private boolean _scrollEnabled = true;
|
||||
private boolean _rotateEnabled = true;
|
||||
private boolean _enableOnRegionWillChange = false;
|
||||
private boolean _enableOnRegionDidChange = false;
|
||||
private int _paddingTop, _paddingRight, _paddingBottom, _paddingLeft;
|
||||
|
||||
private android.os.Handler _trackingModeHandler;
|
||||
@@ -188,6 +190,14 @@ public class ReactNativeMapboxGLView extends RelativeLayout implements
|
||||
_initialCamera.target(new LatLng(lat, lon));
|
||||
}
|
||||
|
||||
public void setEnableOnRegionDidChange(boolean value) {
|
||||
_enableOnRegionDidChange = value;
|
||||
}
|
||||
|
||||
public void setEnableOnRegionWillChange(boolean value) {
|
||||
_enableOnRegionWillChange = value;
|
||||
}
|
||||
|
||||
public void setShowsUserLocation(boolean value) {
|
||||
if (_showsUserLocation == value) { return; }
|
||||
_showsUserLocation = value;
|
||||
@@ -407,11 +417,15 @@ public class ReactNativeMapboxGLView extends RelativeLayout implements
|
||||
switch (change) {
|
||||
case MapView.REGION_WILL_CHANGE:
|
||||
case MapView.REGION_WILL_CHANGE_ANIMATED:
|
||||
emitEvent("onRegionWillChange", serializeCurrentRegion()); // TODO: These should be throttled
|
||||
if (_enableOnRegionWillChange) {
|
||||
emitEvent("onRegionWillChange", serializeCurrentRegion()); // TODO: These should be throttled
|
||||
}
|
||||
break;
|
||||
case MapView.REGION_DID_CHANGE:
|
||||
case MapView.REGION_DID_CHANGE_ANIMATED:
|
||||
emitEvent("onRegionDidChange", serializeCurrentRegion());
|
||||
if (_enableOnRegionDidChange) {
|
||||
emitEvent("onRegionDidChange", serializeCurrentRegion());
|
||||
}
|
||||
break;
|
||||
case MapView.WILL_START_LOADING_MAP:
|
||||
emitEvent("onStartLoadingMap", null);
|
||||
|
||||
Reference in New Issue
Block a user