All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mapbox.mapboxsdk.maps.ShapeAnnotationContainer Maven / Gradle / Ivy

There is a newer version: 9.2.1
Show newest version
package com.mapbox.mapboxsdk.maps;

import android.graphics.RectF;
import android.support.v4.util.LongSparseArray;

import com.mapbox.mapboxsdk.annotations.Annotation;

import java.util.ArrayList;
import java.util.List;

class ShapeAnnotationContainer implements ShapeAnnotations {

  private final NativeMapView nativeMapView;
  private final LongSparseArray annotations;

  ShapeAnnotationContainer(NativeMapView nativeMapView, LongSparseArray annotations) {
    this.nativeMapView = nativeMapView;
    this.annotations = annotations;
  }

  @Override
  public List obtainAllIn(RectF rectangle) {
    RectF rect = nativeMapView.getDensityDependantRectangle(rectangle);
    long[] annotationIds = nativeMapView.queryShapeAnnotations(rect);
    return getAnnotationsFromIds(annotationIds);
  }

  private List getAnnotationsFromIds(long[] annotationIds) {
    List shapeAnnotations = new ArrayList<>();
    for (long annotationId : annotationIds) {
      Annotation annotation = annotations.get(annotationId);
      if (annotation != null) {
        shapeAnnotations.add(annotation);
      }
    }
    return shapeAnnotations;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy