Skip to content

Commit

Permalink
Merge pull request #109 from mapbox/bring-back-options
Browse files Browse the repository at this point in the history
bring back the constructor options
  • Loading branch information
mapsam authored Dec 17, 2016
2 parents c69dc0c + d881a7d commit 6b1729a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 34 deletions.
21 changes: 18 additions & 3 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,32 @@ The Directions control

**Parameters**

- `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** no currently accepted options
- `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
- `options.styles` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)]** Override default layer properties of the [directions source](https://github.com/mapbox/mapbox-gl-directions/blob/master/src/directions_style.js). Documentation for each property are specified in the [Mapbox GL Style Reference](https://www.mapbox.com/mapbox-gl-style-spec/).
- `options.accessToken` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Required unless `mapboxgl.accessToken` is set globally (optional, default `null`)
- `options.interactive` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** Enable/Disable mouse or touch interactivity from the plugin (optional, default `true`)
- `options.profile` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Routing profile to use. Options: `driving`, `walking`, `cycling` (optional, default `"driving"`)
- `options.unit` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Measurement system to be used in navigation instructions. Options: `imperial`, `metric` (optional, default `"imperial"`)
- `options.geocoder` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** Pass options available to mapbox-gl-geocoder as [documented here](https://github.com/mapbox/mapbox-gl-geocoder/blob/master/API.md#mapboxglgeocoder).
- `options.controls` **\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]**
- `options.controls.inputs` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** Hide or display the inputs control. (optional, default `true`)
- `options.controls.instructions` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** Hide or display the instructions control. (optional, default `true`)

**Examples**

```javascript
var MapboxDirections = require('../src/index');
var directions = new MapboxDirections({
accessToken: mapboxgl.accessToken
accessToken: 'YOUR-MAPBOX-ACCESS-TOKEN',
unit: 'metric',
profile: 'cycling'
});
map.addControl(directions, 'top-left');
// add to your mapboxgl map
map.addControl(directions);
```

Returns **[MapboxDirections](#mapboxdirections)** `this`

## onRemove

Removes the control from the map it has been added to. This is called by `map.removeControl`,
Expand Down
24 changes: 20 additions & 4 deletions src/directions.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,28 @@ import Instructions from './controls/instructions';
/**
* The Directions control
* @class MapboxDirections
* @param {Object} options no currently accepted options
*
* @param {Object} options
* @param {Array} [options.styles] Override default layer properties of the [directions source](https://github.com/mapbox/mapbox-gl-directions/blob/master/src/directions_style.js). Documentation for each property are specified in the [Mapbox GL Style Reference](https://www.mapbox.com/mapbox-gl-style-spec/).
* @param {String} [options.accessToken=null] Required unless `mapboxgl.accessToken` is set globally
* @param {Boolean} [options.interactive=true] Enable/Disable mouse or touch interactivity from the plugin
* @param {String} [options.profile="driving"] Routing profile to use. Options: `driving`, `walking`, `cycling`
* @param {String} [options.unit="imperial"] Measurement system to be used in navigation instructions. Options: `imperial`, `metric`
* @param {Object} [options.geocoder] Pass options available to mapbox-gl-geocoder as [documented here](https://github.com/mapbox/mapbox-gl-geocoder/blob/master/API.md#mapboxglgeocoder).
* @param {Object} [options.controls]
* @param {Boolean} [options.controls.inputs=true] Hide or display the inputs control.
* @param {Boolean} [options.controls.instructions=true] Hide or display the instructions control.
* @example
* var MapboxDirections = require('../src/index');
* var directions = new MapboxDirections({
* accessToken: mapboxgl.accessToken
* accessToken: 'YOUR-MAPBOX-ACCESS-TOKEN',
* unit: 'metric',
* profile: 'cycling'
* });
* map.addControl(directions, 'top-left');
* // add to your mapboxgl map
* map.addControl(directions);
*
* @return {MapboxDirections} `this`
*/
export default class MapboxDirections {

Expand Down Expand Up @@ -448,7 +464,7 @@ export default class MapboxDirections {
* Removes all routes and waypoints from the map.
*
* @returns {MapboxDirections} this;
*/
*/
removeRoutes() {
this.actions.clearOrigin();
this.actions.clearDestination();
Expand Down
28 changes: 1 addition & 27 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,3 @@
/**
* A directions component using Mapbox Directions API
* @class MapboxDirections
*
* @param {Object} options
* @param {Array} [options.styles] Override default layer properties of the [directions source](https://github.com/mapbox/mapbox-gl-directions/blob/master/src/directions_style.js). Documentation for each property are specified in the [Mapbox GL Style Reference](https://www.mapbox.com/mapbox-gl-style-spec/).
* @param {String} [options.accessToken=null] Required unless `mapboxgl.accessToken` is set globally
* @param {Boolean} [options.interactive=true] Enable/Disable mouse or touch interactivity from the plugin
* @param {String} [options.profile="driving"] Routing profile to use. Options: `driving`, `walking`, `cycling`
* @param {String} [options.unit="imperial"] Measurement system to be used in navigation instructions. Options: `imperial`, `metric`
* @param {Object} [options.geocoder] Pass options available to mapbox-gl-geocoder as [documented here](https://github.com/mapbox/mapbox-gl-geocoder/blob/master/API.md#mapboxglgeocoder).
* @param {Object} [options.controls]
* @param {Boolean} [options.controls.inputs=true] Hide or display the inputs control.
* @param {Boolean} [options.controls.instructions=true] Hide or display the instructions control.
* @example
* var MapboxDirections = require('../src/index');
* var directions = new MapboxDirections({
* accessToken: 'YOUR-MAPBOX-ACCESS-TOKEN',
* unit: 'metric',
* profile: 'cycling'
* });
* // add to your mapboxgl map
* map.addControl(directions);
*
* @return {MapboxDirections} `this`
*/
import MapboxDirections from './directions';

module.exports = MapboxDirections;
module.exports = MapboxDirections;

0 comments on commit 6b1729a

Please sign in to comment.