Distance to road, Actual distance between two places

I want to calculate the distance between two locations [user specified points] before the user starts moving. I used a lot of formulas and getDistanceFrom in CLLocation, but I cannot achieve the perfect distance between these places.

There is a big difference in the actual and calculated distance.

Please help me calculate the distance between two points. How can I use the Google Maps API to calculate my travel distance?

I already used regexkitlite to show the road path on Google Maps between two places. However, I cannot calculate the distance of the path.

If you have a code / link, send it to me.

Thanks in advance....

+3
source share
3 answers

See the Google Maps API Index

You only need to make an HTTP request:
http://maps.googleapis.com/maps/api/directions/output?parameters

The answer may be json or xml. You will find the distance in the answer

+4
source

If you have two LatLongs, you can calculate the direct distance between them; however, since you want to get directions (not like a crow), you need access to street lines, so you can calculate the distance for each “leg” of the trip.

Google maps can provide driving directions along with the distance of the route, you will need to check the documentation for this specific function.

change

, , API ( 2006 ), : http://groups.google.com/group/Google-Maps-API/msg/4dc2fad4f74e3314

0

Using the Core Location API, it will only give you the distance between two points in a straight line - most roads are not, and therefore the distance will be incorrect.

0
source

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


All Articles