2

I have problems with android google map api v2.

I want to select a polyline from the map like I select a marker. With a marker I use onTap.

Is it possible to select a polyline?

Pavel Dudka
  • 20,754
  • 7
  • 70
  • 83

2 Answers2

1

Just use PolyUtil#isLocationOnPath(...) from android map utils. It is exactly what you want.

Example:

googleMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
    @Override
    public void onMapClick(LatLng latLng) {
        boolean isOnRoute = PolyUtil.isLocationOnPath(latLng, latLngs, true, tolerance);
        // do what you want
    }
}
Oleksandr
  • 6,226
  • 1
  • 46
  • 54
0

You will have to write your own algorithm for that and do the checking in OnMapClickListener.

MaciejGórski
  • 22,187
  • 7
  • 70
  • 94