diff options
author | Łukasz Paczos <lukas.paczos@gmail.com> | 2018-10-26 14:41:39 +0200 |
---|---|---|
committer | Tobrun <tobrun@mapbox.com> | 2018-10-31 14:53:56 +0100 |
commit | 48bbaa6c6ed2306c59fcab58d455bdeb5ddc91c3 (patch) | |
tree | 6f54d037682c9a5a054f8480873007020494ddf7 /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java | |
parent | 11f00c439374238901b1992a940c98ecd59880bf (diff) | |
download | qtlocation-mapboxgl-48bbaa6c6ed2306c59fcab58d455bdeb5ddc91c3.tar.gz |
[android] option to consume map clicks, consuming location clicks
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java index 9118f926f3..4e17268abb 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java @@ -583,6 +583,11 @@ public final class LocationComponent { /** * Adds a listener that gets invoked when the user clicks the displayed location. + * <p> + * If there are registered location click listeners and the location is clicked, + * only {@link OnLocationClickListener#onLocationComponentClick()} is going to be delivered, + * {@link com.mapbox.mapboxsdk.maps.MapboxMap.OnMapClickListener#onMapClick(LatLng)} is going to be consumed + * and not pushed to the listeners registered after the component's activation. * * @param listener The location click listener that is invoked when the * location is clicked @@ -602,6 +607,11 @@ public final class LocationComponent { /** * Adds a listener that gets invoked when the user long clicks the displayed location. + * <p> + * If there are registered location long click listeners and the location is long clicked, + * only {@link OnLocationLongClickListener#onLocationComponentLongClick()} is going to be delivered, + * {@link com.mapbox.mapboxsdk.maps.MapboxMap.OnMapLongClickListener#onMapLongClick(LatLng)} is going to be consumed + * and not pushed to the listeners registered after the component's activation. * * @param listener The location click listener that is invoked when the * location is clicked @@ -915,23 +925,27 @@ public final class LocationComponent { private OnMapClickListener onMapClickListener = new OnMapClickListener() { @Override - public void onMapClick(@NonNull LatLng point) { + public boolean onMapClick(@NonNull LatLng point) { if (!onLocationClickListeners.isEmpty() && locationLayerController.onMapClick(point)) { for (OnLocationClickListener listener : onLocationClickListeners) { listener.onLocationComponentClick(); } + return true; } + return false; } }; private MapboxMap.OnMapLongClickListener onMapLongClickListener = new MapboxMap.OnMapLongClickListener() { @Override - public void onMapLongClick(@NonNull LatLng point) { + public boolean onMapLongClick(@NonNull LatLng point) { if (!onLocationLongClickListeners.isEmpty() && locationLayerController.onMapClick(point)) { for (OnLocationLongClickListener listener : onLocationLongClickListeners) { listener.onLocationComponentLongClick(); } + return true; } + return false; } }; |