diff --git a/plugin-locationlayer/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerCamera.java b/plugin-locationlayer/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerCamera.java index 3e2f012b9..194fc3353 100644 --- a/plugin-locationlayer/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerCamera.java +++ b/plugin-locationlayer/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerCamera.java @@ -26,12 +26,14 @@ final class LocationLayerCamera implements LocationLayerAnimator.OnCameraAnimati private boolean adjustFocalPoint; private final MoveGestureDetector moveGestureDetector; + private final OnCameraMoveInvalidateListener onCameraMoveInvalidateListener; LocationLayerCamera( Context context, MapboxMap mapboxMap, OnCameraTrackingChangedListener internalCameraTrackingChangedListener, - LocationLayerOptions options) { + LocationLayerOptions options, + OnCameraMoveInvalidateListener onCameraMoveInvalidateListener) { this.mapboxMap = mapboxMap; mapboxMap.setGesturesManager( new PluginsGesturesManager(context), true, true); @@ -40,6 +42,7 @@ final class LocationLayerCamera implements LocationLayerAnimator.OnCameraAnimati mapboxMap.addOnRotateListener(onRotateListener); this.internalCameraTrackingChangedListener = internalCameraTrackingChangedListener; + this.onCameraMoveInvalidateListener = onCameraMoveInvalidateListener; initializeOptions(options); } @@ -61,10 +64,12 @@ int getCameraMode() { private void setBearing(float bearing) { mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(bearing)); + onCameraMoveInvalidateListener.onInvalidateCameraMove(); } private void setLatLng(LatLng latLng) { mapboxMap.moveCamera(CameraUpdateFactory.newLatLng(latLng)); + onCameraMoveInvalidateListener.onInvalidateCameraMove(); } @Override diff --git a/plugin-locationlayer/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerPlugin.java b/plugin-locationlayer/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerPlugin.java index ad005b655..f7a5fb4a5 100644 --- a/plugin-locationlayer/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerPlugin.java +++ b/plugin-locationlayer/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerPlugin.java @@ -501,7 +501,7 @@ private void initialize() { locationLayer = new LocationLayer(mapView, mapboxMap, options); locationLayerCamera = new LocationLayerCamera( - mapView.getContext(), mapboxMap, cameraTrackingChangedListener, options); + mapView.getContext(), mapboxMap, cameraTrackingChangedListener, options, onCameraMoveInvalidateListener); locationLayerAnimator = new LocationLayerAnimator(); locationLayerAnimator.addLayerListener(locationLayer); locationLayerAnimator.addCameraListener(locationLayerCamera); @@ -639,6 +639,13 @@ public void onMapChanged(int change) { } }; + private OnCameraMoveInvalidateListener onCameraMoveInvalidateListener = new OnCameraMoveInvalidateListener() { + @Override + public void onInvalidateCameraMove() { + onCameraMoveListener.onCameraMove(); + } + }; + private CompassListener compassListener = new CompassListener() { @Override public void onCompassChanged(float userHeading) { diff --git a/plugin-locationlayer/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/OnCameraMoveInvalidateListener.java b/plugin-locationlayer/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/OnCameraMoveInvalidateListener.java new file mode 100644 index 000000000..3636df9f8 --- /dev/null +++ b/plugin-locationlayer/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/OnCameraMoveInvalidateListener.java @@ -0,0 +1,7 @@ +package com.mapbox.mapboxsdk.plugins.locationlayer; + +interface OnCameraMoveInvalidateListener { + + void onInvalidateCameraMove(); + +}