Using the latitude and longitude of the current location and destination, how can we get directions in iphone

I work in 1 iphone application where we need to show the direction from 1st place to another place That is, from the current location in which direction (N or E or W or S or NE or NW or SE or SW) the destination. I know how to get routes from one place to another place, but I am looking to show directions. Is my problem understandable? If anyone knows how to do this, please help me. Thank you all!

+1
source share
2 answers

Do you know the coordinates of two places?

See CLLocationCoordinate2D :

. . .

. , , .

, , , , , , , , .

latitudinal_distance = destination.latitude - origin.latitude

, , , , . , , , .

distance_east = (origin.longitude > 0 && destination.longitude < 0) ? 180 - origin.longitude + destination.longitude - -180 : destination.longitude - origin.longitude; if (distance_east < 0) distance_east += 360

distance_west = (origin.longitude < 0 && destination.longitude > 0) ? -180 - origin.longitude - 180 - destination.longitude : origin.longitude - destination.longitude; if (distance_west < 0) distance_west += 360

longitudinal_distance = min(distance_east, distance_west)

, , , , . (N, E, S, W) 90 . 8 45 . , .

heading = arctan(longitudinal_distance / latitudinal_distance) if (heading >= -45 || heading < 45) return 'N'; else if (heading >= 45 && heading < 135) return 'E'; else if ...

, , , , , , . , , , .

+3

/ Apple: Teslameter

0

Source: https://habr.com/ru/post/1786979/


All Articles