简体   繁体   中英

mapbox-gl-js route is not accurate

路线图

I'm new with map box and java scripts, i have try route mapping system but its not accurate. i don't know if routing map using map box-gl-js is normally its become like this or my code cause that problem. i follow the tutorial from https://docs.mapbox.com/help/tutorials/getting-started-directions-api/ .

I had the same problem and I found the answer in another Stackoverflow question ( Does Mapbox Directions API limit the number or precision of coordinates in a response? ):

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:

Query 1

https://api.mapbox.com/directions/v5/mapbox/driving/-73.989%2C40.733%3B-74%2C40.733.json?access_token=my_access_token&geometries=geojson&overview=full

Query 2

https://api.mapbox.com/directions/v5/mapbox/driving/-73.989%2C40.733%3B-94%2C40.733.json?access_token=my_access_token&geometries=geojson&overview=full

If you put them in the API playground, you should see a more detailed route for your 2nd Query.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM