I've been playing around with the Google Maps/Google directions API. Does anyone have an inkling on how I might be able to find the mid-point along a route, not the geographic midpoint.
Ideally I'd like to find the lat and long values of this midpoint.
Any thoughts? I'm a bit stumped and hoping I may be able to find a suggestion without going crazy trying to find the answer myself.
An easiest way is that you can first:
1) Calculate total distance of the path using GMSGeometryDistance, by calculating the distance between every two subsequent points by GMSGeometryDistance function, then summing all the distance.
2) Then you calculate again, and summing in each step. When the sum is about half of the total distance, then you are at the middle point. Sample code is as following:
There is more to optimize the function. I wrote a detail answer in Swift in here