Road distance,Actual distance between two places

后端 未结 3 1774
没有蜡笔的小新
没有蜡笔的小新 2020-12-19 21:23

I want to calculate the driving distance between two locations [the user\'s specified locations], before user starts the driving. I used many formulas and getDistanceFrom in

相关标签:
3条回答
  • 2020-12-19 21:28

    Using Core Location API it will only give you the distance between two point in a straight line - most roads aren't, and hence the distance will be wrong.

    0 讨论(0)
  • 2020-12-19 21:33

    See directions API of Google Maps

    You have just to make a HTTP request:
    http://maps.googleapis.com/maps/api/directions/output?parameters

    Answer could be json or xml. You will find the distance in the answer

    0 讨论(0)
  • 2020-12-19 21:43

    If you have two LatLongs you can calculate the direct distance between them; however, since you want driving directions (not as the crow flies) you'll need access to street-center-lines, so you can calculate the distance for each "leg" of the trip.

    Google Maps may provide driving directions along with route distance, you'll need to check the documentation for that specific functionality.

    edit

    On a second look, it appears this may not be available on the API (as of 2006), but a work-around is posted here: http://groups.google.com/group/Google-Maps-API/msg/4dc2fad4f74e3314

    0 讨论(0)
提交回复
热议问题