0

I have a list of Lats and Longs together form a Polyline and a current location. Now how can I find from a know position to the closest point(LatLng) in the polyline?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Adarsh
  • 45
  • 8
  • see [this](http://googlemaps.github.io/android-maps-utils/javadoc/com/google/maps/android/PolyUtil.html) – pskink Aug 26 '18 at 07:51
  • @pskink I have gone through this link before but it seems to give return true or false result. I want the nearest point from the list rather than a boolean value. – Adarsh Aug 26 '18 at 07:55
  • what does `distanceToLine(LatLng p, LatLng start, LatLng end)` return? true / false? or double? – pskink Aug 26 '18 at 07:56
  • @pskink it seems to return a double value which contains distance only. But I'm not getting on how to implement it. – Adarsh Aug 26 '18 at 08:00
  • Too inefficient to do `distanceToLine` for each segment of the Polyline, and take minimum distance? – Eric Aug 26 '18 at 08:00
  • did you check `PolyUtil.java` source code? if so, whats unclear in `distanceToLine` implementation and finding the `LatLng` of the closest point? – pskink Aug 26 '18 at 08:03
  • This link will help you https://stackoverflow.com/questions/36104809/find-the-closest-point-on-polygon-to-user-location – Son Truong Aug 26 '18 at 10:18

0 Answers0