javascriptapimapboxdirectionstransit

Limit possibilities for Mapbox Directions API


I don't have much knowledge of Javascript and I haven't been able to figure out a solution for my problem. I'm making use of the Mapbox Direction API, which currently supports traffic/driving/walking/cycling. I am however interest in an other option; transit, for which I have my own GTSF datasets up and running in a queryable database. Hence; I want to use the code of the Mapbox Direction API and couple it to my own database (in the end, some small steps first..). - Example: https://www.mapbox.com/mapbox-gl-js/example/mapbox-gl-directions/ - Code: https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-directions/v3.1.1/mapbox-gl-directions.js

Does anyone know how (easily) I can edit the Javascript in such a way that; the Start and Destination can ónly be selected based from a pre-defined list.

PS: If anyone has any other idea of creating a javascript layover with a simple list-based Point A to Point B which returns a text-based popup/layover, on mapbox... let me know.


Solution

  • Answer: Disable map-based selections:

        /*case types.ORIGIN_FROM_COORDINATES:
      return Object.assign({}, state, {
        originQueryCoordinates: action.coordinates
      });*/
    
    /*case types.DESTINATION_FROM_COORDINATES:
      return Object.assign({}, state, {
        destinationQueryCoordinates: action.coordinates
      });*/
    

    --

    var MapboxDirections = function () {
    function MapboxDirections(options) {
    _classCallCheck(this, MapboxDirections);
    
    this.actions = (0, _redux.bindActionCreators)(actions, store.dispatch);
    this.actions.setOptions(options || {});
    this.options = options || {};
    
    this.onDragDown = this._onDragDown.bind(this);
    this.onDragMove = this._onDragMove.bind(this);
    this.onDragUp = this._onDragUp.bind(this);
    this.move = this._move.bind(this);
    //this.onClick = this._onClick.bind(this);
    }
    

    To get my own transit-based list I need to create my own database with searchable Json files, as set-up in Mapbox's own API: api.mapbox.com/geocoding/v5/mapbox.places. This is a different question, and I will therefore open a new topic.