diff --git a/CHANGELOG.md b/CHANGELOG.md
index 894cc200..be7324ef 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,9 +14,12 @@ way to update this template, but currently, we follow a pattern:
## Upcoming version 2019-XX-XX
+- [change] Mapbox library dependencies updated to v1.0.0.
+ [#1099](https://github.com/sharetribe/flex-template-web/pull/1099)
+ - Note: Mapbox changed their pricing scheme!
- [fix] missing provider information (like SSN in US), might cause payment to fail on
`CheckoutPage`. This improves related error message.
- [#10967](https://github.com/sharetribe/flex-template-web/pull/1097)
+ [#1098](https://github.com/sharetribe/flex-template-web/pull/1098)
- [fix] Menu needs to wait for mounting to calculate dimensions properly.
[#1096](https://github.com/sharetribe/flex-template-web/pull/1096)
- [fix] Renamed Component.example.css files to ComponentExample.css to fix bug introduced in one of
diff --git a/public/index.html b/public/index.html
index 672374cc..db42bf79 100644
--- a/public/index.html
+++ b/public/index.html
@@ -149,8 +149,8 @@
We didn't bundle it to the main app since it would unnecessarily slow down initial rendering.
-->
-
-
+
+
diff --git a/public/static/scripts/mapbox/mapbox-sdk.js b/public/static/scripts/mapbox/mapbox-sdk.js
index 586259d7..4a329888 100644
--- a/public/static/scripts/mapbox/mapbox-sdk.js
+++ b/public/static/scripts/mapbox/mapbox-sdk.js
@@ -1,4 +1,4 @@
-// version 0.5.0
+// version 0.6.0
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
@@ -371,163 +371,163 @@
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function createCommonjsModule(fn, module) {
- return module = { exports: {} }, fn(module, module.exports), module.exports;
+ return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var base64 = createCommonjsModule(function (module, exports) {
(function(root) {
- // Detect free variables `exports`.
- var freeExports = exports;
+ // Detect free variables `exports`.
+ var freeExports = exports;
- // Detect free variable `module`.
- var freeModule = module &&
- module.exports == freeExports && module;
+ // Detect free variable `module`.
+ var freeModule = module &&
+ module.exports == freeExports && module;
- // Detect free variable `global`, from Node.js or Browserified code, and use
- // it as `root`.
- var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal;
- if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
- root = freeGlobal;
- }
+ // Detect free variable `global`, from Node.js or Browserified code, and use
+ // it as `root`.
+ var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal;
+ if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
+ root = freeGlobal;
+ }
- /*--------------------------------------------------------------------------*/
+ /*--------------------------------------------------------------------------*/
- var InvalidCharacterError = function(message) {
- this.message = message;
- };
- InvalidCharacterError.prototype = new Error;
- InvalidCharacterError.prototype.name = 'InvalidCharacterError';
+ var InvalidCharacterError = function(message) {
+ this.message = message;
+ };
+ InvalidCharacterError.prototype = new Error;
+ InvalidCharacterError.prototype.name = 'InvalidCharacterError';
- var error = function(message) {
- // Note: the error messages used throughout this file match those used by
- // the native `atob`/`btoa` implementation in Chromium.
- throw new InvalidCharacterError(message);
- };
+ var error = function(message) {
+ // Note: the error messages used throughout this file match those used by
+ // the native `atob`/`btoa` implementation in Chromium.
+ throw new InvalidCharacterError(message);
+ };
- var TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
- // http://whatwg.org/html/common-microsyntaxes.html#space-character
- var REGEX_SPACE_CHARACTERS = /[\t\n\f\r ]/g;
+ var TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
+ // http://whatwg.org/html/common-microsyntaxes.html#space-character
+ var REGEX_SPACE_CHARACTERS = /[\t\n\f\r ]/g;
- // `decode` is designed to be fully compatible with `atob` as described in the
- // HTML Standard. http://whatwg.org/html/webappapis.html#dom-windowbase64-atob
- // The optimized base64-decoding algorithm used is based on @atk’s excellent
- // implementation. https://gist.github.com/atk/1020396
- var decode = function(input) {
- input = String(input)
- .replace(REGEX_SPACE_CHARACTERS, '');
- var length = input.length;
- if (length % 4 == 0) {
- input = input.replace(/==?$/, '');
- length = input.length;
- }
- if (
- length % 4 == 1 ||
- // http://whatwg.org/C#alphanumeric-ascii-characters
- /[^+a-zA-Z0-9/]/.test(input)
- ) {
- error(
- 'Invalid character: the string to be decoded is not correctly encoded.'
- );
- }
- var bitCounter = 0;
- var bitStorage;
- var buffer;
- var output = '';
- var position = -1;
- while (++position < length) {
- buffer = TABLE.indexOf(input.charAt(position));
- bitStorage = bitCounter % 4 ? bitStorage * 64 + buffer : buffer;
- // Unless this is the first of a group of 4 characters…
- if (bitCounter++ % 4) {
- // …convert the first 8 bits to a single ASCII character.
- output += String.fromCharCode(
- 0xFF & bitStorage >> (-2 * bitCounter & 6)
- );
- }
- }
- return output;
- };
+ // `decode` is designed to be fully compatible with `atob` as described in the
+ // HTML Standard. http://whatwg.org/html/webappapis.html#dom-windowbase64-atob
+ // The optimized base64-decoding algorithm used is based on @atk’s excellent
+ // implementation. https://gist.github.com/atk/1020396
+ var decode = function(input) {
+ input = String(input)
+ .replace(REGEX_SPACE_CHARACTERS, '');
+ var length = input.length;
+ if (length % 4 == 0) {
+ input = input.replace(/==?$/, '');
+ length = input.length;
+ }
+ if (
+ length % 4 == 1 ||
+ // http://whatwg.org/C#alphanumeric-ascii-characters
+ /[^+a-zA-Z0-9/]/.test(input)
+ ) {
+ error(
+ 'Invalid character: the string to be decoded is not correctly encoded.'
+ );
+ }
+ var bitCounter = 0;
+ var bitStorage;
+ var buffer;
+ var output = '';
+ var position = -1;
+ while (++position < length) {
+ buffer = TABLE.indexOf(input.charAt(position));
+ bitStorage = bitCounter % 4 ? bitStorage * 64 + buffer : buffer;
+ // Unless this is the first of a group of 4 characters…
+ if (bitCounter++ % 4) {
+ // …convert the first 8 bits to a single ASCII character.
+ output += String.fromCharCode(
+ 0xFF & bitStorage >> (-2 * bitCounter & 6)
+ );
+ }
+ }
+ return output;
+ };
- // `encode` is designed to be fully compatible with `btoa` as described in the
- // HTML Standard: http://whatwg.org/html/webappapis.html#dom-windowbase64-btoa
- var encode = function(input) {
- input = String(input);
- if (/[^\0-\xFF]/.test(input)) {
- // Note: no need to special-case astral symbols here, as surrogates are
- // matched, and the input is supposed to only contain ASCII anyway.
- error(
- 'The string to be encoded contains characters outside of the ' +
- 'Latin1 range.'
- );
- }
- var padding = input.length % 3;
- var output = '';
- var position = -1;
- var a;
- var b;
- var c;
- var buffer;
- // Make sure any padding is handled outside of the loop.
- var length = input.length - padding;
+ // `encode` is designed to be fully compatible with `btoa` as described in the
+ // HTML Standard: http://whatwg.org/html/webappapis.html#dom-windowbase64-btoa
+ var encode = function(input) {
+ input = String(input);
+ if (/[^\0-\xFF]/.test(input)) {
+ // Note: no need to special-case astral symbols here, as surrogates are
+ // matched, and the input is supposed to only contain ASCII anyway.
+ error(
+ 'The string to be encoded contains characters outside of the ' +
+ 'Latin1 range.'
+ );
+ }
+ var padding = input.length % 3;
+ var output = '';
+ var position = -1;
+ var a;
+ var b;
+ var c;
+ var buffer;
+ // Make sure any padding is handled outside of the loop.
+ var length = input.length - padding;
- while (++position < length) {
- // Read three bytes, i.e. 24 bits.
- a = input.charCodeAt(position) << 16;
- b = input.charCodeAt(++position) << 8;
- c = input.charCodeAt(++position);
- buffer = a + b + c;
- // Turn the 24 bits into four chunks of 6 bits each, and append the
- // matching character for each of them to the output.
- output += (
- TABLE.charAt(buffer >> 18 & 0x3F) +
- TABLE.charAt(buffer >> 12 & 0x3F) +
- TABLE.charAt(buffer >> 6 & 0x3F) +
- TABLE.charAt(buffer & 0x3F)
- );
- }
+ while (++position < length) {
+ // Read three bytes, i.e. 24 bits.
+ a = input.charCodeAt(position) << 16;
+ b = input.charCodeAt(++position) << 8;
+ c = input.charCodeAt(++position);
+ buffer = a + b + c;
+ // Turn the 24 bits into four chunks of 6 bits each, and append the
+ // matching character for each of them to the output.
+ output += (
+ TABLE.charAt(buffer >> 18 & 0x3F) +
+ TABLE.charAt(buffer >> 12 & 0x3F) +
+ TABLE.charAt(buffer >> 6 & 0x3F) +
+ TABLE.charAt(buffer & 0x3F)
+ );
+ }
- if (padding == 2) {
- a = input.charCodeAt(position) << 8;
- b = input.charCodeAt(++position);
- buffer = a + b;
- output += (
- TABLE.charAt(buffer >> 10) +
- TABLE.charAt((buffer >> 4) & 0x3F) +
- TABLE.charAt((buffer << 2) & 0x3F) +
- '='
- );
- } else if (padding == 1) {
- buffer = input.charCodeAt(position);
- output += (
- TABLE.charAt(buffer >> 2) +
- TABLE.charAt((buffer << 4) & 0x3F) +
- '=='
- );
- }
+ if (padding == 2) {
+ a = input.charCodeAt(position) << 8;
+ b = input.charCodeAt(++position);
+ buffer = a + b;
+ output += (
+ TABLE.charAt(buffer >> 10) +
+ TABLE.charAt((buffer >> 4) & 0x3F) +
+ TABLE.charAt((buffer << 2) & 0x3F) +
+ '='
+ );
+ } else if (padding == 1) {
+ buffer = input.charCodeAt(position);
+ output += (
+ TABLE.charAt(buffer >> 2) +
+ TABLE.charAt((buffer << 4) & 0x3F) +
+ '=='
+ );
+ }
- return output;
- };
+ return output;
+ };
- var base64 = {
- 'encode': encode,
- 'decode': decode,
- 'version': '0.1.0'
- };
+ var base64 = {
+ 'encode': encode,
+ 'decode': decode,
+ 'version': '0.1.0'
+ };
- // Some AMD build optimizers, like r.js, check for specific condition patterns
- // like the following:
- if (freeExports && !freeExports.nodeType) {
- if (freeModule) { // in Node.js or RingoJS v0.8.0+
- freeModule.exports = base64;
- } else { // in Narwhal or RingoJS v0.7.0-
- for (var key in base64) {
- base64.hasOwnProperty(key) && (freeExports[key] = base64[key]);
- }
- }
- } else { // in Rhino or a web browser
- root.base64 = base64;
- }
+ // Some AMD build optimizers, like r.js, check for specific condition patterns
+ // like the following:
+ if (freeExports && !freeExports.nodeType) {
+ if (freeModule) { // in Node.js or RingoJS v0.8.0+
+ freeModule.exports = base64;
+ } else { // in Narwhal or RingoJS v0.7.0-
+ for (var key in base64) {
+ base64.hasOwnProperty(key) && (freeExports[key] = base64[key]);
+ }
+ }
+ } else { // in Rhino or a web browser
+ root.base64 = base64;
+ }
}(commonjsGlobal));
});
@@ -1361,8 +1361,8 @@
var toString = Object.prototype.toString;
var isPlainObj = function (x) {
- var prototype;
- return toString.call(x) === '[object Object]' && (prototype = Object.getPrototypeOf(x), prototype === null || prototype === Object.getPrototypeOf({}));
+ var prototype;
+ return toString.call(x) === '[object Object]' && (prototype = Object.getPrototypeOf(x), prototype === null || prototype === Object.getPrototypeOf({}));
};
/**
@@ -1842,16 +1842,29 @@
* Datasets API service.
*
* Learn more about this service and its responses in
- * [the HTTP service documentation](https://www.mapbox.com/api-documentation/#datasets).
+ * [the HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#datasets).
*/
var Datasets = {};
/**
* List datasets in your account.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/#list-datasets).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#list-datasets).
*
* @return {MapiRequest}
+ *
+ * @example
+ * datasetsClient.listDatasets()
+ * .send()
+ * .then(response => {
+ * const datasets = response.body;
+ * });
+ *
+ * @example
+ * datasetsClient.listDatasets()
+ * .eachPage((error, response, next) => {
+ * // Handle error or response and call next.
+ * });
*/
Datasets.listDatasets = function() {
return this.client.createRequest({
@@ -1863,12 +1876,22 @@
/**
* Create a new, empty dataset.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/#create-dataset).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#create-a-dataset).
*
* @param {Object} config
* @param {string} [config.name]
* @param {string} [config.description]
* @return {MapiRequest}
+ *
+ * @example
+ * datasetsClient.createDataset({
+ * name: 'example',
+ * description: 'An example dataset'
+ * })
+ * .send()
+ * .then(response => {
+ * const datasetMetadata = response.body;
+ * });
*/
Datasets.createDataset = function(config) {
validator.assertShape({
@@ -1886,11 +1909,20 @@
/**
* Get metadata about a dataset.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/#retrieve-a-dataset).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#retrieve-a-dataset).
*
* @param {Object} config
* @param {string} config.datasetId
* @return {MapiRequest}
+ *
+ * @example
+ * datasetsClient.getMetadata({
+ * datasetId: 'dataset-id'
+ * })
+ * .send()
+ * .then(response => {
+ * const datasetMetadata = response.body;
+ * })
*/
Datasets.getMetadata = function(config) {
validator.assertShape({
@@ -1908,13 +1940,23 @@
/**
* Update user-defined properties of a dataset's metadata.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/#update-a-dataset).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#update-a-dataset).
*
* @param {Object} config
* @param {string} config.datasetId
* @param {string} [config.name]
* @param {string} [config.description]
* @return {MapiRequest}
+ *
+ * @example
+ * datasetsClient.updateMetadata({
+ * datasetId: 'dataset-id',
+ * name: 'foo'
+ * })
+ * .send()
+ * .then(response => {
+ * const datasetMetadata = response.body;
+ * });
*/
Datasets.updateMetadata = function(config) {
validator.assertShape({
@@ -1934,11 +1976,20 @@
/**
* Delete a dataset, including all features it contains.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/#delete-a-dataset).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#delete-a-dataset).
*
* @param {Object} config
* @param {string} config.datasetId
* @return {MapiRequest}
+ *
+ * @example
+ * datasetsClient.deleteDataset({
+ * datasetId: 'dataset-id'
+ * })
+ * .send()
+ * .then(response => {
+ * // Dataset is successfully deleted.
+ * });
*/
Datasets.deleteDataset = function(config) {
validator.assertShape({
@@ -1958,7 +2009,7 @@
* This endpoint supports pagination. Use `MapiRequest#eachPage` or manually specify
* the `limit` and `start` options.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/#list-features).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#list-features).
*
* @param {Object} config
* @param {string} config.datasetId
@@ -1966,6 +2017,15 @@
* @param {string} [config.start] - The ID of the feature from which the listing should
* start.
* @return {MapiRequest}
+ *
+ * @example
+ * datasetsClient.listFeatures({
+ * datasetId: 'dataset-id'
+ * })
+ * .send()
+ * .then(response => {
+ * const features = response.body;
+ * });
*/
Datasets.listFeatures = function(config) {
validator.assertShape({
@@ -1985,7 +2045,7 @@
/**
* Add a feature to a dataset or update an existing one.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/#insert-or-update-a-feature).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#insert-or-update-a-feature).
*
* @param {Object} config
* @param {string} config.datasetId
@@ -1993,6 +2053,24 @@
* @param {Object} config.feature - Valid GeoJSON that is not a `FeatureCollection`.
* If the feature has a top-level `id` property, it must match the `featureId` you specify.
* @return {MapiRequest}
+ *
+ * @example
+ * datasetsClient.putFeature({
+ * datasetId: 'dataset-id',
+ * featureId: 'null-island',
+ * feature: {
+ * "type": "Feature",
+ * "properties": { "name": "Null Island" },
+ * "geometry": {
+ * "type": "Point",
+ * "coordinates": [0, 0]
+ * }
+ * }
+ * })
+ * .send()
+ * .then(response => {
+ * const feature = response.body;
+ * });
*/
Datasets.putFeature = function(config) {
validator.assertShape({
@@ -2019,12 +2097,22 @@
/**
* Get a feature in a dataset.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/#retrieve-a-feature).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#retrieve-a-feature).
*
* @param {Object} config
* @param {string} config.datasetId
* @param {string} config.featureId
* @return {MapiRequest}
+ *
+ * @example
+ * datasetsClient.getFeature({
+ * datasetId: 'dataset-id',
+ * featureId: 'feature-id'
+ * })
+ * .send()
+ * .then(response => {
+ * const feature = response.body;
+ * });
*/
Datasets.getFeature = function(config) {
validator.assertShape({
@@ -2042,12 +2130,22 @@
/**
* Delete a feature in a dataset.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/#delete-a-feature).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#delete-a-feature).
*
* @param {Object} config
* @param {string} config.datasetId
* @param {string} config.featureId
* @return {MapiRequest}
+ *
+ * @example
+ * datasetsClient.deleteFeature({
+ * datasetId: 'dataset-id',
+ * featureId: 'feature-id'
+ * })
+ * .send()
+ * .then(response => {
+ * // Feature is successfully deleted.
+ * });
*/
Datasets.deleteFeature = function(config) {
validator.assertShape({
@@ -2099,14 +2197,14 @@
* Directions API service.
*
* Learn more about this service and its responses in
- * [the HTTP service documentation](https://www.mapbox.com/api-documentation/#directions).
+ * [the HTTP service documentation](https://www.mapbox.com/api-documentation/navigation/#directions).
*/
var Directions = {};
/**
* Get directions.
*
- * Please read [the full HTTP service documentation](https://www.mapbox.com/api-documentation/#directions)
+ * Please read [the full HTTP service documentation](https://www.mapbox.com/api-documentation/navigation/#directions)
* to understand all of the available options.
*
* @param {Object} config
@@ -2119,13 +2217,35 @@
* @param {string} [config.exclude] - Exclude certain road types from routing. See HTTP service documentation for options.
* @param {'geojson'|'polyline'|'polyline6'} [config.geometries="polyline"] - Format of the returned geometry.
* @param {string} [config.language="en"] - Language of returned turn-by-turn text instructions.
- * See options listed in [the HTTP service documentation](https://www.mapbox.com/api-documentation/#instructions-languages).
+ * See options listed in [the HTTP service documentation](https://www.mapbox.com/api-documentation/navigation/#instructions-languages).
* @param {'simplified'|'full'|'false'} [config.overview="simplified"] - Type of returned overview geometry.
* @param {boolean} [config.roundaboutExits=false] - Emit insbtructions at roundabout exits.
* @param {boolean} [config.steps=false] - Whether to return steps and turn-by-turn instructions.
* @param {boolean} [config.voiceInstructions=false] - Whether or not to return SSML marked-up text for voice guidance along the route.
* @param {'imperial'|'metric'} [config.voiceUnits="imperial"] - Which type of units to return in the text for voice instructions.
* @return {MapiRequest}
+ *
+ * @example
+ * directionsClient.getDirections({
+ * profile: 'driving-traffic',
+ * waypoints: [
+ * {
+ * coordinates: [13.4301, 52.5109],
+ * approach: 'unrestricted'
+ * },
+ * {
+ * coordinates: [13.4265, 52.508]
+ * },
+ * {
+ * coordinates: [13.4194, 52.5072],
+ * bearing: [100, 60]
+ * }
+ * ]
+ * })
+ * .send()
+ * .then(response => {
+ * const directions = response.body;
+ * });
*/
Directions.getDirections = function(config) {
validator.assertShape({
@@ -2254,7 +2374,7 @@
* Geocoding API service.
*
* Learn more about this service and its responses in
- * [the HTTP service documentation](https://www.mapbox.com/api-documentation/#geocoding).
+ * [the HTTP service documentation](https://www.mapbox.com/api-documentation/search/#geocoding).
*/
var Geocoding = {};
@@ -2274,7 +2394,7 @@
/**
* Search for a place.
*
- * See the [public documentation](https://www.mapbox.com/api-documentation/#search-for-places).
+ * See the [public documentation](https://www.mapbox.com/api-documentation/search/#forward-geocoding).
*
* @param {Object} config
* @param {string} config.query - A place name.
@@ -2290,6 +2410,47 @@
* Options are [IETF language tags](https://en.wikipedia.org/wiki/IETF_language_tag) comprised of a mandatory
* [ISO 639-1 language code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) and optionally one or more IETF subtags for country or script.
* @return {MapiRequest}
+ *
+ * @example
+ * geocodingClient.forwardGeocode({
+ * query: 'Paris, France',
+ * limit: 2
+ * })
+ * .send()
+ * .then(response => {
+ * const match = response.body;
+ * });
+ *
+ * @example
+ * // geocoding with proximity
+ * geocodingClient.forwardGeocode({
+ * query: 'Paris, France',
+ * proximity: [-95.4431142, 33.6875431]
+ * })
+ * .send()
+ * .then(response => {
+ * const match = response.body;
+ * });
+ *
+ * // geocoding with countries
+ * geocodingClient.forwardGeocode({
+ * query: 'Paris, France',
+ * countries: ['fr']
+ * })
+ * .send()
+ * .then(response => {
+ * const match = response.body;
+ * });
+ *
+ * // geocoding with bounding box
+ * geocodingClient.forwardGeocode({
+ * query: 'Paris, France',
+ * bbox: [2.14, 48.72, 2.55, 48.96]
+ * })
+ * .send()
+ * .then(response => {
+ * const match = response.body;
+ * });
*/
Geocoding.forwardGeocode = function(config) {
validator.assertShape({
@@ -2331,7 +2492,7 @@
/**
* Search for places near coordinates.
*
- * See the [public documentation](https://www.mapbox.com/api-documentation/#retrieve-places-near-a-location).
+ * See the [public documentation](https://www.mapbox.com/api-documentation/search/#reverse-geocoding).
*
* @param {Object} config
* @param {Coordinates} config.query - Coordinates at which features will be searched.
@@ -2346,6 +2507,17 @@
* [ISO 639-1 language code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) and optionally one or more IETF subtags for country or script.
* @param {'distance'|'score'} [config.reverseMode='distance'] - Set the factors that are used to sort nearby results.
* @return {MapiRequest}
+ *
+ * @example
+ * geocodingClient.reverseGeocode({
+ * query: [-95.4431142, 33.6875431],
+ * limit: 2
+ * })
+ * .send()
+ * .then(response => {
+ * // GeoJSON document with geocoding matches
+ * const match = response.body;
+ * });
*/
Geocoding.reverseGeocode = function(config) {
validator.assertShape({
@@ -2389,7 +2561,7 @@
* Map Matching API service.
*
* Learn more about this service and its responses in
- * [the HTTP service documentation](https://www.mapbox.com/api-documentation/#map-matching).
+ * [the HTTP service documentation](https://www.mapbox.com/api-documentation/navigation/#map-matching).
*/
var MapMatching = {};
@@ -2402,11 +2574,47 @@
* @param {Array<'duration'|'distance'|'speed'>} [config.annotations] - Specify additional metadata that should be returned.
* @param {'geojson'|'polyline'|'polyline6'} [config.geometries="polyline"] - Format of the returned geometry.
* @param {string} [config.language="en"] - Language of returned turn-by-turn text instructions.
- * See [supported languages](https://www.mapbox.com/api-documentation/#instructions-languages).
+ * See [supported languages](https://www.mapbox.com/api-documentation/navigation/#instructions-languages).
* @param {'simplified'|'full'|'false'} [config.overview="simplified"] - Type of returned overview geometry.
* @param {boolean} [config.steps=false] - Whether to return steps and turn-by-turn instructions.
* @param {boolean} [config.tidy=false] - Whether or not to transparently remove clusters and re-sample traces for improved map matching results.
* @return {MapiRequest}
+ *
+ * @example
+ * mapMatchingClient.getMatch({
+ * points: [
+ * {
+ * coordinates: [-117.17283, 32.712041],
+ * approach: 'curb'
+ * },
+ * {
+ * coordinates: [-117.17291, 32.712256],
+ * isWaypoint: false
+ * },
+ * {
+ * coordinates: [-117.17292, 32.712444]
+ * },
+ * {
+ * coordinates: [-117.172922, 32.71257],
+ * waypointName: 'point-a',
+ * approach: 'unrestricted'
+ * },
+ * {
+ * coordinates: [-117.172985, 32.7126]
+ * },
+ * {
+ * coordinates: [-117.173143, 32.712597]
+ * },
+ * {
+ * coordinates: [-117.173345, 32.712546]
+ * }
+ * ],
+ * tidy: false,
+ * })
+ * .send()
+ * .then(response => {
+ * const matching = response.body;
+ * })
*/
MapMatching.getMatch = function(config) {
validator.assertShape({
@@ -2553,7 +2761,7 @@
* Map Matching API service.
*
* Learn more about this service and its responses in
- * [the HTTP service documentation](https://www.mapbox.com/api-documentation/#matrix).
+ * [the HTTP service documentation](https://www.mapbox.com/api-documentation/navigation/#matrix).
*/
var Matrix = {};
@@ -2567,6 +2775,30 @@
* @param {'all'|Array} [config.destinations] - Use coordinates with given index as destinations.
* @param {Array<'distance'|'duration'>} [config.annotations] - Used to specify resulting matrices.
* @return {MapiRequest}
+ *
+ * @example
+ * matrixClient.getMatrix({
+ * points: [
+ * {
+ * coordinates: [2.2, 1.1]
+ * },
+ * {
+ * coordinates: [2.2, 1.1],
+ * approach: 'curb'
+ * },
+ * {
+ * coordinates: [3.2, 1.1]
+ * },
+ * {
+ * coordinates: [4.2, 1.1]
+ * }
+ * ],
+ * profile: 'walking'
+ * })
+ * .send()
+ * .then(response => {
+ * const matrix = response.body;
+ * });
*/
Matrix.getMatrix = function(config) {
validator.assertShape({
@@ -2648,14 +2880,14 @@
* Optimization API service.
*
* Learn more about this service and its responses in
- * [the HTTP service documentation](https://www.mapbox.com/api-documentation/#optimization).
+ * [the HTTP service documentation](https://www.mapbox.com/api-documentation/navigation/#optimization).
*/
var Optimization = {};
/**
* Get a duration-optimized route.
*
- * Please read [the full HTTP service documentation](https://www.mapbox.com/api-documentation/#optimization)
+ * Please read [the full HTTP service documentation](https://www.mapbox.com/api-documentation/navigation/#optimization)
* to understand all of the available options.
*
* @param {Object} config
@@ -2666,7 +2898,7 @@
* @param {Array} [config.distributions] - An ordered array of [`Distribution`](#distribution) objects, each of which includes a `pickup` and `dropoff` property. `pickup` and `dropoff` properties correspond to an index in the OptimizationWaypoint array.
* @param {'geojson'|'polyline'|'polyline6'} [config.geometries="polyline"] - Format of the returned geometries.
* @param {string} [config.language="en"] - Language of returned turn-by-turn text instructions.
- * See options listed in [the HTTP service documentation](https://www.mapbox.com/api-documentation/#instructions-languages).
+ * See options listed in [the HTTP service documentation](https://www.mapbox.com/api-documentation/navigation/#instructions-languages).
* @param {'simplified'|'full'|'false'} [config.overview="simplified"] - Type of returned overview geometry.
* @param {boolean} [config.roundtrip=true] - Specifies whether the trip should complete by returning to the first location.
* @param {'any'|'first'} [config.source="any"] - To begin the route, start either from the first coordinate or let the Optimization API choose.
@@ -2965,7 +3197,7 @@
* Static API service.
*
* Learn more about this service and its responses in
- * [the HTTP service documentation](https://www.mapbox.com/api-documentation/#static).
+ * [the HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#static).
*/
var Static = {};
@@ -3005,6 +3237,85 @@
* @param {boolean} [config.logo=true] - Whether there is a Mapbox logo
* on the map image.
* @return {MapiRequest}
+ *
+ * @example
+ * staticClient.getStaticImage({
+ * ownerId: 'mapbox',
+ * styleId: 'streets-v11',
+ * width: 200,
+ * height: 300,
+ * position: {
+ * coordinates: [12, 13],
+ * zoom: 4
+ * }
+ * })
+ * .send()
+ * .then(response => {
+ * const image = response.body;
+ * });
+ *
+ * @example
+ * staticClient.getStaticImage({
+ * ownerId: 'mapbox',
+ * styleId: 'streets-v11',
+ * width: 200,
+ * height: 300,
+ * position: {
+ * coordinates: [12, 13],
+ * zoom: 3
+ * },
+ * overlays: [
+ * // Simple markers.
+ * {
+ * marker: {
+ * coordinates: [12.2, 12.8]
+ * }
+ * },
+ * {
+ * marker: {
+ * size: 'large',
+ * coordinates: [14, 13.2],
+ * label: 'm',
+ * color: '#000'
+ * }
+ * },
+ * {
+ * marker: {
+ * coordinates: [15, 15.2],
+ * label: 'airport',
+ * color: '#ff0000'
+ * }
+ * },
+ * // Custom marker
+ * {
+ * marker: {
+ * coordinates: [10, 11],
+ * url: 'https://upload.wikimedia.org/wikipedia/commons/6/6f/0xff_timetracker.png'
+ * }
+ * }
+ * ]
+ * })
+ * .send()
+ * .then(response => {
+ * const image = response.body;
+ * });
+ *
+ * @example
+ * // To get the URL instead of the image, create a request
+ * // and get its URL without sending it.
+ * const request = staticClient
+ * .getStaticImage({
+ * ownerId: 'mapbox',
+ * styleId: 'streets-v11',
+ * width: 200,
+ * height: 300,
+ * position: {
+ * coordinates: [12, 13],
+ * zoom: 4
+ * }
+ * });
+ * const staticImageUrl = request.url();
+ * // Now you can open staticImageUrl in a browser.
*/
Static.getStaticImage = function(config) {
validator.assertShape({
@@ -3217,19 +3528,28 @@
* Styles API service.
*
* Learn more about this service and its responses in
- * [the HTTP service documentation](https://www.mapbox.com/api-documentation/#styles).
+ * [the HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#styles).
*/
var Styles = {};
/**
* Get a style.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/#retrieve-a-style).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#retrieve-a-style).
*
* @param {Object} config
* @param {string} config.styleId
* @param {string} [config.ownerId]
* @return {MapiRequest}
+ *
+ * @example
+ * stylesClient.getStyle({
+ * styleId: 'style-id'
+ * })
+ * .send()
+ * .then(response => {
+ * const style = response.body;
+ * });
*/
Styles.getStyle = function(config) {
validator.assertShape({
@@ -3247,12 +3567,28 @@
/**
* Create a style.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/#create-a-style).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#create-a-style).
*
* @param {Object} config
* @param {Object} config.style - Stylesheet JSON object.
* @param {string} [config.ownerId]
* @return {MapiRequest}
+ *
+ * @example
+ * stylesClient.createStyle({
+ * style: {
+ * version: 8,
+ * name: "My Awesome Style",
+ * metadata: {},
+ * sources: {},
+ * layers: [],
+ * glyphs: "mapbox://fonts/{owner}/{fontstack}/{range}.pbf"
+ * }
+ * })
+ * .send()
+ * .then(response => {
+ * const style = response.body;
+ * });
*/
Styles.createStyle = function(config) {
validator.assertShape({
@@ -3271,7 +3607,7 @@
/**
* Update a style.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/#update-a-style).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#update-a-style).
*
* @param {Object} config
* @param {string} config.styleId
@@ -3280,6 +3616,23 @@
* known update. Passed as 'If-Unmodified-Since' HTTP header.
* @param {string} [config.ownerId]
* @return {MapiRequest}
+ *
+ * @example
+ * stylesClient.updateStyle({
+ * styleId: 'style-id',
+ * style: {
+ * version: 8,
+ * name: 'My Awesome Style',
+ * metadata: {},
+ * sources: {},
+ * layers: [],
+ * glyphs: 'mapbox://fonts/{owner}/{fontstack}/{range}.pbf'
+ * }
+ * })
+ * .send()
+ * .then(response => {
+ * const style = response.body;
+ * });
*/
Styles.updateStyle = function(config) {
validator.assertShape({
@@ -3311,6 +3664,15 @@
* @param {string} config.styleId
* @param {string} [config.ownerId]
* @return {MapiRequest}
+ *
+ * @example
+ * stylesClient.deleteStyle({
+ * styleId: 'style-id'
+ * })
+ * .send()
+ * .then(response => {
+ * // delete successful
+ * });
*/
Styles.deleteStyle = function(config) {
validator.assertShape({
@@ -3332,6 +3694,13 @@
* @param {string} [config.start] - The style ID to start at, for paginated results.
* @param {string} [config.ownerId]
* @return {MapiRequest}
+ *
+ * @example
+ * stylesClient.listStyles()
+ * .send()
+ * .then(response => {
+ * const styles = response.body;
+ * });
*/
Styles.listStyles = function(config) {
config = config || {};
@@ -3361,6 +3730,19 @@
* @param {UploadableFile} config.file - An SVG file.
* @param {string} [config.ownerId]
* @return {MapiRequest}
+ *
+ * @example
+ * stylesClient.putStyleIcon({
+ * styleId: 'foo',
+ * iconId: 'bar',
+ * // The string filename value works in Node.
+ * // In the browser, provide a Blob.
+ * file: 'path/to/file.svg'
+ * })
+ * .send()
+ * .then(response => {
+ * const newSprite = response.body;
+ * });
*/
Styles.putStyleIcon = function(config) {
validator.assertShape({
@@ -3386,6 +3768,16 @@
* @param {string} config.iconId
* @param {string} [config.ownerId]
* @return {MapiRequest}
+ *
+ * @example
+ * stylesClient.deleteStyleIcon({
+ * styleId: 'foo',
+ * iconId: 'bar'
+ * })
+ * .send()
+ * .then(response => {
+ * // delete successful
+ * });
*/
Styles.deleteStyleIcon = function(config) {
validator.assertShape({
@@ -3404,7 +3796,7 @@
/**
* Get a style sprite's image or JSON document.
*
- * See [the corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/?language=JavaScript#retrieve-a-sprite-image-or-json).
+ * See [the corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#retrieve-a-sprite-image-or-json).
*
* @param {Object} config
* @param {string} config.styleId
@@ -3413,6 +3805,17 @@
* resolution.
* @param {string} [config.ownerId]
* @return {MapiRequest}
+ *
+ * @example
+ * stylesClient.getStyleSprite({
+ * format: 'json',
+ * styleId: 'foo',
+ * highRes: true
+ * })
+ * .send()
+ * .then(response => {
+ * const sprite = response.body;
+ * });
*/
Styles.getStyleSprite = function(config) {
validator.assertShape({
@@ -3437,7 +3840,7 @@
/**
* Get a font glyph range.
*
- * See [the corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/?language=JavaScript#retrieve-font-glyph-ranges).
+ * See [the corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#retrieve-font-glyph-ranges).
*
* @param {Object} config
* @param {string|Array} config.fonts - An array of font names.
@@ -3446,6 +3849,17 @@
* typically equivalent to`config.start + 255`.
* @param {string} [config.ownerId]
* @return {MapiRequest}
+ *
+ * @example
+ * stylesClient.getFontGlyphRange({
+ * fonts: 'Arial Unicode',
+ * start: 0,
+ * end: 255
+ * })
+ * .send()
+ * .then(response => {
+ * const glyph = response.body;
+ * });
*/
Styles.getFontGlyphRange = function(config) {
validator.assertShape({
@@ -3470,7 +3884,7 @@
/**
* Get embeddable HTML displaying a map.
*
- * See [the corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/?language=JavaScript#embed-a-style).
+ * See [the corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#request-embeddable-html).
*
* @param {Object} config
* @param {string} styleId
@@ -3513,7 +3927,7 @@
* Tilequery API service.
*
* Learn more about this service and its responses in
- * [the HTTP service documentation](https://www.mapbox.com/api-documentation/#tilequery).
+ * [the HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#tilequery).
*/
var Tilequery = {};
@@ -3530,6 +3944,17 @@
* @param {'polygon'|'linestring'|'point'} [config.geometry] - Queries for a specific geometry type.
* @param {Array} [config.layers] - IDs of vector layers to query.
* @return {MapiRequest}
+ *
+ * @example
+ * tilequeryClient.listFeatures({
+ * mapIds: ['mapbox.mapbox-streets-v8'],
+ * coordinates: [-122.42901, 37.80633],
+ * radius: 10
+ * })
+ * .send()
+ * .then(response => {
+ * const features = response.body;
+ * });
*/
Tilequery.listFeatures = function(config) {
validator.assertShape({
@@ -3558,7 +3983,7 @@
* Tilesets API service.
*
* Learn more about this service and its responses in
- * [the HTTP service documentation](https://www.mapbox.com/api-documentation/#tilesets).
+ * [the HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#tilesets).
*/
var Tilesets = {};
@@ -3568,6 +3993,18 @@
* @param {Object} [config]
* @param {string} [config.ownerId]
* @return {MapiRequest}
+ *
+ * @example
+ * tilesetsClient.listTilesets()
+ * .then(response => {
+ * const tilesets = response.body;
+ * });
+ *
+ * @example
+ * tilesetsClient.listTilesets()
+ * .eachPage((error, response, next) => {
+ * // Handle error or response and call next.
+ * });
*/
Tilesets.listTilesets = function(config) {
validator.assertShape({
@@ -3587,16 +4024,23 @@
* Tokens API service.
*
* Learn more about this service and its responses in
- * [the HTTP service documentation](https://www.mapbox.com/api-documentation/#tokens).
+ * [the HTTP service documentation](https://www.mapbox.com/api-documentation/accounts/#tokens).
*/
var Tokens = {};
/**
* List your access tokens.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/#list-tokens).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/accounts/#list-tokens).
*
* @return {MapiRequest}
+ *
+ * @example
+ * tokensClient.listTokens()
+ * .send()
+ * .then(response => {
+ * const tokens = response.body;
+ * });
*/
Tokens.listTokens = function() {
return this.client.createRequest({
@@ -3608,14 +4052,24 @@
/**
* Create a new access token.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/#create-token).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/accounts/#create-a-token).
*
* @param {Object} [config]
* @param {string} [config.note]
* @param {Array} [config.scopes]
* @param {Array} [config.resources]
- * @param {Array} [config.referrers]
+ * @param {Array} [config.allowedUrls]
* @return {MapiRequest}
+ *
+ * @example
+ * tokensClient.createToken({
+ * note: 'datasets-token',
+ * scopes: ['datasets:write', 'datasets:read']
+ * })
+ * .send()
+ * .then(response => {
+ * const token = response.body;
+ * });
*/
Tokens.createToken = function(config) {
config = config || {};
@@ -3623,7 +4077,7 @@
note: validator.string,
scopes: validator.arrayOf(validator.string),
resources: validator.arrayOf(validator.string),
- referrers: validator.arrayOf(validator.string)
+ allowedUrls: validator.arrayOf(validator.string)
})(config);
var body = {};
@@ -3634,8 +4088,8 @@
if (config.resources) {
body.resources = config.resources;
}
- if (config.referrers) {
- body.referrers = config.referrers;
+ if (config.allowedUrls) {
+ body.allowedUrls = config.allowedUrls;
}
return this.client.createRequest({
@@ -3649,12 +4103,21 @@
/**
* Create a new temporary access token.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/#create-temporary-token).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/accounts/#create-a-temporary-token).
*
* @param {Object} config
* @param {string} config.expires
* @param {Array} config.scopes
* @return {MapiRequest}
+ *
+ * @example
+ * tokensClient.createTemporaryToken({
+ * scopes: ['datasets:write', 'datasets:read']
+ * })
+ * .send()
+ * .then(response => {
+ * const token = response.body;
+ * });
*/
Tokens.createTemporaryToken = function(config) {
validator.assertShape({
@@ -3676,15 +4139,26 @@
/**
* Update an access token.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/#update-a-token).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/accounts/#update-a-token).
*
* @param {Object} config
* @param {string} config.tokenId
* @param {string} [config.note]
* @param {Array} [config.scopes]
* @param {Array} [config.resources]
- * @param {Array} [config.referrers]
+ * @param {Array} [config.allowedUrls]
* @return {MapiRequest}
+ *
+ * @example
+ * tokensClient.updateToken({
+ * tokenId: 'cijucimbe000brbkt48d0dhcx',
+ * note: 'datasets-token',
+ * scopes: ['datasets:write', 'datasets:read']
+ * })
+ * .send()
+ * .then(response => {
+ * const token = response.body;
+ * });
*/
Tokens.updateToken = function(config) {
validator.assertShape({
@@ -3692,7 +4166,7 @@
note: validator.string,
scopes: validator.arrayOf(validator.string),
resources: validator.arrayOf(validator.string),
- referrers: validator.arrayOf(validator.string)
+ allowedUrls: validator.arrayOf(validator.string)
})(config);
var body = {};
@@ -3702,11 +4176,11 @@
if (config.note !== undefined) {
body.note = config.note;
}
- if (config.resources) {
+ if (config.resources || config.resources === null) {
body.resources = config.resources;
}
- if (config.referrers) {
- body.referrers = config.referrers;
+ if (config.allowedUrls || config.allowedUrls === null) {
+ body.allowedUrls = config.allowedUrls;
}
return this.client.createRequest({
@@ -3720,9 +4194,16 @@
/**
* Get data about the client's access token.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/#retrieve-a-token).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/accounts/#retrieve-a-token).
*
* @return {MapiRequest}
+ *
+ * @example
+ * tokensClient.getToken()
+ * .send()
+ * .then(response => {
+ * const token = response.body;
+ * });
*/
Tokens.getToken = function() {
return this.client.createRequest({
@@ -3734,11 +4215,20 @@
/**
* Delete an access token.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/?language=cURL#delete-a-token).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/accounts/#delete-a-token).
*
* @param {Object} config
* @param {string} config.tokenId
* @return {MapiRequest}
+ *
+ * @example
+ * tokensClient.deleteToken({
+ * tokenId: 'cijucimbe000brbkt48d0dhcx'
+ * })
+ * .send()
+ * .then(response => {
+ * // Token successfully deleted.
+ * });
*/
Tokens.deleteToken = function(config) {
validator.assertShape({
@@ -3756,9 +4246,16 @@
* List your available scopes. Each item is a metadata
* object about the scope, not just the string scope.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/#list-scopes).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/accounts/#list-scopes).
*
* @return {MapiRequest}
+ *
+ * @example
+ * tokensClient.listScopes()
+ * .send()
+ * .then(response => {
+ * const scopes = response.body;
+ * });
*/
Tokens.listScopes = function() {
return this.client.createRequest({
@@ -3773,18 +4270,25 @@
* Uploads API service.
*
* Learn more about this service and its responses in
- * [the HTTP service documentation](https://www.mapbox.com/api-documentation/#uploads).
+ * [the HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#uploads).
*/
var Uploads = {};
/**
* List the statuses of all recent uploads.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/#retrieve-recent-upload-statuses).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#retrieve-recent-upload-statuses).
*
* @param {Object} [config]
* @param {boolean} [config.reverse] - List uploads in chronological order, rather than reverse chronological order.
* @return {MapiRequest}
+ *
+ * @example
+ * uploadsClient.listUploads()
+ * .send()
+ * .then(response => {
+ * const uploads = response.body;
+ * });
*/
Uploads.listUploads = function(config) {
validator.assertShape({
@@ -3801,9 +4305,33 @@
/**
* Create S3 credentials.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/#retrieve-s3-credentials).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#retrieve-s3-credentials).
*
* @return {MapiRequest}
+ *
+ * @example
+ * const AWS = require('aws-sdk');
+ * const getCredentials = () => {
+ * return uploadsClient
+ * .createUploadCredentials()
+ * .send()
+ * .then(response => response.body);
+ * }
+ * const putFileOnS3 = (credentials) => {
+ * const s3 = new AWS.S3({
+ * accessKeyId: credentials.accessKeyId,
+ * secretAccessKey: credentials.secretAccessKey,
+ * sessionToken: credentials.sessionToken,
+ * region: 'us-east-1'
+ * });
+ * return s3.putObject({
+ * Bucket: credentials.bucket,
+ * Key: credentials.key,
+ * Body: fs.createReadStream('/path/to/file.mbtiles')
+ * }).promise();
+ * };
+ *
+ * getCredentials().then(putFileOnS3);
*/
Uploads.createUploadCredentials = function() {
return this.client.createRequest({
@@ -3815,7 +4343,7 @@
/**
* Create an upload.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/#create-an-upload).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#create-an-upload).
*
* @param {Object} config
* @param {string} config.mapId - The map ID to create or replace in the format `username.nameoftileset`.
@@ -3826,6 +4354,25 @@
* This should be in the format `mapbox://datasets/{username}/{datasetId}`.
* @param {string} [config.tilesetName] - Name for the tileset. Limited to 64 characters.
* @return {MapiRequest}
+ *
+ * @example
+ * // Response from a call to createUploadCredentials
+ * const credentials = {
+ * accessKeyId: '{accessKeyId}',
+ * bucket: '{bucket}',
+ * key: '{key}',
+ * secretAccessKey: '{secretAccessKey}',
+ * sessionToken: '{sessionToken}',
+ * url: '{s3 url}'
+ * };
+ * uploadsClient.createUpload({
+ * mapId: `${myUsername}.${myTileset}`,
+ * url: credentials.url
+ * })
+ * .send()
+ * .then(response => {
+ * const upload = response.body;
+ * });
*/
Uploads.createUpload = function(config) {
validator.assertShape({
@@ -3848,11 +4395,20 @@
/**
* Get an upload's status.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/#retrieve-upload-status).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#retrieve-upload-status).
*
* @param {Object} config
* @param {string} config.uploadId
* @return {MapiRequest}
+ *
+ * @example
+ * uploadsClient.getUpload({
+ * uploadId: '{upload_id}'
+ * })
+ * .send()
+ * .then(response => {
+ * const status = response.body;
+ * });
*/
Uploads.getUpload = function(config) {
validator.assertShape({
@@ -3869,11 +4425,20 @@
/**
* Delete an upload.
*
- * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/#remove-an-upload).
+ * See the [corresponding HTTP service documentation](https://www.mapbox.com/api-documentation/maps/#remove-an-upload-status).
*
* @param {Object} config
* @param {string} config.uploadId
* @return {MapiRequest}
+ *
+ * @example
+ * uploadsClient.deleteUpload({
+ * uploadId: '{upload_id}'
+ * })
+ * .send()
+ * .then(response => {
+ * // Upload successfully deleted.
+ * });
*/
Uploads.deleteUpload = function(config) {
validator.assertShape({
@@ -3912,4 +4477,4 @@
return bundle;
-})));
\ No newline at end of file
+})));
diff --git a/public/static/scripts/mapbox/mapbox-sdk.min.js b/public/static/scripts/mapbox/mapbox-sdk.min.js
index dd80c5e7..70395046 100644
--- a/public/static/scripts/mapbox/mapbox-sdk.min.js
+++ b/public/static/scripts/mapbox/mapbox-sdk.min.js
@@ -1 +1 @@
-(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory():typeof define==="function"&&define.amd?define(factory):global.mapboxSdk=factory()})(this,function(){"use strict";function parseParam(param){var parts=param.match(/\s*(.+)\s*=\s*"?([^"]+)"?/);if(!parts)return null;return{key:parts[1],value:parts[2]}}function parseLink(link){var parts=link.match(/([^>]*)>(.*)/);if(!parts)return null;var linkUrl=parts[1];var linkParams=parts[2].split(";");var rel=null;var parsedLinkParams=linkParams.reduce(function(result,param){var parsed=parseParam(param);if(!parsed)return result;if(parsed.key==="rel"){if(!rel){rel=parsed.value}return result}result[parsed.key]=parsed.value;return result},{});if(!rel)return null;return{url:linkUrl,rel:rel,params:parsedLinkParams}}function parseLinkHeader(linkHeader){if(!linkHeader)return{};return linkHeader.split(/,\s*).reduce(function(result,link){var parsed=parseLink(link);if(!parsed)return result;var splitRel=parsed.rel.split(/\s+/);splitRel.forEach(function(rel){if(!result[rel]){result[rel]={url:parsed.url,params:parsed.params}}});return result},{})}var parseLinkHeader_1=parseLinkHeader;function MapiResponse(request,responseData){this.request=request;this.headers=responseData.headers;this.rawBody=responseData.body;this.statusCode=responseData.statusCode;try{this.body=JSON.parse(responseData.body||"{}")}catch(parseError){this.body=responseData.body}this.links=parseLinkHeader_1(this.headers.link)}MapiResponse.prototype.hasNextPage=function hasNextPage(){return!!this.links.next};MapiResponse.prototype.nextPage=function nextPage(){if(!this.hasNextPage())return null;return this.request._extend({path:this.links.next.url})};var mapiResponse=MapiResponse;var constants={API_ORIGIN:"https://api.mapbox.com",EVENT_PROGRESS_DOWNLOAD:"downloadProgress",EVENT_PROGRESS_UPLOAD:"uploadProgress",EVENT_ERROR:"error",EVENT_RESPONSE:"response",ERROR_HTTP:"HttpError",ERROR_REQUEST_ABORTED:"RequestAbortedError"};function MapiError(options){var errorType=options.type||constants.ERROR_HTTP;var body;if(options.body){try{body=JSON.parse(options.body)}catch(e){body=options.body}}else{body=null}var message=options.message||null;if(!message){if(typeof body==="string"){message=body}else if(body&&typeof body.message==="string"){message=body.message}else if(errorType===constants.ERROR_REQUEST_ABORTED){message="Request aborted"}}this.message=message;this.type=errorType;this.statusCode=options.statusCode||null;this.request=options.request;this.body=body}var mapiError=MapiError;function parseSingleHeader(raw){var boundary=raw.indexOf(":");var name=raw.substring(0,boundary).trim().toLowerCase();var value=raw.substring(boundary+1).trim();return{name:name,value:value}}function parseHeaders(raw){var headers={};if(!raw){return headers}raw.trim().split(/[\r|\n]+/).forEach(function(rawHeader){var parsed=parseSingleHeader(rawHeader);headers[parsed.name]=parsed.value});return headers}var parseHeaders_1=parseHeaders;var requestsUnderway={};function browserAbort(request){var xhr=requestsUnderway[request.id];if(!xhr)return;xhr.abort();delete requestsUnderway[request.id]}function createResponse(request,xhr){return new mapiResponse(request,{body:xhr.response,headers:parseHeaders_1(xhr.getAllResponseHeaders()),statusCode:xhr.status})}function normalizeBrowserProgressEvent(event){var total=event.total;var transferred=event.loaded;var percent=100*transferred/total;return{total:total,transferred:transferred,percent:percent}}function sendRequestXhr(request,xhr){return new Promise(function(resolve,reject){xhr.onprogress=function(event){request.emitter.emit(constants.EVENT_PROGRESS_DOWNLOAD,normalizeBrowserProgressEvent(event))};var file=request.file;if(file){xhr.upload.onprogress=function(event){request.emitter.emit(constants.EVENT_PROGRESS_UPLOAD,normalizeBrowserProgressEvent(event))}}xhr.onerror=function(error){reject(error)};xhr.onabort=function(){var mapiError$$1=new mapiError({request:request,type:constants.ERROR_REQUEST_ABORTED});reject(mapiError$$1)};xhr.onload=function(){delete requestsUnderway[request.id];if(xhr.status<200||xhr.status>=400){var mapiError$$1=new mapiError({request:request,body:xhr.response,statusCode:xhr.status});reject(mapiError$$1);return}resolve(xhr)};var body=request.body;if(typeof body==="string"){xhr.send(body)}else if(body){xhr.send(JSON.stringify(body))}else if(file){xhr.send(file)}else{xhr.send()}requestsUnderway[request.id]=xhr}).then(function(xhr){return createResponse(request,xhr)})}function createRequestXhr(request,accessToken){var url=request.url(accessToken);var xhr=new window.XMLHttpRequest;xhr.open(request.method,url);Object.keys(request.headers).forEach(function(key){xhr.setRequestHeader(key,request.headers[key])});return xhr}function browserSend(request){return Promise.resolve().then(function(){var xhr=createRequestXhr(request,request.client.accessToken);return sendRequestXhr(request,xhr)})}var browserLayer={browserAbort:browserAbort,sendRequestXhr:sendRequestXhr,browserSend:browserSend,createRequestXhr:createRequestXhr};var commonjsGlobal=typeof window!=="undefined"?window:typeof global!=="undefined"?global:typeof self!=="undefined"?self:{};function createCommonjsModule(fn,module){return module={exports:{}},fn(module,module.exports),module.exports}var base64=createCommonjsModule(function(module,exports){(function(root){var freeExports=exports;var freeModule=module&&module.exports==freeExports&&module;var freeGlobal=typeof commonjsGlobal=="object"&&commonjsGlobal;if(freeGlobal.global===freeGlobal||freeGlobal.window===freeGlobal){root=freeGlobal}var InvalidCharacterError=function(message){this.message=message};InvalidCharacterError.prototype=new Error;InvalidCharacterError.prototype.name="InvalidCharacterError";var error=function(message){throw new InvalidCharacterError(message)};var TABLE="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var REGEX_SPACE_CHARACTERS=/[\t\n\f\r ]/g;var decode=function(input){input=String(input).replace(REGEX_SPACE_CHARACTERS,"");var length=input.length;if(length%4==0){input=input.replace(/==?$/,"");length=input.length}if(length%4==1||/[^+a-zA-Z0-9/]/.test(input)){error("Invalid character: the string to be decoded is not correctly encoded.")}var bitCounter=0;var bitStorage;var buffer;var output="";var position=-1;while(++position>(-2*bitCounter&6))}}return output};var encode=function(input){input=String(input);if(/[^\0-\xFF]/.test(input)){error("The string to be encoded contains characters outside of the "+"Latin1 range.")}var padding=input.length%3;var output="";var position=-1;var a;var b;var c;var buffer;var length=input.length-padding;while(++position>18&63)+TABLE.charAt(buffer>>12&63)+TABLE.charAt(buffer>>6&63)+TABLE.charAt(buffer&63)}if(padding==2){a=input.charCodeAt(position)<<8;b=input.charCodeAt(++position);buffer=a+b;output+=TABLE.charAt(buffer>>10)+TABLE.charAt(buffer>>4&63)+TABLE.charAt(buffer<<2&63)+"="}else if(padding==1){buffer=input.charCodeAt(position);output+=TABLE.charAt(buffer>>2)+TABLE.charAt(buffer<<4&63)+"=="}return output};var base64={encode:encode,decode:decode,version:"0.1.0"};if(freeExports&&!freeExports.nodeType){if(freeModule){freeModule.exports=base64}else{for(var key in base64){base64.hasOwnProperty(key)&&(freeExports[key]=base64[key])}}}else{root.base64=base64}})(commonjsGlobal)});var tokenCache={};function parseToken(token){if(tokenCache[token]){return tokenCache[token]}var parts=token.split(".");var usage=parts[0];var rawPayload=parts[1];if(!rawPayload){throw new Error("Invalid token")}var parsedPayload=parsePaylod(rawPayload);var result={usage:usage,user:parsedPayload.u};if(has(parsedPayload,"a"))result.authorization=parsedPayload.a;if(has(parsedPayload,"exp"))result.expires=parsedPayload.exp*1e3;if(has(parsedPayload,"iat"))result.created=parsedPayload.iat*1e3;if(has(parsedPayload,"scopes"))result.scopes=parsedPayload.scopes;if(has(parsedPayload,"client"))result.client=parsedPayload.client;if(has(parsedPayload,"ll"))result.lastLogin=parsedPayload.ll;if(has(parsedPayload,"iu"))result.impersonator=parsedPayload.iu;tokenCache[token]=result;return result}function parsePaylod(rawPayload){try{return JSON.parse(base64.decode(rawPayload))}catch(parseError){throw new Error("Invalid token")}}function has(obj,key){return Object.prototype.hasOwnProperty.call(obj,key)}var parseMapboxToken=parseToken;var immutable=extend;var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(){var target={};for(var i=0;imax.length?arr:max})}};v.equal=function equal(compareWith){return function equalValidator(value){if(value!==compareWith){return JSON.stringify(compareWith)}}};v.oneOf=function oneOf(){var options=Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments);var validators=options.map(function(value){return v.equal(value)});return v.oneOfType.apply(this,validators)};v.range=function range(compareWith){var min=compareWith[0];var max=compareWith[1];return function rangeValidator(value){var validationResult=validate(v.number,value);if(validationResult||valuemax){return"number between "+min+" & "+max+" (inclusive)"}}};v.any=function any(){return};v.boolean=function boolean(value){if(typeof value!=="boolean"){return"boolean"}};v.number=function number(value){if(typeof value!=="number"){return"number"}};v.plainArray=function plainArray(value){if(!Array.isArray(value)){return"array"}};v.plainObject=function plainObject(value){if(!isPlainObj(value)){return"object"}};v.string=function string(value){if(typeof value!=="string"){return"string"}};v.func=function func(value){if(typeof value!=="function"){return"function"}};function validate(validator,value){if(value==null&&!validator.hasOwnProperty("__required")){return}var result=validator(value);if(result){return Array.isArray(result)?result:[result]}}function processMessage(message,options){var len=message.length;var result=message[len-1];var path=message.slice(0,len-1);if(path.length===0){path=[DEFAULT_ERROR_PATH]}options=immutable(options,{path:path});return typeof result==="function"?result(options):formatErrorMessage(options,prettifyResult(result))}function orList(list){if(list.length<2){return list[0]}if(list.length===2){return list.join(" or ")}return list.slice(0,-1).join(", ")+", or "+list.slice(-1)}function prettifyResult(result){return"must be "+addArticle(result)+"."}function addArticle(nounPhrase){if(/^an? /.test(nounPhrase)){return nounPhrase}if(/^[aeiou]/i.test(nounPhrase)){return"an "+nounPhrase}if(/^[a-z]/i.test(nounPhrase)){return"a "+nounPhrase}return nounPhrase}function formatErrorMessage(options,prettyResult){var arrayCulprit=isArrayCulprit(options.path);var output=options.path.join(".")+" "+prettyResult;var prepend=arrayCulprit?"Item at position ":"";return prepend+output}function isArrayCulprit(path){return typeof path[path.length-1]=="number"||typeof path[0]=="number"}function objectEntries(obj){return Object.keys(obj||{}).map(function(key){return{key:key,value:obj[key]}})}v.validate=validate;v.processMessage=processMessage;var lib=v;function file(value){if(typeof window!=="undefined"){if(value instanceof commonjsGlobal.Blob||value instanceof commonjsGlobal.ArrayBuffer){return}return"Blob or ArrayBuffer"}if(typeof value==="string"||value.pipe!==undefined){return}return"Filename or Readable stream"}function assertShape(validatorObj,apiName){return lib.assert(lib.strictShape(validatorObj),apiName)}function date(value){var msg="date";if(typeof value==="boolean"){return msg}try{var date=new Date(value);if(date.getTime&&isNaN(date.getTime())){return msg}}catch(e){return msg}}function coordinates(value){return lib.tuple(lib.number,lib.number)(value)}var validator=immutable(lib,{file:file,date:date,coordinates:coordinates,assertShape:assertShape});function pick(source,keys){var filter=function(key,val){return keys.indexOf(key)!==-1&&val!==undefined};if(typeof keys==="function"){filter=keys}return Object.keys(source).filter(function(key){return filter(key,source[key])}).reduce(function(result,key){result[key]=source[key];return result},{})}var pick_1=pick;function createServiceFactory(ServicePrototype){return function(clientOrConfig){var client;if(mapiClient.prototype.isPrototypeOf(clientOrConfig)){client=clientOrConfig}else{client=browserClient(clientOrConfig)}var service=Object.create(ServicePrototype);service.client=client;return service}}var createServiceFactory_1=createServiceFactory;var Datasets={};Datasets.listDatasets=function(){return this.client.createRequest({method:"GET",path:"/datasets/v1/:ownerId"})};Datasets.createDataset=function(config){validator.assertShape({name:validator.string,description:validator.string})(config);return this.client.createRequest({method:"POST",path:"/datasets/v1/:ownerId",body:config})};Datasets.getMetadata=function(config){validator.assertShape({datasetId:validator.required(validator.string),description:validator.string})(config);return this.client.createRequest({method:"GET",path:"/datasets/v1/:ownerId/:datasetId",params:config})};Datasets.updateMetadata=function(config){validator.assertShape({datasetId:validator.required(validator.string),name:validator.string,description:validator.string})(config);return this.client.createRequest({method:"PATCH",path:"/datasets/v1/:ownerId/:datasetId",params:pick_1(config,["datasetId"]),body:pick_1(config,["name","description"])})};Datasets.deleteDataset=function(config){validator.assertShape({datasetId:validator.required(validator.string)})(config);return this.client.createRequest({method:"DELETE",path:"/datasets/v1/:ownerId/:datasetId",params:config})};Datasets.listFeatures=function(config){validator.assertShape({datasetId:validator.required(validator.string),limit:validator.number,start:validator.string})(config);return this.client.createRequest({method:"GET",path:"/datasets/v1/:ownerId/:datasetId/features",params:pick_1(config,["datasetId"]),query:pick_1(config,["limit","start"])})};Datasets.putFeature=function(config){validator.assertShape({datasetId:validator.required(validator.string),featureId:validator.required(validator.string),feature:validator.required(validator.plainObject)})(config);if(config.feature.id!==undefined&&config.feature.id!==config.featureId){throw new Error("featureId must match the id property of the feature")}return this.client.createRequest({method:"PUT",path:"/datasets/v1/:ownerId/:datasetId/features/:featureId",params:pick_1(config,["datasetId","featureId"]),body:config.feature})};Datasets.getFeature=function(config){validator.assertShape({datasetId:validator.required(validator.string),featureId:validator.required(validator.string)})(config);return this.client.createRequest({method:"GET",path:"/datasets/v1/:ownerId/:datasetId/features/:featureId",params:config})};Datasets.deleteFeature=function(config){validator.assertShape({datasetId:validator.required(validator.string),featureId:validator.required(validator.string)})(config);return this.client.createRequest({method:"DELETE",path:"/datasets/v1/:ownerId/:datasetId/features/:featureId",params:config})};var datasets=createServiceFactory_1(Datasets);function objectClean(obj){return pick_1(obj,function(_,val){return val!=null})}var objectClean_1=objectClean;function objectMap(obj,cb){return Object.keys(obj).reduce(function(result,key){result[key]=cb(key,obj[key]);return result},{})}var objectMap_1=objectMap;function stringifyBoolean(obj){return objectMap_1(obj,function(_,value){return typeof value==="boolean"?JSON.stringify(value):value})}var stringifyBooleans=stringifyBoolean;var Directions={};Directions.getDirections=function(config){validator.assertShape({profile:validator.oneOf("driving-traffic","driving","walking","cycling"),waypoints:validator.required(validator.arrayOf(validator.shape({coordinates:validator.required(validator.coordinates),approach:validator.oneOf("unrestricted","curb"),bearing:validator.arrayOf(validator.range([0,360])),radius:validator.oneOfType(validator.number,validator.equal("unlimited")),waypointName:validator.string}))),alternatives:validator.boolean,annotations:validator.arrayOf(validator.oneOf("duration","distance","speed","congestion")),bannerInstructions:validator.boolean,continueStraight:validator.boolean,exclude:validator.string,geometries:validator.string,language:validator.string,overview:validator.string,roundaboutExits:validator.boolean,steps:validator.boolean,voiceInstructions:validator.boolean,voiceUnits:validator.string})(config);config.profile=config.profile||"driving";var path={coordinates:[],approach:[],bearing:[],radius:[],waypointName:[]};var waypointCount=config.waypoints.length;if(waypointCount<2||waypointCount>25){throw new Error("waypoints must include between 2 and 25 DirectionsWaypoints")}config.waypoints.forEach(function(waypoint){path.coordinates.push(waypoint.coordinates[0]+","+waypoint.coordinates[1]);["bearing"].forEach(function(prop){if(waypoint.hasOwnProperty(prop)&&waypoint[prop]!=null){waypoint[prop]=waypoint[prop].join(",")}});["approach","bearing","radius","waypointName"].forEach(function(prop){if(waypoint.hasOwnProperty(prop)&&waypoint[prop]!=null){path[prop].push(waypoint[prop])}else{path[prop].push("")}})});["approach","bearing","radius","waypointName"].forEach(function(prop){if(path[prop].every(function(char){return char===""})){delete path[prop]}else{path[prop]=path[prop].join(";")}});var query=stringifyBooleans({alternatives:config.alternatives,annotations:config.annotations,banner_instructions:config.bannerInstructions,continue_straight:config.continueStraight,exclude:config.exclude,geometries:config.geometries,language:config.language,overview:config.overview,roundabout_exits:config.roundaboutExits,steps:config.steps,voice_instructions:config.voiceInstructions,voice_units:config.voiceUnits,approaches:path.approach,bearings:path.bearing,radiuses:path.radius,waypoint_names:path.waypointName});return this.client.createRequest({method:"GET",path:"/directions/v5/mapbox/:profile/:coordinates",params:{profile:config.profile,coordinates:path.coordinates.join(";")},query:objectClean_1(query)})};var directions=createServiceFactory_1(Directions);var Geocoding={};var featureTypes=["country","region","postcode","district","place","locality","neighborhood","address","poi","poi.landmark"];Geocoding.forwardGeocode=function(config){validator.assertShape({query:validator.required(validator.string),mode:validator.oneOf("mapbox.places","mapbox.places-permanent"),countries:validator.arrayOf(validator.string),proximity:validator.coordinates,types:validator.arrayOf(validator.oneOf(featureTypes)),autocomplete:validator.boolean,bbox:validator.arrayOf(validator.number),limit:validator.number,language:validator.arrayOf(validator.string)})(config);config.mode=config.mode||"mapbox.places";var query=stringifyBooleans(immutable({country:config.countries},pick_1(config,["proximity","types","autocomplete","bbox","limit","language"])));return this.client.createRequest({method:"GET",path:"/geocoding/v5/:mode/:query.json",params:pick_1(config,["mode","query"]),query:query})};Geocoding.reverseGeocode=function(config){validator.assertShape({query:validator.required(validator.coordinates),mode:validator.oneOf("mapbox.places","mapbox.places-permanent"),countries:validator.arrayOf(validator.string),types:validator.arrayOf(validator.oneOf(featureTypes)),bbox:validator.arrayOf(validator.number),limit:validator.number,language:validator.arrayOf(validator.string),reverseMode:validator.oneOf("distance","score")})(config);config.mode=config.mode||"mapbox.places";var query=stringifyBooleans(immutable({country:config.countries},pick_1(config,["country","types","bbox","limit","language","reverseMode"])));return this.client.createRequest({method:"GET",path:"/geocoding/v5/:mode/:query.json",params:pick_1(config,["mode","query"]),query:query})};var geocoding=createServiceFactory_1(Geocoding);var MapMatching={};MapMatching.getMatch=function(config){validator.assertShape({points:validator.required(validator.arrayOf(validator.shape({coordinates:validator.required(validator.coordinates),approach:validator.oneOf("unrestricted","curb"),radius:validator.range([0,50]),isWaypoint:validator.boolean,waypointName:validator.string,timestamp:validator.date}))),profile:validator.oneOf("driving-traffic","driving","walking","cycling"),annotations:validator.arrayOf(validator.oneOf("duration","distance","speed")),geometries:validator.oneOf("geojson","polyline","polyline6"),language:validator.string,overview:validator.oneOf("full","simplified","false"),steps:validator.boolean,tidy:validator.boolean})(config);var pointCount=config.points.length;if(pointCount<2||pointCount>100){throw new Error("points must include between 2 and 100 MapMatchingPoints")}config.profile=config.profile||"driving";var path={coordinates:[],approach:[],radius:[],isWaypoint:[],waypointName:[],timestamp:[]};config.points.forEach(function(obj){path.coordinates.push(obj.coordinates[0]+","+obj.coordinates[1]);if(obj.hasOwnProperty("isWaypoint")&&obj.isWaypoint!=null){path.isWaypoint.push(obj.isWaypoint)}else{path.isWaypoint.push(true)}if(obj.hasOwnProperty("timestamp")&&obj.timestamp!=null){path.timestamp.push(Number(new Date(obj.timestamp)))}else{path.timestamp.push("")}["approach","radius","waypointName"].forEach(function(prop){if(obj.hasOwnProperty(prop)&&obj[prop]!=null){path[prop].push(obj[prop])}else{path[prop].push("")}})});["coordinates","approach","radius","waypointName","timestamp"].forEach(function(prop){if(path[prop].every(function(value){return value===""})){delete path[prop]}else{path[prop]=path[prop].join(";")}});path.isWaypoint[0]=true;path.isWaypoint[path.isWaypoint.length-1]=true;if(path.isWaypoint.every(function(value){return value===true})){delete path.isWaypoint}else{path.isWaypoint=path.isWaypoint.map(function(val,i){return val===true?i:""}).join(";")}var body=stringifyBooleans(objectClean_1({annotations:config.annotations,geometries:config.geometries,language:config.language,overview:config.overview,steps:config.steps,tidy:config.tidy,approaches:path.approach,radiuses:path.radius,waypoints:path.isWaypoint,timestamps:path.timestamp,waypoint_names:path.waypointName,coordinates:path.coordinates}));return this.client.createRequest({method:"POST",path:"/matching/v5/mapbox/:profile",params:{profile:config.profile},body:urlUtils.appendQueryObject("",body).substring(1),headers:{"content-type":"application/x-www-form-urlencoded"}})};var mapMatching=createServiceFactory_1(MapMatching);var Matrix={};Matrix.getMatrix=function(config){validator.assertShape({points:validator.required(validator.arrayOf(validator.shape({coordinates:validator.required(validator.coordinates),approach:validator.oneOf("unrestricted","curb")}))),profile:validator.oneOf("driving-traffic","driving","walking","cycling"),annotations:validator.arrayOf(validator.oneOf("duration","distance")),sources:validator.oneOfType(validator.equal("all"),validator.arrayOf(validator.number)),destinations:validator.oneOfType(validator.equal("all"),validator.arrayOf(validator.number))})(config);var pointCount=config.points.length;if(pointCount<2||pointCount>100){throw new Error("points must include between 2 and 100 MatrixPoints")}config.profile=config.profile||"driving";var path={coordinates:[],approach:[]};config.points.forEach(function(obj){path.coordinates.push(obj.coordinates[0]+","+obj.coordinates[1]);if(obj.hasOwnProperty("approach")&&obj.approach!=null){path.approach.push(obj.approach)}else{path.approach.push("")}});if(path.approach.every(function(value){return value===""})){delete path.approach}else{path.approach=path.approach.join(";")}var query={sources:Array.isArray(config.sources)?config.sources.join(";"):config.sources,destinations:Array.isArray(config.destinations)?config.destinations.join(";"):config.destinations,approaches:path.approach,annotations:config.annotations&&config.annotations.join(",")};return this.client.createRequest({method:"GET",path:"/directions-matrix/v1/mapbox/:profile/:coordinates",params:{profile:config.profile,coordinates:path.coordinates.join(";")},query:objectClean_1(query)})};var matrix=createServiceFactory_1(Matrix);var Optimization={};Optimization.getOptimization=function(config){validator.assertShape({profile:validator.oneOf("driving","walking","cycling"),waypoints:validator.required(validator.arrayOf(validator.shape({coordinates:validator.required(validator.coordinates),approach:validator.oneOf("unrestricted","curb"),bearing:validator.arrayOf(validator.range([0,360])),radius:validator.oneOfType(validator.number,validator.equal("unlimited"))}))),annotations:validator.arrayOf(validator.oneOf("duration","distance","speed")),geometries:validator.oneOf("geojson","polyline","polyline6"),language:validator.string,overview:validator.oneOf("simplified","full","false"),roundtrip:validator.boolean,steps:validator.boolean,source:validator.oneOf("any","first"),destination:validator.oneOf("any","last"),distributions:validator.arrayOf(validator.shape({pickup:validator.number,dropoff:validator.number}))})(config);var path={coordinates:[],approach:[],bearing:[],radius:[],distributions:[]};var waypointCount=config.waypoints.length;if(waypointCount<2||waypointCount>12){throw new Error("waypoints must include between 2 and 12 OptimizationWaypoints")}config.waypoints.forEach(function(waypoint){path.coordinates.push(waypoint.coordinates[0]+","+waypoint.coordinates[1]);["bearing"].forEach(function(prop){if(waypoint.hasOwnProperty(prop)&&waypoint[prop]!=null){waypoint[prop]=waypoint[prop].join(",")}});["approach","bearing","radius"].forEach(function(prop){if(waypoint.hasOwnProperty(prop)&&waypoint[prop]!=null){path[prop].push(waypoint[prop])}else{path[prop].push("")}})});if(config.distributions){config.distributions.forEach(function(dist){path.distributions.push(dist.pickup+","+dist.dropoff)})}["approach","bearing","radius","distributions"].forEach(function(prop){if(path[prop].every(function(char){return char===""})){delete path[prop]}else{path[prop]=path[prop].join(";")}});var query=stringifyBooleans({geometries:config.geometries,language:config.language,overview:config.overview,roundtrip:config.roundtrip,steps:config.steps,source:config.source,destination:config.destination,distributions:path.distributions,approaches:path.approach,bearings:path.bearing,radiuses:path.radius});return this.client.createRequest({method:"GET",path:"/optimized-trips/v1/mapbox/:profile/:coordinates",params:{profile:config.profile||"driving",coordinates:path.coordinates.join(";")},query:objectClean_1(query)})};var optimization=createServiceFactory_1(Optimization);var polyline_1=createCommonjsModule(function(module){var polyline={};function py2_round(value){return Math.floor(Math.abs(value)+.5)*(value>=0?1:-1)}function encode(current,previous,factor){current=py2_round(current*factor);previous=py2_round(previous*factor);var coordinate=current-previous;coordinate<<=1;if(current-previous<0){coordinate=~coordinate}var output="";while(coordinate>=32){output+=String.fromCharCode((32|coordinate&31)+63);coordinate>>=5}output+=String.fromCharCode(coordinate+63);return output}polyline.decode=function(str,precision){var index=0,lat=0,lng=0,coordinates=[],shift=0,result=0,byte=null,latitude_change,longitude_change,factor=Math.pow(10,precision||5);while(index=32);latitude_change=result&1?~(result>>1):result>>1;shift=result=0;do{byte=str.charCodeAt(index++)-63;result|=(byte&31)<=32);longitude_change=result&1?~(result>>1):result>>1;lat+=latitude_change;lng+=longitude_change;coordinates.push([lat/factor,lng/factor])}return coordinates};polyline.encode=function(coordinates,precision){if(!coordinates.length){return""}var factor=Math.pow(10,precision||5),output=encode(coordinates[0][0],0,factor)+encode(coordinates[0][1],0,factor);for(var i=1;i]*)>(.*)/);if(!parts)return null;var linkUrl=parts[1];var linkParams=parts[2].split(";");var rel=null;var parsedLinkParams=linkParams.reduce(function(result,param){var parsed=parseParam(param);if(!parsed)return result;if(parsed.key==="rel"){if(!rel){rel=parsed.value}return result}result[parsed.key]=parsed.value;return result},{});if(!rel)return null;return{url:linkUrl,rel:rel,params:parsedLinkParams}}function parseLinkHeader(linkHeader){if(!linkHeader)return{};return linkHeader.split(/,\s*).reduce(function(result,link){var parsed=parseLink(link);if(!parsed)return result;var splitRel=parsed.rel.split(/\s+/);splitRel.forEach(function(rel){if(!result[rel]){result[rel]={url:parsed.url,params:parsed.params}}});return result},{})}var parseLinkHeader_1=parseLinkHeader;function MapiResponse(request,responseData){this.request=request;this.headers=responseData.headers;this.rawBody=responseData.body;this.statusCode=responseData.statusCode;try{this.body=JSON.parse(responseData.body||"{}")}catch(parseError){this.body=responseData.body}this.links=parseLinkHeader_1(this.headers.link)}MapiResponse.prototype.hasNextPage=function hasNextPage(){return!!this.links.next};MapiResponse.prototype.nextPage=function nextPage(){if(!this.hasNextPage())return null;return this.request._extend({path:this.links.next.url})};var mapiResponse=MapiResponse;var constants={API_ORIGIN:"https://api.mapbox.com",EVENT_PROGRESS_DOWNLOAD:"downloadProgress",EVENT_PROGRESS_UPLOAD:"uploadProgress",EVENT_ERROR:"error",EVENT_RESPONSE:"response",ERROR_HTTP:"HttpError",ERROR_REQUEST_ABORTED:"RequestAbortedError"};function MapiError(options){var errorType=options.type||constants.ERROR_HTTP;var body;if(options.body){try{body=JSON.parse(options.body)}catch(e){body=options.body}}else{body=null}var message=options.message||null;if(!message){if(typeof body==="string"){message=body}else if(body&&typeof body.message==="string"){message=body.message}else if(errorType===constants.ERROR_REQUEST_ABORTED){message="Request aborted"}}this.message=message;this.type=errorType;this.statusCode=options.statusCode||null;this.request=options.request;this.body=body}var mapiError=MapiError;function parseSingleHeader(raw){var boundary=raw.indexOf(":");var name=raw.substring(0,boundary).trim().toLowerCase();var value=raw.substring(boundary+1).trim();return{name:name,value:value}}function parseHeaders(raw){var headers={};if(!raw){return headers}raw.trim().split(/[\r|\n]+/).forEach(function(rawHeader){var parsed=parseSingleHeader(rawHeader);headers[parsed.name]=parsed.value});return headers}var parseHeaders_1=parseHeaders;var requestsUnderway={};function browserAbort(request){var xhr=requestsUnderway[request.id];if(!xhr)return;xhr.abort();delete requestsUnderway[request.id]}function createResponse(request,xhr){return new mapiResponse(request,{body:xhr.response,headers:parseHeaders_1(xhr.getAllResponseHeaders()),statusCode:xhr.status})}function normalizeBrowserProgressEvent(event){var total=event.total;var transferred=event.loaded;var percent=100*transferred/total;return{total:total,transferred:transferred,percent:percent}}function sendRequestXhr(request,xhr){return new Promise(function(resolve,reject){xhr.onprogress=function(event){request.emitter.emit(constants.EVENT_PROGRESS_DOWNLOAD,normalizeBrowserProgressEvent(event))};var file=request.file;if(file){xhr.upload.onprogress=function(event){request.emitter.emit(constants.EVENT_PROGRESS_UPLOAD,normalizeBrowserProgressEvent(event))}}xhr.onerror=function(error){reject(error)};xhr.onabort=function(){var mapiError$$1=new mapiError({request:request,type:constants.ERROR_REQUEST_ABORTED});reject(mapiError$$1)};xhr.onload=function(){delete requestsUnderway[request.id];if(xhr.status<200||xhr.status>=400){var mapiError$$1=new mapiError({request:request,body:xhr.response,statusCode:xhr.status});reject(mapiError$$1);return}resolve(xhr)};var body=request.body;if(typeof body==="string"){xhr.send(body)}else if(body){xhr.send(JSON.stringify(body))}else if(file){xhr.send(file)}else{xhr.send()}requestsUnderway[request.id]=xhr}).then(function(xhr){return createResponse(request,xhr)})}function createRequestXhr(request,accessToken){var url=request.url(accessToken);var xhr=new window.XMLHttpRequest;xhr.open(request.method,url);Object.keys(request.headers).forEach(function(key){xhr.setRequestHeader(key,request.headers[key])});return xhr}function browserSend(request){return Promise.resolve().then(function(){var xhr=createRequestXhr(request,request.client.accessToken);return sendRequestXhr(request,xhr)})}var browserLayer={browserAbort:browserAbort,sendRequestXhr:sendRequestXhr,browserSend:browserSend,createRequestXhr:createRequestXhr};var commonjsGlobal=typeof window!=="undefined"?window:typeof global!=="undefined"?global:typeof self!=="undefined"?self:{};function createCommonjsModule(fn,module){return module={exports:{}},fn(module,module.exports),module.exports}var base64=createCommonjsModule(function(module,exports){(function(root){var freeExports=exports;var freeModule=module&&module.exports==freeExports&&module;var freeGlobal=typeof commonjsGlobal=="object"&&commonjsGlobal;if(freeGlobal.global===freeGlobal||freeGlobal.window===freeGlobal){root=freeGlobal}var InvalidCharacterError=function(message){this.message=message};InvalidCharacterError.prototype=new Error;InvalidCharacterError.prototype.name="InvalidCharacterError";var error=function(message){throw new InvalidCharacterError(message)};var TABLE="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var REGEX_SPACE_CHARACTERS=/[\t\n\f\r ]/g;var decode=function(input){input=String(input).replace(REGEX_SPACE_CHARACTERS,"");var length=input.length;if(length%4==0){input=input.replace(/==?$/,"");length=input.length}if(length%4==1||/[^+a-zA-Z0-9/]/.test(input)){error("Invalid character: the string to be decoded is not correctly encoded.")}var bitCounter=0;var bitStorage;var buffer;var output="";var position=-1;while(++position>(-2*bitCounter&6))}}return output};var encode=function(input){input=String(input);if(/[^\0-\xFF]/.test(input)){error("The string to be encoded contains characters outside of the "+"Latin1 range.")}var padding=input.length%3;var output="";var position=-1;var a;var b;var c;var buffer;var length=input.length-padding;while(++position>18&63)+TABLE.charAt(buffer>>12&63)+TABLE.charAt(buffer>>6&63)+TABLE.charAt(buffer&63)}if(padding==2){a=input.charCodeAt(position)<<8;b=input.charCodeAt(++position);buffer=a+b;output+=TABLE.charAt(buffer>>10)+TABLE.charAt(buffer>>4&63)+TABLE.charAt(buffer<<2&63)+"="}else if(padding==1){buffer=input.charCodeAt(position);output+=TABLE.charAt(buffer>>2)+TABLE.charAt(buffer<<4&63)+"=="}return output};var base64={encode:encode,decode:decode,version:"0.1.0"};if(freeExports&&!freeExports.nodeType){if(freeModule){freeModule.exports=base64}else{for(var key in base64){base64.hasOwnProperty(key)&&(freeExports[key]=base64[key])}}}else{root.base64=base64}})(commonjsGlobal)});var tokenCache={};function parseToken(token){if(tokenCache[token]){return tokenCache[token]}var parts=token.split(".");var usage=parts[0];var rawPayload=parts[1];if(!rawPayload){throw new Error("Invalid token")}var parsedPayload=parsePaylod(rawPayload);var result={usage:usage,user:parsedPayload.u};if(has(parsedPayload,"a"))result.authorization=parsedPayload.a;if(has(parsedPayload,"exp"))result.expires=parsedPayload.exp*1e3;if(has(parsedPayload,"iat"))result.created=parsedPayload.iat*1e3;if(has(parsedPayload,"scopes"))result.scopes=parsedPayload.scopes;if(has(parsedPayload,"client"))result.client=parsedPayload.client;if(has(parsedPayload,"ll"))result.lastLogin=parsedPayload.ll;if(has(parsedPayload,"iu"))result.impersonator=parsedPayload.iu;tokenCache[token]=result;return result}function parsePaylod(rawPayload){try{return JSON.parse(base64.decode(rawPayload))}catch(parseError){throw new Error("Invalid token")}}function has(obj,key){return Object.prototype.hasOwnProperty.call(obj,key)}var parseMapboxToken=parseToken;var immutable=extend;var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(){var target={};for(var i=0;imax.length?arr:max})}};v.equal=function equal(compareWith){return function equalValidator(value){if(value!==compareWith){return JSON.stringify(compareWith)}}};v.oneOf=function oneOf(){var options=Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments);var validators=options.map(function(value){return v.equal(value)});return v.oneOfType.apply(this,validators)};v.range=function range(compareWith){var min=compareWith[0];var max=compareWith[1];return function rangeValidator(value){var validationResult=validate(v.number,value);if(validationResult||valuemax){return"number between "+min+" & "+max+" (inclusive)"}}};v.any=function any(){return};v.boolean=function boolean(value){if(typeof value!=="boolean"){return"boolean"}};v.number=function number(value){if(typeof value!=="number"){return"number"}};v.plainArray=function plainArray(value){if(!Array.isArray(value)){return"array"}};v.plainObject=function plainObject(value){if(!isPlainObj(value)){return"object"}};v.string=function string(value){if(typeof value!=="string"){return"string"}};v.func=function func(value){if(typeof value!=="function"){return"function"}};function validate(validator,value){if(value==null&&!validator.hasOwnProperty("__required")){return}var result=validator(value);if(result){return Array.isArray(result)?result:[result]}}function processMessage(message,options){var len=message.length;var result=message[len-1];var path=message.slice(0,len-1);if(path.length===0){path=[DEFAULT_ERROR_PATH]}options=immutable(options,{path:path});return typeof result==="function"?result(options):formatErrorMessage(options,prettifyResult(result))}function orList(list){if(list.length<2){return list[0]}if(list.length===2){return list.join(" or ")}return list.slice(0,-1).join(", ")+", or "+list.slice(-1)}function prettifyResult(result){return"must be "+addArticle(result)+"."}function addArticle(nounPhrase){if(/^an? /.test(nounPhrase)){return nounPhrase}if(/^[aeiou]/i.test(nounPhrase)){return"an "+nounPhrase}if(/^[a-z]/i.test(nounPhrase)){return"a "+nounPhrase}return nounPhrase}function formatErrorMessage(options,prettyResult){var arrayCulprit=isArrayCulprit(options.path);var output=options.path.join(".")+" "+prettyResult;var prepend=arrayCulprit?"Item at position ":"";return prepend+output}function isArrayCulprit(path){return typeof path[path.length-1]=="number"||typeof path[0]=="number"}function objectEntries(obj){return Object.keys(obj||{}).map(function(key){return{key:key,value:obj[key]}})}v.validate=validate;v.processMessage=processMessage;var lib=v;function file(value){if(typeof window!=="undefined"){if(value instanceof commonjsGlobal.Blob||value instanceof commonjsGlobal.ArrayBuffer){return}return"Blob or ArrayBuffer"}if(typeof value==="string"||value.pipe!==undefined){return}return"Filename or Readable stream"}function assertShape(validatorObj,apiName){return lib.assert(lib.strictShape(validatorObj),apiName)}function date(value){var msg="date";if(typeof value==="boolean"){return msg}try{var date=new Date(value);if(date.getTime&&isNaN(date.getTime())){return msg}}catch(e){return msg}}function coordinates(value){return lib.tuple(lib.number,lib.number)(value)}var validator=immutable(lib,{file:file,date:date,coordinates:coordinates,assertShape:assertShape});function pick(source,keys){var filter=function(key,val){return keys.indexOf(key)!==-1&&val!==undefined};if(typeof keys==="function"){filter=keys}return Object.keys(source).filter(function(key){return filter(key,source[key])}).reduce(function(result,key){result[key]=source[key];return result},{})}var pick_1=pick;function createServiceFactory(ServicePrototype){return function(clientOrConfig){var client;if(mapiClient.prototype.isPrototypeOf(clientOrConfig)){client=clientOrConfig}else{client=browserClient(clientOrConfig)}var service=Object.create(ServicePrototype);service.client=client;return service}}var createServiceFactory_1=createServiceFactory;var Datasets={};Datasets.listDatasets=function(){return this.client.createRequest({method:"GET",path:"/datasets/v1/:ownerId"})};Datasets.createDataset=function(config){validator.assertShape({name:validator.string,description:validator.string})(config);return this.client.createRequest({method:"POST",path:"/datasets/v1/:ownerId",body:config})};Datasets.getMetadata=function(config){validator.assertShape({datasetId:validator.required(validator.string),description:validator.string})(config);return this.client.createRequest({method:"GET",path:"/datasets/v1/:ownerId/:datasetId",params:config})};Datasets.updateMetadata=function(config){validator.assertShape({datasetId:validator.required(validator.string),name:validator.string,description:validator.string})(config);return this.client.createRequest({method:"PATCH",path:"/datasets/v1/:ownerId/:datasetId",params:pick_1(config,["datasetId"]),body:pick_1(config,["name","description"])})};Datasets.deleteDataset=function(config){validator.assertShape({datasetId:validator.required(validator.string)})(config);return this.client.createRequest({method:"DELETE",path:"/datasets/v1/:ownerId/:datasetId",params:config})};Datasets.listFeatures=function(config){validator.assertShape({datasetId:validator.required(validator.string),limit:validator.number,start:validator.string})(config);return this.client.createRequest({method:"GET",path:"/datasets/v1/:ownerId/:datasetId/features",params:pick_1(config,["datasetId"]),query:pick_1(config,["limit","start"])})};Datasets.putFeature=function(config){validator.assertShape({datasetId:validator.required(validator.string),featureId:validator.required(validator.string),feature:validator.required(validator.plainObject)})(config);if(config.feature.id!==undefined&&config.feature.id!==config.featureId){throw new Error("featureId must match the id property of the feature")}return this.client.createRequest({method:"PUT",path:"/datasets/v1/:ownerId/:datasetId/features/:featureId",params:pick_1(config,["datasetId","featureId"]),body:config.feature})};Datasets.getFeature=function(config){validator.assertShape({datasetId:validator.required(validator.string),featureId:validator.required(validator.string)})(config);return this.client.createRequest({method:"GET",path:"/datasets/v1/:ownerId/:datasetId/features/:featureId",params:config})};Datasets.deleteFeature=function(config){validator.assertShape({datasetId:validator.required(validator.string),featureId:validator.required(validator.string)})(config);return this.client.createRequest({method:"DELETE",path:"/datasets/v1/:ownerId/:datasetId/features/:featureId",params:config})};var datasets=createServiceFactory_1(Datasets);function objectClean(obj){return pick_1(obj,function(_,val){return val!=null})}var objectClean_1=objectClean;function objectMap(obj,cb){return Object.keys(obj).reduce(function(result,key){result[key]=cb(key,obj[key]);return result},{})}var objectMap_1=objectMap;function stringifyBoolean(obj){return objectMap_1(obj,function(_,value){return typeof value==="boolean"?JSON.stringify(value):value})}var stringifyBooleans=stringifyBoolean;var Directions={};Directions.getDirections=function(config){validator.assertShape({profile:validator.oneOf("driving-traffic","driving","walking","cycling"),waypoints:validator.required(validator.arrayOf(validator.shape({coordinates:validator.required(validator.coordinates),approach:validator.oneOf("unrestricted","curb"),bearing:validator.arrayOf(validator.range([0,360])),radius:validator.oneOfType(validator.number,validator.equal("unlimited")),waypointName:validator.string}))),alternatives:validator.boolean,annotations:validator.arrayOf(validator.oneOf("duration","distance","speed","congestion")),bannerInstructions:validator.boolean,continueStraight:validator.boolean,exclude:validator.string,geometries:validator.string,language:validator.string,overview:validator.string,roundaboutExits:validator.boolean,steps:validator.boolean,voiceInstructions:validator.boolean,voiceUnits:validator.string})(config);config.profile=config.profile||"driving";var path={coordinates:[],approach:[],bearing:[],radius:[],waypointName:[]};var waypointCount=config.waypoints.length;if(waypointCount<2||waypointCount>25){throw new Error("waypoints must include between 2 and 25 DirectionsWaypoints")}config.waypoints.forEach(function(waypoint){path.coordinates.push(waypoint.coordinates[0]+","+waypoint.coordinates[1]);["bearing"].forEach(function(prop){if(waypoint.hasOwnProperty(prop)&&waypoint[prop]!=null){waypoint[prop]=waypoint[prop].join(",")}});["approach","bearing","radius","waypointName"].forEach(function(prop){if(waypoint.hasOwnProperty(prop)&&waypoint[prop]!=null){path[prop].push(waypoint[prop])}else{path[prop].push("")}})});["approach","bearing","radius","waypointName"].forEach(function(prop){if(path[prop].every(function(char){return char===""})){delete path[prop]}else{path[prop]=path[prop].join(";")}});var query=stringifyBooleans({alternatives:config.alternatives,annotations:config.annotations,banner_instructions:config.bannerInstructions,continue_straight:config.continueStraight,exclude:config.exclude,geometries:config.geometries,language:config.language,overview:config.overview,roundabout_exits:config.roundaboutExits,steps:config.steps,voice_instructions:config.voiceInstructions,voice_units:config.voiceUnits,approaches:path.approach,bearings:path.bearing,radiuses:path.radius,waypoint_names:path.waypointName});return this.client.createRequest({method:"GET",path:"/directions/v5/mapbox/:profile/:coordinates",params:{profile:config.profile,coordinates:path.coordinates.join(";")},query:objectClean_1(query)})};var directions=createServiceFactory_1(Directions);var Geocoding={};var featureTypes=["country","region","postcode","district","place","locality","neighborhood","address","poi","poi.landmark"];Geocoding.forwardGeocode=function(config){validator.assertShape({query:validator.required(validator.string),mode:validator.oneOf("mapbox.places","mapbox.places-permanent"),countries:validator.arrayOf(validator.string),proximity:validator.coordinates,types:validator.arrayOf(validator.oneOf(featureTypes)),autocomplete:validator.boolean,bbox:validator.arrayOf(validator.number),limit:validator.number,language:validator.arrayOf(validator.string)})(config);config.mode=config.mode||"mapbox.places";var query=stringifyBooleans(immutable({country:config.countries},pick_1(config,["proximity","types","autocomplete","bbox","limit","language"])));return this.client.createRequest({method:"GET",path:"/geocoding/v5/:mode/:query.json",params:pick_1(config,["mode","query"]),query:query})};Geocoding.reverseGeocode=function(config){validator.assertShape({query:validator.required(validator.coordinates),mode:validator.oneOf("mapbox.places","mapbox.places-permanent"),countries:validator.arrayOf(validator.string),types:validator.arrayOf(validator.oneOf(featureTypes)),bbox:validator.arrayOf(validator.number),limit:validator.number,language:validator.arrayOf(validator.string),reverseMode:validator.oneOf("distance","score")})(config);config.mode=config.mode||"mapbox.places";var query=stringifyBooleans(immutable({country:config.countries},pick_1(config,["country","types","bbox","limit","language","reverseMode"])));return this.client.createRequest({method:"GET",path:"/geocoding/v5/:mode/:query.json",params:pick_1(config,["mode","query"]),query:query})};var geocoding=createServiceFactory_1(Geocoding);var MapMatching={};MapMatching.getMatch=function(config){validator.assertShape({points:validator.required(validator.arrayOf(validator.shape({coordinates:validator.required(validator.coordinates),approach:validator.oneOf("unrestricted","curb"),radius:validator.range([0,50]),isWaypoint:validator.boolean,waypointName:validator.string,timestamp:validator.date}))),profile:validator.oneOf("driving-traffic","driving","walking","cycling"),annotations:validator.arrayOf(validator.oneOf("duration","distance","speed")),geometries:validator.oneOf("geojson","polyline","polyline6"),language:validator.string,overview:validator.oneOf("full","simplified","false"),steps:validator.boolean,tidy:validator.boolean})(config);var pointCount=config.points.length;if(pointCount<2||pointCount>100){throw new Error("points must include between 2 and 100 MapMatchingPoints")}config.profile=config.profile||"driving";var path={coordinates:[],approach:[],radius:[],isWaypoint:[],waypointName:[],timestamp:[]};config.points.forEach(function(obj){path.coordinates.push(obj.coordinates[0]+","+obj.coordinates[1]);if(obj.hasOwnProperty("isWaypoint")&&obj.isWaypoint!=null){path.isWaypoint.push(obj.isWaypoint)}else{path.isWaypoint.push(true)}if(obj.hasOwnProperty("timestamp")&&obj.timestamp!=null){path.timestamp.push(Number(new Date(obj.timestamp)))}else{path.timestamp.push("")}["approach","radius","waypointName"].forEach(function(prop){if(obj.hasOwnProperty(prop)&&obj[prop]!=null){path[prop].push(obj[prop])}else{path[prop].push("")}})});["coordinates","approach","radius","waypointName","timestamp"].forEach(function(prop){if(path[prop].every(function(value){return value===""})){delete path[prop]}else{path[prop]=path[prop].join(";")}});path.isWaypoint[0]=true;path.isWaypoint[path.isWaypoint.length-1]=true;if(path.isWaypoint.every(function(value){return value===true})){delete path.isWaypoint}else{path.isWaypoint=path.isWaypoint.map(function(val,i){return val===true?i:""}).join(";")}var body=stringifyBooleans(objectClean_1({annotations:config.annotations,geometries:config.geometries,language:config.language,overview:config.overview,steps:config.steps,tidy:config.tidy,approaches:path.approach,radiuses:path.radius,waypoints:path.isWaypoint,timestamps:path.timestamp,waypoint_names:path.waypointName,coordinates:path.coordinates}));return this.client.createRequest({method:"POST",path:"/matching/v5/mapbox/:profile",params:{profile:config.profile},body:urlUtils.appendQueryObject("",body).substring(1),headers:{"content-type":"application/x-www-form-urlencoded"}})};var mapMatching=createServiceFactory_1(MapMatching);var Matrix={};Matrix.getMatrix=function(config){validator.assertShape({points:validator.required(validator.arrayOf(validator.shape({coordinates:validator.required(validator.coordinates),approach:validator.oneOf("unrestricted","curb")}))),profile:validator.oneOf("driving-traffic","driving","walking","cycling"),annotations:validator.arrayOf(validator.oneOf("duration","distance")),sources:validator.oneOfType(validator.equal("all"),validator.arrayOf(validator.number)),destinations:validator.oneOfType(validator.equal("all"),validator.arrayOf(validator.number))})(config);var pointCount=config.points.length;if(pointCount<2||pointCount>100){throw new Error("points must include between 2 and 100 MatrixPoints")}config.profile=config.profile||"driving";var path={coordinates:[],approach:[]};config.points.forEach(function(obj){path.coordinates.push(obj.coordinates[0]+","+obj.coordinates[1]);if(obj.hasOwnProperty("approach")&&obj.approach!=null){path.approach.push(obj.approach)}else{path.approach.push("")}});if(path.approach.every(function(value){return value===""})){delete path.approach}else{path.approach=path.approach.join(";")}var query={sources:Array.isArray(config.sources)?config.sources.join(";"):config.sources,destinations:Array.isArray(config.destinations)?config.destinations.join(";"):config.destinations,approaches:path.approach,annotations:config.annotations&&config.annotations.join(",")};return this.client.createRequest({method:"GET",path:"/directions-matrix/v1/mapbox/:profile/:coordinates",params:{profile:config.profile,coordinates:path.coordinates.join(";")},query:objectClean_1(query)})};var matrix=createServiceFactory_1(Matrix);var Optimization={};Optimization.getOptimization=function(config){validator.assertShape({profile:validator.oneOf("driving","walking","cycling"),waypoints:validator.required(validator.arrayOf(validator.shape({coordinates:validator.required(validator.coordinates),approach:validator.oneOf("unrestricted","curb"),bearing:validator.arrayOf(validator.range([0,360])),radius:validator.oneOfType(validator.number,validator.equal("unlimited"))}))),annotations:validator.arrayOf(validator.oneOf("duration","distance","speed")),geometries:validator.oneOf("geojson","polyline","polyline6"),language:validator.string,overview:validator.oneOf("simplified","full","false"),roundtrip:validator.boolean,steps:validator.boolean,source:validator.oneOf("any","first"),destination:validator.oneOf("any","last"),distributions:validator.arrayOf(validator.shape({pickup:validator.number,dropoff:validator.number}))})(config);var path={coordinates:[],approach:[],bearing:[],radius:[],distributions:[]};var waypointCount=config.waypoints.length;if(waypointCount<2||waypointCount>12){throw new Error("waypoints must include between 2 and 12 OptimizationWaypoints")}config.waypoints.forEach(function(waypoint){path.coordinates.push(waypoint.coordinates[0]+","+waypoint.coordinates[1]);["bearing"].forEach(function(prop){if(waypoint.hasOwnProperty(prop)&&waypoint[prop]!=null){waypoint[prop]=waypoint[prop].join(",")}});["approach","bearing","radius"].forEach(function(prop){if(waypoint.hasOwnProperty(prop)&&waypoint[prop]!=null){path[prop].push(waypoint[prop])}else{path[prop].push("")}})});if(config.distributions){config.distributions.forEach(function(dist){path.distributions.push(dist.pickup+","+dist.dropoff)})}["approach","bearing","radius","distributions"].forEach(function(prop){if(path[prop].every(function(char){return char===""})){delete path[prop]}else{path[prop]=path[prop].join(";")}});var query=stringifyBooleans({geometries:config.geometries,language:config.language,overview:config.overview,roundtrip:config.roundtrip,steps:config.steps,source:config.source,destination:config.destination,distributions:path.distributions,approaches:path.approach,bearings:path.bearing,radiuses:path.radius});return this.client.createRequest({method:"GET",path:"/optimized-trips/v1/mapbox/:profile/:coordinates",params:{profile:config.profile||"driving",coordinates:path.coordinates.join(";")},query:objectClean_1(query)})};var optimization=createServiceFactory_1(Optimization);var polyline_1=createCommonjsModule(function(module){var polyline={};function py2_round(value){return Math.floor(Math.abs(value)+.5)*(value>=0?1:-1)}function encode(current,previous,factor){current=py2_round(current*factor);previous=py2_round(previous*factor);var coordinate=current-previous;coordinate<<=1;if(current-previous<0){coordinate=~coordinate}var output="";while(coordinate>=32){output+=String.fromCharCode((32|coordinate&31)+63);coordinate>>=5}output+=String.fromCharCode(coordinate+63);return output}polyline.decode=function(str,precision){var index=0,lat=0,lng=0,coordinates=[],shift=0,result=0,byte=null,latitude_change,longitude_change,factor=Math.pow(10,precision||5);while(index=32);latitude_change=result&1?~(result>>1):result>>1;shift=result=0;do{byte=str.charCodeAt(index++)-63;result|=(byte&31)<=32);longitude_change=result&1?~(result>>1):result>>1;lat+=latitude_change;lng+=longitude_change;coordinates.push([lat/factor,lng/factor])}return coordinates};polyline.encode=function(coordinates,precision){if(!coordinates.length){return""}var factor=Math.pow(10,precision||5),output=encode(coordinates[0][0],0,factor)+encode(coordinates[0][1],0,factor);for(var i=1;i