0
votes

Maybe you might know this as the plugin and everything looks like abandoned and nobody cares about answering our issues on github.

I am using mapbox-gl-js and mapbox-gl-directions plugins.

mapbox-gl-directions plugin has function addWaypoint and it doesn't have addWaypoint(s). So I can only add one waypoint at a time. So I need for loop my points and call addWaypoint each time. Look what the function(addWaypoint) says in the github's docs:

"Add a waypoint to the route. Note: calling this method requires the map load event to have run."

. So map load event runs and I lose the idea of mapbox gl which is cheaper for pricing. After looking through src code, I can see that it only creates one api call after I set the destination. So I don't understand why the docs say the above thing about map load each time when addWaypoint is called.

Do you think map load event still runs for adding each Waypoint? I'd really appreciate it. Thank you. Also, if the answer is yes, then what's the point of using mapbox-gl-js which states pricing is for map load and not each tile request.

1
My reading of that statement is that you can't run addWaypoint until after the map has loaded. I don't read it that you have to load the map each time. - peeebeee
I think you're correct. My Bad. - Nika Kurashvili

1 Answers

1
votes

@peeebeee is correct, you just need to make sure that you only call mapbox-gl-direction's addWaypoint after the GL JS's Map load event has been called https://docs.mapbox.com/mapbox-gl-js/api/#map.event:load. This is a different thing to the "map load" billing unit.

map.on('load', function () {
  directions.addWaypoint(...)
})