[android] - getMarkerViews in rect should return in bound views (#7015)
* [android] - getMarkerViews in rectangle should only return in bound views. * added example in test app for debugging * Covert rectangle coming in to density dependant rectangle
This commit is contained in:
@@ -329,7 +329,14 @@ class AnnotationManager {
|
||||
return selectedMarkers;
|
||||
}
|
||||
|
||||
public List<Marker> getMarkersInRect(@NonNull RectF rect) {
|
||||
public List<Marker> getMarkersInRect(@NonNull RectF rectangle) {
|
||||
// convert Rectangle to be density depedent
|
||||
float pixelRatio = nativeMapView.getPixelRatio();
|
||||
RectF rect = new RectF(rectangle.left / pixelRatio,
|
||||
rectangle.top / pixelRatio,
|
||||
rectangle.right / pixelRatio,
|
||||
rectangle.bottom / pixelRatio);
|
||||
|
||||
long[] ids = nativeMapView.queryPointAnnotations(rect);
|
||||
|
||||
List<Long> idsList = new ArrayList<>(ids.length);
|
||||
@@ -350,7 +357,13 @@ class AnnotationManager {
|
||||
return new ArrayList<>(annotations);
|
||||
}
|
||||
|
||||
public List<MarkerView> getMarkerViewsInRect(@NonNull RectF rect) {
|
||||
public List<MarkerView> getMarkerViewsInRect(@NonNull RectF rectangle) {
|
||||
float pixelRatio = nativeMapView.getPixelRatio();
|
||||
RectF rect = new RectF(rectangle.left / pixelRatio,
|
||||
rectangle.top / pixelRatio,
|
||||
rectangle.right / pixelRatio,
|
||||
rectangle.bottom / pixelRatio);
|
||||
|
||||
long[] ids = nativeMapView.queryPointAnnotations(rect);
|
||||
|
||||
List<Long> idsList = new ArrayList<>(ids.length);
|
||||
@@ -363,7 +376,7 @@ class AnnotationManager {
|
||||
int count = annotationList.size();
|
||||
for (int i = 0; i < count; i++) {
|
||||
Annotation annotation = annotationList.get(i);
|
||||
if (annotation instanceof MarkerView) {
|
||||
if (annotation instanceof MarkerView && idsList.contains(annotation.getId())) {
|
||||
annotations.add((MarkerView) annotation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1572,10 +1572,10 @@ public class MapView extends FrameLayout {
|
||||
float toleranceSides = 4 * screenDensity;
|
||||
float toleranceTopBottom = 10 * screenDensity;
|
||||
|
||||
RectF tapRect = new RectF((tapPoint.x - iconManager.getAverageIconWidth() / 2 - toleranceSides) / screenDensity,
|
||||
(tapPoint.y - iconManager.getAverageIconHeight() / 2 - toleranceTopBottom) / screenDensity,
|
||||
(tapPoint.x + iconManager.getAverageIconWidth() / 2 + toleranceSides) / screenDensity,
|
||||
(tapPoint.y + iconManager.getAverageIconHeight() / 2 + toleranceTopBottom) / screenDensity);
|
||||
RectF tapRect = new RectF(tapPoint.x - iconManager.getAverageIconWidth() / 2 - toleranceSides,
|
||||
tapPoint.y - iconManager.getAverageIconHeight() / 2 - toleranceTopBottom,
|
||||
tapPoint.x + iconManager.getAverageIconWidth() / 2 + toleranceSides,
|
||||
tapPoint.y + iconManager.getAverageIconHeight() / 2 + toleranceTopBottom);
|
||||
|
||||
List<Marker> nearbyMarkers = annotationManager.getMarkersInRect(tapRect);
|
||||
long newSelectedMarkerId = -1;
|
||||
|
||||
Reference in New Issue
Block a user