问题描述
我正在从移动应用程序调用Mapbox Directions API,并在地图上手动绘制结果路径.如果我在2个相对较近的位置通过,则响应中将包含坐标,并且路径会沿着道路行驶.如果我在两个相距较远的地方通过,则响应会包含更多坐标,但是路径会沿着长距离直线走,而忽略道路.似乎它失去了更长距离的细节.
I'm calling the Mapbox Directions API from a mobile app and manually drawing the resulting path on a map. If I pass in 2 relatively close locations, the response includes coordinates and the path nicely follows roads. If I pass in 2 locations that are far away, the the response includes more coordinates, but the path follows straight lines over long distances, ignoring roads. Seems like it loses details with longer distances.
Mapbox Directions API是否会限制响应中坐标的数量或精度,如果是,我该怎么知道?
Does Mapbox Directions API limit the number or precision of coordinates in a response and if so, how can I tell?
例如,查询1返回8个coordiantes,代表沿道路行驶约1/4英里.查询2返回大约60个坐标,但是路径中有较长的路段经过道路.
For instance Query 1 returns 8 coordiantes representing a about 1/4 mile following roads. Query 2 returns about 60 coordinates, but the path has long segments that go over roads.
您可以使用 API Playground 可视化此内容,在-73.989,40.733; -74,40.733(查询1)和 -73 .989,40.733; -94 ,40.733(查询2)
You can visualize this using the API Playground, putting in -73.989,40.733;-74,40.733 for Query 1 and -73.989,40.733;-94,40.733 for Query 2
查询1 https://api.mapbox.com/directions/v5/mapbox/driving/-73.989%2C40.733%3B-74%2C40.733.json?access_token=pk.eyJ1Ijoic3RldmVyZXMiLCJhIjoiY2syM2pzZmFwMjV3cTNkbXV2Nnpwd2I4aiJ9.q-86qHLcFYbwk_RLs27N-Q&geometries = geojson
查询2 https://api.mapbox.com/directions/v5/mapbox/driving/-73.989%2C40.733%3B-94%2C40.733.json?access_token=pk.eyJ1Ijoic3RldmVyZXMiLCJhIjoiY2syM2pzZmFwMjV3cTNkbXV2Nnpwd2I4aiJ9.q-86qHLcFYbwk_RLs27N-Q&geometries = geojson
谢谢!
推荐答案
您可以使用 overview = full
(这是查询中的可选参数),以获取最详细的几何图形,因此您的查询将如下所示:
You can use the overview=full
which is an optional parameter in your queries to get the most detailed geometry, so your queries would look something like this:
查询1
https://api.mapbox.com/directions/v5/mapbox/driving/-73.989%2C40.733%3B-74%2C40.733.json?access_token=pk.eyJ1Ijoic3RldmVyZXMiLCJhIjoiY2syM2pzZmFwMjV3cTNkbXV2Nnpwd2I4aiJ9.q-86qHLcFYbwk_RLs27N-Q&geometries=geojson&overview=full
查询2
https://api.mapbox.com/directions/v5/mapbox/driving/-73.989%2C40.733%3B-94%2C40.733.json?access_token=pk.eyJ1Ijoic3RldmVyZXMiLCJhIjoiY2syM2pzZmFwMjV3cTNkbXV2Nnpwd2I4aiJ9.q-86qHLcFYbwk_RLs27N-Q&geometries=geojson&overview=full
如果将它们放在API操场上,您应该会看到用于第二次查询的更详细的路线.
If you put them in the API playground, you should see a more detailed route for your 2nd Query.
这篇关于Mapbox Directions API是否会限制响应中坐标的数量或精度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!