summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java214
1 files changed, 189 insertions, 25 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java
index 509e784e58..cbd3842a02 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java
@@ -16,6 +16,14 @@ import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
+import com.mapbox.android.core.location.LocationEngine;
+import com.mapbox.android.gestures.AndroidGesturesManager;
+import com.mapbox.android.gestures.MoveGestureDetector;
+import com.mapbox.android.gestures.RotateGestureDetector;
+import com.mapbox.android.gestures.ShoveGestureDetector;
+import com.mapbox.android.gestures.StandardScaleGestureDetector;
+import com.mapbox.geojson.Feature;
+import com.mapbox.geojson.Geometry;
import com.mapbox.mapboxsdk.annotations.Annotation;
import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions;
import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions;
@@ -41,9 +49,6 @@ import com.mapbox.mapboxsdk.style.layers.Filter;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.light.Light;
import com.mapbox.mapboxsdk.style.sources.Source;
-import com.mapbox.services.android.telemetry.location.LocationEngine;
-import com.mapbox.services.commons.geojson.Feature;
-import com.mapbox.services.commons.geojson.Geometry;
import java.lang.reflect.ParameterizedType;
import java.util.HashMap;
@@ -73,13 +78,13 @@ public final class MapboxMap {
private final MyLocationViewSettings myLocationViewSettings;
private final CameraChangeDispatcher cameraChangeDispatcher;
- private final OnRegisterTouchListener onRegisterTouchListener;
+ private final OnGesturesManagerInteractionListener onGesturesManagerInteractionListener;
private MapboxMap.OnFpsChangedListener onFpsChangedListener;
private PointF focalPoint;
MapboxMap(NativeMapView map, Transform transform, UiSettings ui, TrackingSettings tracking,
- MyLocationViewSettings myLocationView, Projection projection, OnRegisterTouchListener listener,
+ MyLocationViewSettings myLocationView, Projection projection, OnGesturesManagerInteractionListener listener,
AnnotationManager annotations, CameraChangeDispatcher cameraChangeDispatcher) {
this.nativeMapView = map;
this.uiSettings = ui;
@@ -88,7 +93,7 @@ public final class MapboxMap {
this.myLocationViewSettings = myLocationView;
this.annotationManager = annotations.bind(this);
this.transform = transform;
- this.onRegisterTouchListener = listener;
+ this.onGesturesManagerInteractionListener = listener;
this.cameraChangeDispatcher = cameraChangeDispatcher;
}
@@ -1882,12 +1887,11 @@ public final class MapboxMap {
*
* @param listener The callback that's invoked when the map is scrolled.
* To unset the callback, use null.
- *
* @deprecated Use {@link #addOnScrollListener(OnScrollListener)} instead.
*/
@Deprecated
public void setOnScrollListener(@Nullable OnScrollListener listener) {
- onRegisterTouchListener.onSetScrollListener(listener);
+ onGesturesManagerInteractionListener.onSetScrollListener(listener);
}
/**
@@ -1895,10 +1899,9 @@ public final class MapboxMap {
*
* @param listener The callback that's invoked when the map is scrolled.
* To unset the callback, use null.
- *
*/
public void addOnScrollListener(@Nullable OnScrollListener listener) {
- onRegisterTouchListener.onAddScrollListener(listener);
+ onGesturesManagerInteractionListener.onAddScrollListener(listener);
}
/**
@@ -1906,10 +1909,9 @@ public final class MapboxMap {
*
* @param listener The callback that's invoked when the map is scrolled.
* To unset the callback, use null.
- *
*/
public void removeOnScrollListener(@Nullable OnScrollListener listener) {
- onRegisterTouchListener.onRemoveScrollListener(listener);
+ onGesturesManagerInteractionListener.onRemoveScrollListener(listener);
}
/**
@@ -1917,12 +1919,11 @@ public final class MapboxMap {
*
* @param listener The callback that's invoked when the map is flinged.
* To unset the callback, use null.
- *
* @deprecated Use {@link #addOnFlingListener(OnFlingListener)} instead.
*/
@Deprecated
public void setOnFlingListener(@Nullable OnFlingListener listener) {
- onRegisterTouchListener.onSetFlingListener(listener);
+ onGesturesManagerInteractionListener.onSetFlingListener(listener);
}
/**
@@ -1932,7 +1933,7 @@ public final class MapboxMap {
* To unset the callback, use null.
*/
public void addOnFlingListener(@Nullable OnFlingListener listener) {
- onRegisterTouchListener.onAddFlingListener(listener);
+ onGesturesManagerInteractionListener.onAddFlingListener(listener);
}
/**
@@ -1942,7 +1943,98 @@ public final class MapboxMap {
* To unset the callback, use null.
*/
public void removeOnFlingListener(@Nullable OnFlingListener listener) {
- onRegisterTouchListener.onRemoveFlingListener(listener);
+ onGesturesManagerInteractionListener.onRemoveFlingListener(listener);
+ }
+
+ /**
+ * Adds a callback that's invoked when the map is moved.
+ *
+ * @param listener The callback that's invoked when the map is moved.
+ */
+ public void addOnMoveListener(OnMoveListener listener) {
+ onGesturesManagerInteractionListener.onAddMoveListener(listener);
+ }
+
+ /**
+ * Removes a callback that's invoked when the map is moved.
+ *
+ * @param listener The callback that's invoked when the map is moved.
+ */
+ public void removeOnMoveListener(OnMoveListener listener) {
+ onGesturesManagerInteractionListener.onRemoveMoveListener(listener);
+ }
+
+ /**
+ * Adds a callback that's invoked when the map is rotated.
+ *
+ * @param listener The callback that's invoked when the map is rotated.
+ */
+ public void addOnRotateListener(OnRotateListener listener) {
+ onGesturesManagerInteractionListener.onAddRotateListener(listener);
+ }
+
+ /**
+ * Removes a callback that's invoked when the map is rotated.
+ *
+ * @param listener The callback that's invoked when the map is rotated.
+ */
+ public void removeOnRotateListener(OnRotateListener listener) {
+ onGesturesManagerInteractionListener.onRemoveRotateListener(listener);
+ }
+
+ /**
+ * Adds a callback that's invoked when the map is scaled.
+ *
+ * @param listener The callback that's invoked when the map is scaled.
+ */
+ public void addOnScaleListener(OnScaleListener listener) {
+ onGesturesManagerInteractionListener.onAddScaleListener(listener);
+ }
+
+ /**
+ * Removes a callback that's invoked when the map is scaled.
+ *
+ * @param listener The callback that's invoked when the map is scaled.
+ */
+ public void removeOnScaleListener(OnScaleListener listener) {
+ onGesturesManagerInteractionListener.onRemoveScaleListener(listener);
+ }
+
+ /**
+ * Adds a callback that's invoked when the map is tilted.
+ *
+ * @param listener The callback that's invoked when the map is tilted.
+ */
+ public void addOnShoveListener(OnShoveListener listener) {
+ onGesturesManagerInteractionListener.onAddShoveListener(listener);
+ }
+
+ /**
+ * Remove a callback that's invoked when the map is tilted.
+ *
+ * @param listener The callback that's invoked when the map is tilted.
+ */
+ public void removeOnShoveListener(OnShoveListener listener) {
+ onGesturesManagerInteractionListener.onRemoveShoveListener(listener);
+ }
+
+ /**
+ * Sets a custom {@link AndroidGesturesManager} to handle {@link android.view.MotionEvent}s registered by the map.
+ *
+ * @param androidGesturesManager Gestures manager that interprets gestures based on the motion events.
+ * @see <a href="https://github.com/mapbox/mapbox-gestures-android">mapbox-gestures-android library</a>
+ */
+ public void setGesturesManager(AndroidGesturesManager androidGesturesManager) {
+ onGesturesManagerInteractionListener.setGesturesManager(androidGesturesManager);
+ }
+
+ /**
+ * Get current {@link AndroidGesturesManager} that handles {@link android.view.MotionEvent}s registered by the map.
+ *
+ * @return Current gestures manager.
+ */
+ public AndroidGesturesManager getGesturesManager() {
+ return onGesturesManagerInteractionListener.getGesturesManager();
}
/**
@@ -1950,12 +2042,11 @@ public final class MapboxMap {
*
* @param listener The callback that's invoked when the user clicks on the map view.
* To unset the callback, use null.
- *
* @deprecated Use {@link #addOnMapClickListener(OnMapClickListener)} instead.
*/
@Deprecated
public void setOnMapClickListener(@Nullable OnMapClickListener listener) {
- onRegisterTouchListener.onSetMapClickListener(listener);
+ onGesturesManagerInteractionListener.onSetMapClickListener(listener);
}
/**
@@ -1965,7 +2056,7 @@ public final class MapboxMap {
* To unset the callback, use null.
*/
public void addOnMapClickListener(@Nullable OnMapClickListener listener) {
- onRegisterTouchListener.onAddMapClickListener(listener);
+ onGesturesManagerInteractionListener.onAddMapClickListener(listener);
}
/**
@@ -1975,7 +2066,7 @@ public final class MapboxMap {
* To unset the callback, use null.
*/
public void removeOnMapClickListener(@Nullable OnMapClickListener listener) {
- onRegisterTouchListener.onRemoveMapClickListener(listener);
+ onGesturesManagerInteractionListener.onRemoveMapClickListener(listener);
}
/**
@@ -1983,12 +2074,11 @@ public final class MapboxMap {
*
* @param listener The callback that's invoked when the user long clicks on the map view.
* To unset the callback, use null.
- *
* @deprecated Use {@link #addOnMapLongClickListener(OnMapLongClickListener)} instead.
*/
@Deprecated
public void setOnMapLongClickListener(@Nullable OnMapLongClickListener listener) {
- onRegisterTouchListener.onSetMapLongClickListener(listener);
+ onGesturesManagerInteractionListener.onSetMapLongClickListener(listener);
}
/**
@@ -1998,7 +2088,7 @@ public final class MapboxMap {
* To unset the callback, use null.
*/
public void addOnMapLongClickListener(@Nullable OnMapLongClickListener listener) {
- onRegisterTouchListener.onAddMapLongClickListener(listener);
+ onGesturesManagerInteractionListener.onAddMapLongClickListener(listener);
}
/**
@@ -2008,7 +2098,7 @@ public final class MapboxMap {
* To unset the callback, use null.
*/
public void removeOnMapLongClickListener(@Nullable OnMapLongClickListener listener) {
- onRegisterTouchListener.onRemoveMapLongClickListener(listener);
+ onGesturesManagerInteractionListener.onRemoveMapLongClickListener(listener);
}
/**
@@ -2267,7 +2357,9 @@ public final class MapboxMap {
* Interface definition for a callback to be invoked when the map is scrolled.
*
* @see MapboxMap#setOnScrollListener(OnScrollListener)
+ * @deprecated Use {@link OnMoveListener} instead.
*/
+ @Deprecated
public interface OnScrollListener {
/**
* Called when the map is scrolled.
@@ -2276,6 +2368,58 @@ public final class MapboxMap {
}
/**
+ * Interface definition for a callback to be invoked when the map is moved.
+ *
+ * @see MapboxMap#addOnMoveListener(OnMoveListener)
+ */
+ public interface OnMoveListener {
+ void onMoveBegin(MoveGestureDetector detector);
+
+ void onMove(MoveGestureDetector detector);
+
+ void onMoveEnd(MoveGestureDetector detector);
+ }
+
+ /**
+ * Interface definition for a callback to be invoked when the map is rotated.
+ *
+ * @see MapboxMap#addOnRotateListener(OnRotateListener)
+ */
+ public interface OnRotateListener {
+ void onRotateBegin(RotateGestureDetector detector);
+
+ void onRotate(RotateGestureDetector detector);
+
+ void onRotateEnd(RotateGestureDetector detector);
+ }
+
+ /**
+ * Interface definition for a callback to be invoked when the map is scaled.
+ *
+ * @see MapboxMap#addOnScaleListener(OnScaleListener)
+ */
+ public interface OnScaleListener {
+ void onScaleBegin(StandardScaleGestureDetector detector);
+
+ void onScale(StandardScaleGestureDetector detector);
+
+ void onScaleEnd(StandardScaleGestureDetector detector);
+ }
+
+ /**
+ * Interface definition for a callback to be invoked when the map is tilted.
+ *
+ * @see MapboxMap#addOnShoveListener(OnShoveListener)
+ */
+ public interface OnShoveListener {
+ void onShoveBegin(ShoveGestureDetector detector);
+
+ void onShove(ShoveGestureDetector detector);
+
+ void onShoveEnd(ShoveGestureDetector detector);
+ }
+
+ /**
* Interface definition for a callback to be invoked when the camera changes position.
*
* @deprecated Replaced by {@link MapboxMap.OnCameraMoveStartedListener}, {@link MapboxMap.OnCameraMoveListener} and
@@ -2377,7 +2521,7 @@ public final class MapboxMap {
* Interface definition for a callback to be invoked when a user registers an listener that is
* related to touch and click events.
*/
- interface OnRegisterTouchListener {
+ interface OnGesturesManagerInteractionListener {
void onSetMapClickListener(OnMapClickListener listener);
void onAddMapClickListener(OnMapClickListener listener);
@@ -2401,6 +2545,26 @@ public final class MapboxMap {
void onAddFlingListener(OnFlingListener listener);
void onRemoveFlingListener(OnFlingListener listener);
+
+ void onAddMoveListener(OnMoveListener listener);
+
+ void onRemoveMoveListener(OnMoveListener listener);
+
+ void onAddRotateListener(OnRotateListener listener);
+
+ void onRemoveRotateListener(OnRotateListener listener);
+
+ void onAddScaleListener(OnScaleListener listener);
+
+ void onRemoveScaleListener(OnScaleListener listener);
+
+ void onAddShoveListener(OnShoveListener listener);
+
+ void onRemoveShoveListener(OnShoveListener listener);
+
+ AndroidGesturesManager getGesturesManager();
+
+ void setGesturesManager(AndroidGesturesManager gesturesManager);
}
/**