ios - Get distance from user's location to nearest point on GMSPath -
i working google maps api , have drawn gmspolyline
s on map. know "node" (lat , long position turning point) on map closest user's location, , know next upcoming nodes. given information, how 1 obtain distance user's current location nearest point on closest path? in diagram below, how x when know 3 gps coordinates?
looking @ geometry problem instead of programming problem might make little easier. there exists library or api little more couple lines of code, approach should still yield result little no overhead. disclaimer: approach works straight lines.
you have 2 points on path , 1 point not on path. using basic algebra can find line parallel path , runs through user's location, , invert line find shortest line between user's location , path. it's finding intersection of 2 lines.
one thing note, larger distance between nodes less accurate euclidean distance be. should negligible nodes closer ~100 miles.
Comments
Post a Comment