user1881565
user1881565

Reputation: 21

google map android api v2 select polyline

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?

Upvotes: 2

Views: 819

Answers (2)

Oleksandr
Oleksandr

Reputation: 6356

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
    }
}

Upvotes: 1

MaciejGórski
MaciejGórski

Reputation: 22232

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

Upvotes: 0

Related Questions