Comments (9)
Why does this calculate client-side anyway? We just launched an API for this.
from mapbox-gl-directions.
I'm confused as to why this is necessary at all. mapbox-directions.js doesn't need it.
from mapbox-gl-directions.
Same
from mapbox-gl-directions.
It's calculated to derive the URL query. Given a url like:
/v4/directions/mapbox.driving/
-74.5597381591797,40.12139809056774;
-74.69306607374473,40.031006417727895;
-75.05781808872085,40.11136049688241;
-74.9486688115121,39.92301383728193;
-75.14762445604451,40.02994849538351.json?
It sorts the coordinates between the first(origin) + last(destination). If it's not sorted, the route is returned with the coordinates in the order that they were sent and not - as I could tell - sorted by the most optimized path.
from mapbox-gl-directions.
Yes, and the user inputs waypoints in order, and gets directions in order. This is a directions API, not a traveling-salesman API, and the assumption is that you would want to go to things in the order you type them, rather than an 'optimal' order - people do not plan, for example, roadtrips, based on algorithms.
from mapbox-gl-directions.
Let me be a little more specific. Say I have a route planned with a single waypoint:
Origin = A
Waypoint = C
Destination = B
If I wanted to add another waypoint (D) before the first waypoint I, (as the user) would expect the route to order in this sequence: A -> D -> C -> B.
If I don't sort the order the sequence looks like this: A -> C -> D -> B. which is not the result I would expect.
from mapbox-gl-directions.
You create new waypoints when someone clicks a segment. You would check which segment they clicked to create the waypoint, and place the new waypoint in between its end points.
from mapbox-gl-directions.
Ah that makes sense. I'm creating the directions route as a single LineString when it should be broken into segments.
from mapbox-gl-directions.
💀 going to avoid doing anything weird with waypoint ordering all together.
from mapbox-gl-directions.
Related Issues (20)
- Package import broken without build
- Show autocomplete addresses that are close to the users geolocation or map view HOT 1
- Existing route not found HOT 1
- NODE_ENV is undefined, triggers console error in production HOT 6
- Unable to style line colour/width in Directions HOT 2
- setOrigin and setDestination on click HOT 1
- 3 Issues: (1)Text colour issue + (2)Km Vs. Miles + (3)walking directions appearing in the middle of a lake
- Map SetStyle removes direction polyline HOT 1
- Unable to use with MapBox version v2.6.1 HOT 2
- How do you remove picking custom directions with the cursor?
- Missing new params HOT 1
- visualize waypoints
- visualize instructions past first waypoint
- XMLHttpRequest is not defined HOT 10
- Get duration, distance and weight-name to calculate further
- Error thrown when trying to swap departure and arrival
- [email protected] is not compatible with peer dep [email protected] HOT 8
- Missing TypeScript type definitions for mapbox-gl-directions package
- Get more annotations
- CORS Blocked
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapbox-gl-directions.