If there is a polyline on googlemap and a click is performed on the map, then how can I check whether that click was on polyline or somewhere else?
Polyline
The solution above doesn't work correctly. Especially if we have large distance between two points of polyline.
I answered this question: Clickable Polylines Google Maps API Android
We can modify code above like this:
mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
@Override
public void onMapClick(LatLng clickCoords) {
for (PolylineOptions polyline : mPolylines) {
if (PolyUtil.isLocationOnPath(clickCoords, polyline.getPoints(), true, 100)) {
// user clicked on polyline
}
}
}
});