ANDROID: implementation of deselectAnnotation() and annotationsPopUpDisabled

This commit is contained in:
Hanane
2016-09-21 00:41:03 +03:00
committed by Marius Petcu
parent d68b32541f
commit 577ae45090
2 changed files with 29 additions and 6 deletions
@@ -131,6 +131,11 @@ public class ReactNativeMapboxGLManager extends SimpleViewManager<ReactNativeMap
view.setZoomEnabled(value);
}
@ReactProp(name = "annotationsPopUpEnabled")
public void setAnnotationsPopUpEnabled(ReactNativeMapboxGLView view, boolean value) {
view.setAnnotationsPopUpEnabled(value);
}
@ReactProp(name = "showsUserLocation")
public void setShowsUserLocation(ReactNativeMapboxGLView view, boolean value) {
view.setShowsUserLocation(value);
@@ -177,6 +182,7 @@ public class ReactNativeMapboxGLManager extends SimpleViewManager<ReactNativeMap
public static final int COMMAND_SET_VISIBLE_COORDINATE_BOUNDS = 6;
public static final int COMMAND_SELECT_ANNOTATION = 7;
public static final int COMMAND_SPLICE_ANNOTATIONS = 8;
public static final int COMMAND_DESELECT_ANNOTATION = 9;
@Override
public
@@ -191,6 +197,7 @@ public class ReactNativeMapboxGLManager extends SimpleViewManager<ReactNativeMap
.put("setVisibleCoordinateBounds", COMMAND_SET_VISIBLE_COORDINATE_BOUNDS)
.put("selectAnnotation", COMMAND_SELECT_ANNOTATION)
.put("spliceAnnotations", COMMAND_SPLICE_ANNOTATIONS)
.put("deselectAnnotation", COMMAND_DESELECT_ANNOTATION)
.build();
}
@@ -235,6 +242,9 @@ public class ReactNativeMapboxGLManager extends SimpleViewManager<ReactNativeMap
case COMMAND_SPLICE_ANNOTATIONS:
spliceAnnotations(view, args.getBoolean(0), args.getArray(1), args.getArray(2));
break;
case COMMAND_DESELECT_ANNOTATION:
deselectAnnotation(view);
break;
default:
throw new JSApplicationIllegalArgumentException("Invalid commandId " + commandId + " sent to " + getClass().getSimpleName());
}
@@ -371,4 +381,8 @@ public class ReactNativeMapboxGLManager extends SimpleViewManager<ReactNativeMap
public void selectAnnotation(ReactNativeMapboxGLView view, String annotationId, boolean animated) {
view.selectAnnotation(annotationId, animated);
}
public void deselectAnnotation(ReactNativeMapboxGLView view) {
view.deselectAnnotation();
}
}
@@ -56,12 +56,12 @@ public class ReactNativeMapboxGLView extends RelativeLayout implements
private boolean _trackingModeUpdateScheduled = false;
private boolean _showsUserLocation;
private boolean _zoomEnabled = true;
private boolean _annotationsPopUpEnabled = true;
private boolean _scrollEnabled = true;
private boolean _rotateEnabled = true;
private boolean _enableOnRegionWillChange = false;
private boolean _enableOnRegionDidChange = false;
private int _paddingTop, _paddingRight, _paddingBottom, _paddingLeft;
private boolean _recentlyChanged = false;
private boolean _willChangeThrottled = false;
private boolean _didChangeThrottled = false;
@@ -252,6 +252,10 @@ public class ReactNativeMapboxGLView extends RelativeLayout implements
}
}
public void setAnnotationsPopUpEnabled(boolean value) {
_annotationsPopUpEnabled = value;
}
public void setStyleURL(String styleURL) {
if (styleURL.equals(_mapOptions.getStyle())) { return; }
_mapOptions.styleUrl(styleURL);
@@ -261,19 +265,19 @@ public class ReactNativeMapboxGLView extends RelativeLayout implements
public void setDebugActive(boolean value) {
if (_mapOptions.getDebugActive() == value) { return; }
_mapOptions.debugActive(value);
if (_map != null) { _map.setDebugActive(value); };
if (_map != null) { _map.setDebugActive(value); }
}
public void setLocationTracking(int value) {
if (_locationTrackingMode == value) { return; }
_locationTrackingMode = value;
if (_map != null) { _map.getTrackingSettings().setMyLocationTrackingMode(value); };
if (_map != null) { _map.getTrackingSettings().setMyLocationTrackingMode(value); }
}
public void setBearingTracking(int value) {
if (_bearingTrackingMode == value) { return; }
_bearingTrackingMode = value;
if (_map != null) { _map.getTrackingSettings().setMyBearingTrackingMode(value); };
if (_map != null) { _map.getTrackingSettings().setMyBearingTrackingMode(value); }
}
public void setAttributionButtonIsHidden(boolean value) {
@@ -546,6 +550,7 @@ public class ReactNativeMapboxGLView extends RelativeLayout implements
public boolean onMarkerClick(@NonNull Marker marker) {
emitEvent("onOpenAnnotation", serializeMarker(marker));
if (_annotationsPopUpEnabled == false) { return true; }
// Due to a bug, we need to force a relayout on the _mapView
_handler.post(new Runnable() {
@Override
@@ -568,7 +573,7 @@ public class ReactNativeMapboxGLView extends RelativeLayout implements
}
public LatLngBounds getBounds() {
if (_map == null) { return new LatLngBounds.Builder().build(); };
if (_map == null) { return new LatLngBounds.Builder().build(); }
return _map.getProjection().getVisibleRegion().latLngBounds;
}
@@ -604,7 +609,6 @@ public class ReactNativeMapboxGLView extends RelativeLayout implements
public void onCancel() {
if (callback != null) { callback.run(); }
}
@Override
public void onFinish() {
if (callback != null) { callback.run(); }
@@ -666,4 +670,9 @@ public class ReactNativeMapboxGLView extends RelativeLayout implements
Marker marker = (Marker)annotation;
_map.selectMarker(marker);
}
public void deselectAnnotation() {
if (_map == null) { return; }
_map.deselectMarkers();
}
}