Search code examples
androidgeolocationgeometryhere-api

How to select all markers in certain radius from tapped point on HERE map


I am using HERE map Android SDK. I have subscribed to OnGestureListener as follows. onMapObjectsSelected method returns only those markers which are actually clicked. I want to mark near by markers (within radius) SELECTED from onTapEvent.

mapFragment.getMapGesture().addOnGestureListener(mlistener);

MapGesture.OnGestureListener mlistener =
    new MapGesture.OnGestureListener.OnGestureListenerAdapter() {
    @Override
    public boolean onTapEvent(PointF pointF) {
        int radius = 500; // 500 meter                    
        // How can I select all available markers within 500 mtr radius
        // from point PointF.
        return super.onTapEvent(pointF);
    }

    @Override
    public boolean onMapObjectsSelected(List<ViewObject> objects) {
        // Selected markers should be auto listed within objects list
    }
};

Solution

  • Use Map#getSelectedObject with a view rect. The viewrect should be computed as the minimal bounding square for your circle of some radius in meters. After that, you can filter the results to prune out any objects returned within the selected object rectangle that is greater than the required distance.