2

Im trying to design a navigation app based on Google maps. What I'm looking for is an article or any possible solution to let me be able to, given a polyline, which represents a route on the map, detect all interceptions between the polyline and markers on the map so that I can display for a distinct route how many and what kind of markers this route passes through.

Basically what I lm asking is if there is a way I can detect interceptions between my polyline(which represents a route) and the markers (which represent points of interest on the map, I e), I've thought about using geofences but I can't find a method or a way that would allow me to get interceptions between polyline and geofences created over the markers, any kind of help would be appreciated.

Chaquice
  • 29
  • 3
  • 1
    Actually there is a method called PolyUtil.isLocationOnPath that simplified everything for me, boolean isLocationOnPath(LatLng point, List polyline, boolean geodesic, double tolerance) where Point is your actual point of interest in my example and Polyline is the route. Just writing here so that it can help someone down the line! – Chaquice Sep 14 '17 at 22:08

1 Answers1

1

Seems there is no specific method in Google Maps API, but if You have polyline points and marker coordinates, You can test for each marker and each polyline segment for marker on the polyline segment laying, for example by this way described by MrROY.

Update

You also can use PolyUtil.isLocationOnPath(LatLng point, java.util.List<LatLng> polyline, boolean geodesic, double tolerance) method form Google Maps Android API Utility Library to test intersection of Marker and polyline with tolerance precision.

Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79
  • Seems like the easiest way out. So basically, i should get the 1st point and the second, draw an imaginary line and test to check wether there are any markers on that line! Thank you for your reply, I'll try this implementation the second I have a second! – Chaquice Aug 07 '17 at 18:26
  • Yes, you understood everything right. Do this steps for all segments and all markers. – Andrii Omelchenko Aug 07 '17 at 19:22
  • Your one line saved my entire calculation. Thanks :) – Jigar Sep 03 '18 at 09:44