Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -375,8 +376,7 @@ public boolean onMapClick(@NonNull LatLng point) {
return false;
}

T annotation = queryMapForFeatures(point);
if (annotation != null) {
for (T annotation : queryMapForAllFeatures(point)) {
for (U clickListener : clickListeners) {
if (clickListener.onAnnotationClick(annotation)) {
return true;
Expand All @@ -392,8 +392,7 @@ public boolean onMapLongClick(@NonNull LatLng point) {
return false;
}

T annotation = queryMapForFeatures(point);
if (annotation != null) {
for (T annotation : queryMapForAllFeatures(point)) {
for (V clickListener : longClickListeners) {
if (clickListener.onAnnotationLongClick(annotation)) {
return true;
Expand All @@ -404,11 +403,6 @@ public boolean onMapLongClick(@NonNull LatLng point) {
}
}

@Nullable
private T queryMapForFeatures(@NonNull LatLng point) {
return queryMapForFeatures(mapboxMap.getProjection().toScreenLocation(point));
}

@Nullable
T queryMapForFeatures(@NonNull PointF point) {
List<Feature> features = mapboxMap.queryRenderedFeatures(point, coreElementProvider.getLayerId());
Expand All @@ -418,4 +412,23 @@ T queryMapForFeatures(@NonNull PointF point) {
}
return null;
}

@NonNull
private List<T> queryMapForAllFeatures(@NonNull LatLng point) {
return queryMapForAllFeatures(mapboxMap.getProjection().toScreenLocation(point));
}

@NonNull
List<T> queryMapForAllFeatures(@NonNull PointF point) {
List<T> annotations = new LinkedList<T>();
List<Feature> features = mapboxMap.queryRenderedFeatures(point, coreElementProvider.getLayerId());
for (Feature feature : features) {
long id = feature.getProperty(getAnnotationIdKey()).getAsLong();
T annotation = this.annotations.get(id);
if (annotation != null) {
annotations.add(annotation);
}
}
return annotations;
}
}