Вопрос

I am developing an iOS app where I need to get the walking route distance between two locations.

I have used CoreLocation API

- (CLLocationDistance)distanceFromLocation:(const CLLocation *)location

As per the documentation This method measures the distance between the two locations by tracing a line between them that follows the curvature of the Earth.

The distance it gave was different from the the one which shown in the iOS map app (after converting to miles) as shown in the figure.

walking route distance

I want to get the walking route distance between two locations which we gets in the map app inside my app. is there any API to get this distance.

Could anyone please help me to achieve this.

Это было полезно?

Решение

The CoreLocation API does not give distance along a walking route, it can only give you straight line "as the crow flies" distance. You need to query a network service that has a network of streets and walkways to get actual walking distance. CL and MapKit do not provide this service.

You can send a request to Apple Maps app to get walking directions between two points but the results are not provided back to your app, they are presented to the user.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top