diff --git a/API.md b/API.md index ae733db7..0e03e748 100644 --- a/API.md +++ b/API.md @@ -84,6 +84,8 @@ A geocoder component using Mapbox Geocoding API - `options.localGeocoder` **[Function][55]?** A function accepting the query string which performs local geocoding to supplement results from the Mapbox Geocoding API. Expected to return an Array of GeoJSON Features in the [Carmen GeoJSON][56] format. - `options.reverseMode` **(`"distance"` \| `"score"`)** Set the factors that are used to sort nearby results. (optional, default `'distance'`) - `options.reverseGeocode` **[boolean][52]?** Enable reverse geocoding. Defaults to false. Expects coordinates to be lat, lon. + - `options.marker` **([Boolean][52] \| [Object][48])** If `true`, a [Marker][57] will be added to the map at the location of the user-selected result using a default set of Marker options. If the value is an object, the marker will be constructed using these options. If `false`, no marker will be added to the map. (optional, default `true`) + - `options.mapboxgl` **[Object][48]?** A [mapbox-gl][58] instance to use when creating [Markers][57]. Required if `options.marker` is true. - `options.render` **[Function][55]?** A function that specifies how the results should be rendered in the dropdown menu - `options.getItemValue` **[Function][55]?** A function that specifies how the selected result should be rendered in the search bar @@ -94,7 +96,7 @@ var geocoder = new MapboxGeocoder({ accessToken: mapboxgl.accessToken }); map.addControl(geocoder); ``` -Returns **[MapboxGeocoder][57]** `this` +Returns **[MapboxGeocoder][59]** `this` ### query @@ -104,7 +106,7 @@ Set & query the input - `searchInput` **[string][49]** location name or other search input -Returns **[MapboxGeocoder][57]** this +Returns **[MapboxGeocoder][59]** this ### setInput @@ -114,7 +116,7 @@ Set input - `searchInput` **[string][49]** location name or other search input -Returns **[MapboxGeocoder][57]** this +Returns **[MapboxGeocoder][59]** this ### setProximity @@ -124,7 +126,7 @@ Set proximity - `proximity` **[Object][48]** The new options.proximity value. This is a geographical point given as an object with latitude and longitude properties. -Returns **[MapboxGeocoder][57]** this +Returns **[MapboxGeocoder][59]** this ### getProximity @@ -140,7 +142,7 @@ Set the render function used in the results dropdown - `fn` **[Function][55]** The function to use as a render function -Returns **[MapboxGeocoder][57]** this +Returns **[MapboxGeocoder][59]** this ### getRenderFunction @@ -158,7 +160,7 @@ Look first at the explicitly set options otherwise use the browser's language se - `language` **[String][49]** Specify the language to use for response text and query result weighting. Options are IETF language tags comprised of a mandatory ISO 639-1 language code and optionally one or more IETF subtags for country or script. More than one value can also be specified, separated by commas. -Returns **[MapboxGeocoder][57]** this +Returns **[MapboxGeocoder][59]** this ### getLanguage @@ -180,13 +182,13 @@ Set the zoom level - `zoom` **[Number][51]** The zoom level that the map should animate to when a `bbox` isn't found in the response. If a `bbox` is found the map will fit to the `bbox`. -Returns **[MapboxGeocoder][57]** this +Returns **[MapboxGeocoder][59]** this ### getFlyTo Get the parameters used to fly to the selected response, if any -Returns **[MapboxGeocoder][57]** this +Returns **[MapboxGeocoder][59]** this ### setFlyTo @@ -210,7 +212,7 @@ Set the value of the input element's placeholder - `placeholder` **[String][49]** the text to use as the input element's placeholder -Returns **[MapboxGeocoder][57]** this +Returns **[MapboxGeocoder][59]** this ### getBbox @@ -226,7 +228,7 @@ Set the bounding box to limit search results to - `bbox` **[Array][53]<[Number][51]>** a bounding box given as an array in the format [minX, minY, maxX, maxY]. -Returns **[MapboxGeocoder][57]** this +Returns **[MapboxGeocoder][59]** this ### getCountries @@ -242,7 +244,7 @@ Set the countries to limit search results to - `countries` **[String][49]** a comma separated list of countries to limit to -Returns **[MapboxGeocoder][57]** this +Returns **[MapboxGeocoder][59]** this ### getTypes @@ -259,7 +261,7 @@ Set the types to limit search results to - `types` - `countries` **[String][49]** a comma separated list of types to limit to -Returns **[MapboxGeocoder][57]** this +Returns **[MapboxGeocoder][59]** this ### getMinLength @@ -275,7 +277,7 @@ Set the minimum number of characters typed to trigger results used by the plugin - `minLength` **[Number][51]** the minimum length in characters -Returns **[MapboxGeocoder][57]** this +Returns **[MapboxGeocoder][59]** this ### getLimit @@ -291,7 +293,7 @@ Set the limit value for the number of results to display used by the plugin - `limit` **[Number][51]** the number of search results to return -Returns **[MapboxGeocoder][57]** +Returns **[MapboxGeocoder][59]** ### getFilter @@ -307,7 +309,7 @@ Set the filter function used by the plugin. - `filter` **[Function][55]** A function which accepts a Feature in the [Carmen GeoJSON][56] format to filter out results from the Geocoding API response before they are included in the suggestions list. Return `true` to keep the item, `false` otherwise. -Returns **[MapboxGeocoder][57]** this +Returns **[MapboxGeocoder][59]** this ### on @@ -322,7 +324,7 @@ Subscribe to events that happen within the plugin. - **error** `{ error } Error as string` - `fn` **[Function][55]** function that's called when the event is emitted. -Returns **[MapboxGeocoder][57]** this; +Returns **[MapboxGeocoder][59]** this; ### off @@ -333,7 +335,7 @@ Remove an event - `type` **[String][49]** Event name. - `fn` **[Function][55]** Function that should unsubscribe to the event emitted. -Returns **[MapboxGeocoder][57]** this +Returns **[MapboxGeocoder][59]** this [1]: #mapboxgeocoder @@ -447,4 +449,8 @@ Returns **[MapboxGeocoder][57]** this [56]: https://github.com/mapbox/carmen/blob/master/carmen-geojson.md -[57]: #mapboxgeocoder +[57]: https://docs.mapbox.com/mapbox-gl-js/api/#marker + +[58]: https://github.com/mapbox/mapbox-gl-js + +[59]: #mapboxgeocoder diff --git a/CHANGELOG.md b/CHANGELOG.md index 746cb53f..ea0b8ad8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,11 @@ ## Master +- Support for the Mapbox GL JS 0.47.0 API. This is compatible with 0.47.0 and later, and may not be compatible with earlier versions. - Pass `flyTo` options to the map on result selection on both map#flyTo and map#fitBounds operations [#214](https://github.com/mapbox/mapbox-gl-geocoder/pull/214) and [#227](https://github.com/mapbox/mapbox-gl-geocoder/pull/227) - Obtain language from user's browser settings [#195](https://github.com/mapbox/mapbox-gl-geocoder/issues/195) - Localize placeholder based on language set in constructor options [#150](https://github.com/mapbox/mapbox-gl-geocoder/issues/150) - `trackProximity` turned on by default [#195](https://github.com/mapbox/mapbox-gl-geocoder/issues/195) - Bump suggestions to v1.3.4 +- Adds the `marker` constructor option that allows adding the selected result to the map as a [marker](https://docs.mapbox.com/mapbox-gl-js/api/#marker). Adding the marker to the map is now the default behavior. [#219](https://github.com/mapbox/mapbox-gl-geocoder/pull/219). - Upgrade dev dependencies - Remove hardcoded IDs in bounding box exception list - Fix duplicate event bug diff --git a/debug/index.js b/debug/index.js index 05720982..2fe727e2 100644 --- a/debug/index.js +++ b/debug/index.js @@ -38,8 +38,8 @@ var coordinatesGeocoder = function(query) { return null; } function coordinateFeature(lng, lat) { - var lng = Number(lng); - var lat = Number(lat); + lng = Number(lng); + lat = Number(lat); return { center: [lng, lat], geometry: { @@ -76,7 +76,8 @@ var geocoder = new MapboxGeocoder({ trackProximity: true, localGeocoder: function(query) { return coordinatesGeocoder(query); - } + }, + mapboxgl: mapboxgl }); window.geocoder = geocoder; diff --git a/lib/index.js b/lib/index.js index 7d157875..8e804753 100644 --- a/lib/index.js +++ b/lib/index.js @@ -43,6 +43,8 @@ var geocoderService; * @param {Function} [options.localGeocoder] A function accepting the query string which performs local geocoding to supplement results from the Mapbox Geocoding API. Expected to return an Array of GeoJSON Features in the [Carmen GeoJSON](https://github.com/mapbox/carmen/blob/master/carmen-geojson.md) format. * @param {'distance'|'score'} [options.reverseMode='distance'] - Set the factors that are used to sort nearby results. * @param {boolean} [options.reverseGeocode] Enable reverse geocoding. Defaults to false. Expects coordinates to be lat, lon. + * @param {Boolean|Object} [options.marker=true] If `true`, a [Marker](https://docs.mapbox.com/mapbox-gl-js/api/#marker) will be added to the map at the location of the user-selected result using a default set of Marker options. If the value is an object, the marker will be constructed using these options. If `false`, no marker will be added to the map. + * @param {Object} [options.mapboxgl] A [mapbox-gl](https://github.com/mapbox/mapbox-gl-js) instance to use when creating [Markers](https://docs.mapbox.com/mapbox-gl-js/api/#marker). Required if `options.marker` is true. * @param {Function} [options.render] A function that specifies how the results should be rendered in the dropdown menu * @param {Function} [options.getItemValue] A function that specifies how the selected result should be rendered in the search bar * @example @@ -69,6 +71,8 @@ MapboxGeocoder.prototype = { reverseGeocode: false, limit: 5, origin: 'https://api.mapbox.com', + marker: true, + mapboxgl: null, collapsed: false, getItemValue: function(item) { return item.place_name @@ -159,6 +163,15 @@ MapboxGeocoder.prototype = { this._map.on('moveend', this._updateProximity); } + this.mapMarker = null; + this._handleMarker = this._handleMarker.bind(this); + + this._mapboxgl = this.options.mapboxgl; + if (!this._mapboxgl && this.options.marker) { + console.error("No mapboxgl detected in options. Map markers are disabled. Please set options.mapboxgl."); + this.options.marker = false; + } + return el; }, @@ -180,6 +193,8 @@ MapboxGeocoder.prototype = { this._map.off('moveend', this._updateProximity); } + this._removeMarker(); + this._map = null; return this; @@ -245,6 +260,10 @@ MapboxGeocoder.prototype = { this._map.flyTo(flyOptions); } } + if (this.options.marker && this._mapboxgl){ + this._handleMarker(selected); + } + this._eventEmitter.emit('result', { result: selected }); this.eventManager.select(selected, this); this.lastSelected = selected.id; @@ -378,9 +397,9 @@ MapboxGeocoder.prototype = { this._onChange(); this._inputEl.focus(); this._clearEl.style.display = 'none'; + this._removeMarker(); this.lastSelected = null; this._eventEmitter.emit('clear'); - // reset the turnstile event this.fresh = true; }, @@ -682,6 +701,37 @@ MapboxGeocoder.prototype = { return this; }, + /** + * Handle the placement of a result marking the selected result + * @private + * @param {Object} selected the selected geojson feature + * @returns {MapboxGeocoder} this + */ + _handleMarker: function(selected){ + // clean up any old marker that might be present + this._removeMarker(); + var defaultMarkerOptions = { + color: '#4668F2' + } + var markerOptions = extend({}, defaultMarkerOptions, this.options.marker) + this.mapMarker = new this._mapboxgl.Marker(markerOptions); + this.mapMarker + .setLngLat(selected.center) + .addTo(this._map); + return this; + }, + + /** + * Handle the removal of a result marker + * @private + */ + _removeMarker: function(){ + if (this.mapMarker){ + this.mapMarker.remove(); + this.mapMarker = null; + } + }, + /** * Subscribe to events that happen within the plugin. * @param {String} type name of event. Available events and the data passed into their respective event objects are: diff --git a/package-lock.json b/package-lock.json index 50c6030f..4e36a0db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1250,6 +1250,27 @@ "xtend": "^4.0.1" } }, + "@mapbox/geojson-area": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/@mapbox/geojson-area/-/geojson-area-0.2.2.tgz", + "integrity": "sha1-GNeBSqNr8j+7zDefjiaiKSfevxA=", + "dev": true, + "requires": { + "wgs84": "0.0.0" + } + }, + "@mapbox/jsonlint-lines-primitives": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@mapbox/jsonlint-lines-primitives/-/jsonlint-lines-primitives-2.0.2.tgz", + "integrity": "sha1-zlblOfg1UrWNENZy6k1vya3HsjQ=", + "dev": true + }, + "@mapbox/mapbox-gl-supported": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@mapbox/mapbox-gl-supported/-/mapbox-gl-supported-1.4.0.tgz", + "integrity": "sha512-ZD0Io4XK+/vU/4zpANjOtdWfVszAgnaMPsGR6LKsWh4kLIEv9qoobTVmJPPuwuM+ZI2b3BlZ6DYw1XHVmv6YTA==", + "dev": true + }, "@mapbox/mapbox-sdk": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/@mapbox/mapbox-sdk/-/mapbox-sdk-0.5.0.tgz", @@ -1272,11 +1293,50 @@ "base-64": "^0.1.0" } }, + "@mapbox/point-geometry": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@mapbox/point-geometry/-/point-geometry-0.1.0.tgz", + "integrity": "sha1-ioP5M1x4YO/6Lu7KJUMyqgru2PI=", + "dev": true + }, "@mapbox/polyline": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@mapbox/polyline/-/polyline-1.0.0.tgz", "integrity": "sha512-5Vu99e/+kVF0h0eiWa3er3bYnjorq6SGTn06HqeinFAETlQpcHGj7+DanmFlNyXkgvRcKi0nQytuMm6QA2CkAQ==" }, + "@mapbox/shelf-pack": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@mapbox/shelf-pack/-/shelf-pack-3.2.0.tgz", + "integrity": "sha512-dyQxe6ukILV6qaEvxoKCIwhblgRjYp1ZGlClo4xvfbmxzFO5LYu7Tnrg2AZrRgN7VsSragsGcNjzUe9kCdKHYQ==", + "dev": true + }, + "@mapbox/tiny-sdf": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@mapbox/tiny-sdf/-/tiny-sdf-1.1.0.tgz", + "integrity": "sha512-dnhyk8X2BkDRWImgHILYAGgo+kuciNYX30CUKj/Qd5eNjh54OWM/mdOS/PWsPeN+3abtN+QDGYM4G220ynVJKA==", + "dev": true + }, + "@mapbox/unitbezier": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/@mapbox/unitbezier/-/unitbezier-0.0.0.tgz", + "integrity": "sha1-FWUb1VOme4WB+zmIEMmK2Go0Uk4=", + "dev": true + }, + "@mapbox/vector-tile": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@mapbox/vector-tile/-/vector-tile-1.3.1.tgz", + "integrity": "sha512-MCEddb8u44/xfQ3oD+Srl/tNcQoqTw3goGk2oLsrFxOTc3dUp+kAnby3PvAeeBYSMSjSPD1nd1AJA6W49WnoUw==", + "dev": true, + "requires": { + "@mapbox/point-geometry": "~0.1.0" + } + }, + "@mapbox/whoots-js": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@mapbox/whoots-js/-/whoots-js-3.1.0.tgz", + "integrity": "sha512-Es6WcD0nO5l+2BOQS4uLfNPYQaNDfbot3X1XUoloz+x0mPDS3eeORZJl06HXjwBG1fOGwCRnzK88LMdxKRrd6Q==", + "dev": true + }, "@samverschueren/stream-to-observable": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz", @@ -1337,12 +1397,6 @@ "through": ">=2.2.7 <3" } }, - "JSV": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/JSV/-/JSV-4.0.2.tgz", - "integrity": "sha1-0Hf2glVx+CEy+d/67Vh7QCn+/1c=", - "dev": true - }, "acorn": { "version": "5.7.3", "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", @@ -1392,23 +1446,6 @@ } } }, - "acorn-object-spread": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/acorn-object-spread/-/acorn-object-spread-1.0.0.tgz", - "integrity": "sha1-SOrQ9KjrFplaF6Dbn/xqyq2kumg=", - "dev": true, - "requires": { - "acorn": "^3.1.0" - }, - "dependencies": { - "acorn": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", - "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", - "dev": true - } - } - }, "acorn-walk": { "version": "6.1.1", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-6.1.1.tgz", @@ -1483,6 +1520,12 @@ "integrity": "sha1-6uy/Zs1waIJ2Cy9GkVgrj1XXp94=", "dev": true }, + "ansicolors": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/ansicolors/-/ansicolors-0.2.1.tgz", + "integrity": "sha1-vgiVmQl7dKXJxKhKDNvNtivYeu8=", + "dev": true + }, "any-observable": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/any-observable/-/any-observable-0.3.0.tgz", @@ -1813,12 +1856,6 @@ "integrity": "sha512-X40FaxyH7t3X+JFAKvb1H9wooWKLRCi8pg3m8poqtdZaIng+bjzp9RvKQCvRjF9isHiPkXspbbXT/zwXLtwgwg==", "dev": true }, - "babylon": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", - "integrity": "sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ==", - "dev": true - }, "bail": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/bail/-/bail-1.0.3.tgz", @@ -2005,24 +2042,6 @@ } } }, - "bops": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/bops/-/bops-0.0.6.tgz", - "integrity": "sha1-CC0dVfoB5g29wuvC26N/ZZVUzzo=", - "dev": true, - "requires": { - "base64-js": "0.0.2", - "to-utf8": "0.0.1" - }, - "dependencies": { - "base64-js": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-0.0.2.tgz", - "integrity": "sha1-Ak8Pcq+iW3X5wO5zzU9V7Bvtl4Q=", - "dev": true - } - } - }, "bounce": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/bounce/-/bounce-1.2.3.tgz", @@ -2224,12 +2243,6 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, - "browserify-package-json": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/browserify-package-json/-/browserify-package-json-1.0.1.tgz", - "integrity": "sha1-mN3oqlxWH9bT/km7qhArdLOW/eo=", - "dev": true - }, "browserify-rsa": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", @@ -2275,82 +2288,6 @@ "node-releases": "^1.1.11" } }, - "buble": { - "version": "0.12.5", - "resolved": "https://registry.npmjs.org/buble/-/buble-0.12.5.tgz", - "integrity": "sha1-xm/+kvn0o8ZdMlYHm3EeK9C8UBM=", - "dev": true, - "requires": { - "acorn": "^3.1.0", - "acorn-jsx": "^3.0.1", - "acorn-object-spread": "^1.0.0", - "chalk": "^1.1.3", - "magic-string": "^0.14.0", - "minimist": "^1.2.0", - "os-homedir": "^1.0.1" - }, - "dependencies": { - "acorn": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", - "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", - "dev": true - }, - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, - "has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "magic-string": { - "version": "0.14.0", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.14.0.tgz", - "integrity": "sha1-VyJK7xcByu7Sc7F6OalW5ysXJGI=", - "dev": true, - "requires": { - "vlq": "^0.2.1" - } - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - } - } - }, - "bubleify": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/bubleify/-/bubleify-0.5.1.tgz", - "integrity": "sha1-9lxHzuMbgMrYuedHu+GH1/5R6Sc=", - "dev": true, - "requires": { - "buble": "^0.12.0", - "object-assign": "^4.0.1" - } - }, "budo": { "version": "11.6.1", "resolved": "https://registry.npmjs.org/budo/-/budo-11.6.1.tgz", @@ -2513,18 +2450,6 @@ "integrity": "sha512-5r2GqsoEb4qMTTN9J+WzXfjov+hjxT+j3u5K+kIVNIwAd99DLCJE9pBIMP1qVeybV6JiijL385Oz0DcYxfbOIg==", "dev": true }, - "call-matcher": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/call-matcher/-/call-matcher-1.1.0.tgz", - "integrity": "sha512-IoQLeNwwf9KTNbtSA7aEBb1yfDbdnzwjCetjkC8io5oGeOmK2CBNdg0xr+tadRYKO0p7uQyZzvon0kXlZbvGrw==", - "dev": true, - "requires": { - "core-js": "^2.0.0", - "deep-equal": "^1.0.0", - "espurify": "^1.6.0", - "estraverse": "^4.0.0" - } - }, "caller-callsite": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/caller-callsite/-/caller-callsite-2.0.0.tgz", @@ -2569,6 +2494,16 @@ "integrity": "sha512-eRhP+nQ6YUkIcNQ6hnvdhMkdc7n3zadog0KXNRxAZTT2kHjUb1yGn71OrPhSn8MOvlX97g5CR97kGVj8fMsXWg==", "dev": true }, + "cardinal": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/cardinal/-/cardinal-0.4.4.tgz", + "integrity": "sha1-ylu2iltRG5D+k7ms6km97lwyv+I=", + "dev": true, + "requires": { + "ansicolors": "~0.2.1", + "redeyed": "~0.4.0" + } + }, "caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", @@ -3013,12 +2948,6 @@ "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", "dev": true }, - "core-js": { - "version": "2.6.5", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.5.tgz", - "integrity": "sha512-klh/kDpwX8hryYL14M9w/xei6vrv6sE8gTHDG7/T/+SEovB/G4ejwcfE/CBzO6Edsu+OETZMZ3wcX/EjUkrl5A==", - "dev": true - }, "core-js-compat": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.0.0.tgz", @@ -4352,15 +4281,6 @@ "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=", "dev": true }, - "espurify": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/espurify/-/espurify-1.8.1.tgz", - "integrity": "sha512-ZDko6eY/o+D/gHCWyHTU85mKDgYcS4FJj7S+YD6WIInm7GQ6AnOjmcL4+buFV/JOztVLELi/7MmuGU5NHta0Mg==", - "dev": true, - "requires": { - "core-js": "^2.0.0" - } - }, "esquery": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", @@ -4512,6 +4432,12 @@ } } }, + "expect.js": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/expect.js/-/expect.js-0.2.0.tgz", + "integrity": "sha1-EChTPSwcNj90pnlv9X7AUg3tK+E=", + "dev": true + }, "extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", @@ -4654,12 +4580,6 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, - "fast-stable-stringify": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/fast-stable-stringify/-/fast-stable-stringify-0.1.1.tgz", - "integrity": "sha1-znWNzhy0D7K/DIrvT5PnktGVtJE=", - "dev": true - }, "faye-websocket": { "version": "0.10.0", "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.10.0.tgz", @@ -4669,12 +4589,6 @@ "websocket-driver": ">=0.5.1" } }, - "feature-filter": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/feature-filter/-/feature-filter-2.2.0.tgz", - "integrity": "sha1-PMNWAV6WjDYq+99/8bt0Td9/wuA=", - "dev": true - }, "figures": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", @@ -4775,16 +4689,6 @@ "write": "^0.2.1" } }, - "flow-remove-types": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/flow-remove-types/-/flow-remove-types-1.2.3.tgz", - "integrity": "sha512-ypq/U3V+t9atYiOuSJd40tekCra03EHKoRsiK/wXGrsZimuum0kdwVY7Yv0HTaoXgHW1WiayomYd+Q3kkvPl9Q==", - "dev": true, - "requires": { - "babylon": "^6.15.0", - "vlq": "^0.2.1" - } - }, "flush-write-stream": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.1.1.tgz", @@ -5501,47 +5405,22 @@ "is-property": "^1.0.0" } }, - "geojson-area": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/geojson-area/-/geojson-area-0.1.0.tgz", - "integrity": "sha1-1I2AcILPrfSnjfE0m+UPOL8YlK4=", - "dev": true, - "requires": { - "wgs84": "0.0.0" - } - }, "geojson-rewind": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/geojson-rewind/-/geojson-rewind-0.1.0.tgz", - "integrity": "sha1-VwIqBUsZZmDXVTVP5dJmhNkM0Bk=", + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/geojson-rewind/-/geojson-rewind-0.3.1.tgz", + "integrity": "sha1-IiQHl8hHzC8MHTE+SqDJFa+n8p0=", "dev": true, "requires": { - "concat-stream": "~1.2.1", - "geojson-area": "0.1.0", - "minimist": "0.0.5" - }, - "dependencies": { - "concat-stream": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.2.1.tgz", - "integrity": "sha1-81EAtsRjeL+6i2uA+fDQzN8T3GA=", - "dev": true, - "requires": { - "bops": "0.0.6" - } - }, - "minimist": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.5.tgz", - "integrity": "sha1-16oye87PUY+RBqxrjwA/o7zqhWY=", - "dev": true - } + "@mapbox/geojson-area": "0.2.2", + "concat-stream": "~1.6.0", + "minimist": "1.2.0", + "sharkdown": "^0.1.0" } }, "geojson-vt": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/geojson-vt/-/geojson-vt-2.4.0.tgz", - "integrity": "sha1-PBz0RJPzXrTSxwyV2mVQ3mYHLAU=", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/geojson-vt/-/geojson-vt-3.2.1.tgz", + "integrity": "sha512-EvGQQi/zPrDA6zr6BnJD/YhwAkBP8nnJ9emh3EnHQKVMfg/MRVtPbMYdgVy/IaEmn4UfagD2a6fafPDL5hbtwg==", "dev": true }, "get-assigned-identifiers": { @@ -5765,6 +5644,35 @@ "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==", "dev": true }, + "gray-matter": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/gray-matter/-/gray-matter-3.1.1.tgz", + "integrity": "sha512-nZ1qjLmayEv0/wt3sHig7I0s3/sJO0dkAaKYQ5YAOApUtYEOonXSFdWvL1khvnZMTvov4UufkqlFsilPnejEXA==", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "js-yaml": "^3.10.0", + "kind-of": "^5.0.2", + "strip-bom-string": "^1.0.0" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, "grid-index": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/grid-index/-/grid-index-1.1.0.tgz", @@ -5827,12 +5735,6 @@ } } }, - "has-color": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/has-color/-/has-color-0.1.7.tgz", - "integrity": "sha1-ZxRKUmDDT8PMpnfQQdr1L+e3iy8=", - "dev": true - }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -6953,16 +6855,6 @@ "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", "dev": true }, - "jsonlint-lines-primitives": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/jsonlint-lines-primitives/-/jsonlint-lines-primitives-1.6.0.tgz", - "integrity": "sha1-u4n2DIubYS/ZE92qI2ZJuEDYZhE=", - "dev": true, - "requires": { - "JSV": ">= 4.0.x", - "nomnom": ">= 1.5.x" - } - }, "jsonparse": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", @@ -7030,9 +6922,9 @@ "dev": true }, "kdbush": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/kdbush/-/kdbush-1.0.1.tgz", - "integrity": "sha1-PL0D6d6tnA9vZszblkUOXOzGQOA=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/kdbush/-/kdbush-2.0.1.tgz", + "integrity": "sha512-9KqSdmWCkBIisFIGclT0FRagKhI7IVbMyUjsxCFG0Ly1Dg6whlxJ7b9lrq8ifk3X/fGeJzok1R75LQfZTfA5zQ==", "dev": true }, "keyv": { @@ -7762,29 +7654,6 @@ "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", "dev": true }, - "lodash._baseisequal": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/lodash._baseisequal/-/lodash._baseisequal-3.0.7.tgz", - "integrity": "sha1-2AJfdjOdKTQnZ9zIh85cuVpbUfE=", - "dev": true, - "requires": { - "lodash.isarray": "^3.0.0", - "lodash.istypedarray": "^3.0.0", - "lodash.keys": "^3.0.0" - } - }, - "lodash._bindcallback": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz", - "integrity": "sha1-5THCdkTPi1epnhftlbNcdIeJOS4=", - "dev": true - }, - "lodash._getnative": { - "version": "3.9.1", - "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", - "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=", - "dev": true - }, "lodash.debounce": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", @@ -7796,45 +7665,6 @@ "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", "dev": true }, - "lodash.isarguments": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", - "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", - "dev": true - }, - "lodash.isarray": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz", - "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=", - "dev": true - }, - "lodash.isequal": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-3.0.4.tgz", - "integrity": "sha1-HDXrO27wzR/1F0Pj6jz3/f/ay2Q=", - "dev": true, - "requires": { - "lodash._baseisequal": "^3.0.0", - "lodash._bindcallback": "^3.0.0" - } - }, - "lodash.istypedarray": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/lodash.istypedarray/-/lodash.istypedarray-3.0.6.tgz", - "integrity": "sha1-yaR3SYYHUB2OhJTSg7h8OSgc72I=", - "dev": true - }, - "lodash.keys": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", - "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", - "dev": true, - "requires": { - "lodash._getnative": "^3.0.0", - "lodash.isarguments": "^3.0.0", - "lodash.isarray": "^3.0.0" - } - }, "lodash.memoize": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz", @@ -8062,53 +7892,37 @@ } }, "mapbox-gl": { - "version": "0.27.0", - "resolved": "https://registry.npmjs.org/mapbox-gl/-/mapbox-gl-0.27.0.tgz", - "integrity": "sha1-/wbO9y9kXQbUfwbIvwyb0iHaedY=", - "dev": true, - "requires": { - "bubleify": "^0.5.1", - "csscolorparser": "^1.0.2", - "earcut": "^2.0.3", - "feature-filter": "^2.2.0", - "flow-remove-types": "^1.0.4", - "geojson-rewind": "^0.1.0", - "geojson-vt": "^2.4.0", - "gl-matrix": "^2.3.1", + "version": "0.47.0", + "resolved": "https://registry.npmjs.org/mapbox-gl/-/mapbox-gl-0.47.0.tgz", + "integrity": "sha512-y1AlNYMAKaqEtaqni0zOMYj9gTc1gZ0lqLkxXK9iFg5+ZBITc5DL9AcrXhpEXNxUzXKFa7dZkSULyNaqXFQ8yQ==", + "dev": true, + "requires": { + "@mapbox/jsonlint-lines-primitives": "^2.0.1", + "@mapbox/mapbox-gl-supported": "^1.4.0", + "@mapbox/point-geometry": "^0.1.0", + "@mapbox/shelf-pack": "^3.1.0", + "@mapbox/tiny-sdf": "^1.1.0", + "@mapbox/unitbezier": "^0.0.0", + "@mapbox/vector-tile": "^1.3.1", + "@mapbox/whoots-js": "^3.0.0", + "brfs": "^1.4.4", + "csscolorparser": "~1.0.2", + "earcut": "^2.1.3", + "geojson-rewind": "^0.3.0", + "geojson-vt": "^3.1.4", + "gl-matrix": "^2.6.1", + "gray-matter": "^3.0.8", "grid-index": "^1.0.0", - "mapbox-gl-function": "github:mapbox/mapbox-gl-function#41c6724e2bbd7bd1eb5991451bbf118b7d02b525", - "mapbox-gl-shaders": "github:mapbox/mapbox-gl-shaders#749859b165cd0d96cf52d200e20e3ef7a66e0001", - "mapbox-gl-style-spec": "github:mapbox/mapbox-gl-style-spec#512126c802dbb8f282e9826b181f0d53da00daf2", - "mapbox-gl-supported": "^1.2.0", - "package-json-versionify": "^1.0.2", - "pbf": "^1.3.2", - "pngjs": "^2.2.0", - "point-geometry": "^0.0.0", + "minimist": "0.0.8", + "pbf": "^3.0.5", "quickselect": "^1.0.0", - "request": "^2.39.0", - "shelf-pack": "^1.0.0", - "supercluster": "^2.0.1", + "rw": "^1.3.3", + "shuffle-seed": "^1.1.6", + "sort-object": "^0.3.2", + "supercluster": "^4.0.1", + "through2": "^2.0.3", "tinyqueue": "^1.1.0", - "unassertify": "^2.0.0", - "unflowify": "^1.0.0", - "unitbezier": "^0.0.0", - "vector-tile": "^1.3.0", - "vt-pbf": "^2.0.2", - "webworkify": "^1.4.0", - "whoots-js": "^2.0.0" - } - }, - "mapbox-gl-function": { - "version": "github:mapbox/mapbox-gl-function#41c6724e2bbd7bd1eb5991451bbf118b7d02b525", - "from": "github:mapbox/mapbox-gl-function#41c6724e2bbd7bd1eb5991451bbf118b7d02b525", - "dev": true - }, - "mapbox-gl-shaders": { - "version": "github:mapbox/mapbox-gl-shaders#749859b165cd0d96cf52d200e20e3ef7a66e0001", - "from": "github:mapbox/mapbox-gl-shaders#749859b165cd0d96cf52d200e20e3ef7a66e0001", - "dev": true, - "requires": { - "brfs": "^1.4.0" + "vt-pbf": "^3.0.1" }, "dependencies": { "brfs": { @@ -8132,6 +7946,12 @@ "safe-buffer": "~5.1.1" } }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, "static-module": { "version": "2.2.5", "resolved": "https://registry.npmjs.org/static-module/-/static-module-2.2.5.tgz", @@ -8156,34 +7976,6 @@ } } }, - "mapbox-gl-style-spec": { - "version": "github:mapbox/mapbox-gl-style-spec#512126c802dbb8f282e9826b181f0d53da00daf2", - "from": "github:mapbox/mapbox-gl-style-spec#512126c802dbb8f282e9826b181f0d53da00daf2", - "dev": true, - "requires": { - "csscolorparser": "~1.0.2", - "fast-stable-stringify": "^0.1.1", - "jsonlint-lines-primitives": "~1.6.0", - "lodash.isequal": "^3.0.4", - "minimist": "0.0.8", - "rw": "^0.1.4", - "sort-object": "^0.3.2" - }, - "dependencies": { - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - } - } - }, - "mapbox-gl-supported": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/mapbox-gl-supported/-/mapbox-gl-supported-1.2.0.tgz", - "integrity": "sha1-y9NN+JQgbK3amjPI2aRgnya7GYk=", - "dev": true - }, "markdown-escapes": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/markdown-escapes/-/markdown-escapes-1.0.2.tgz", @@ -8530,26 +8322,6 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, - "multi-stage-sourcemap": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/multi-stage-sourcemap/-/multi-stage-sourcemap-0.2.1.tgz", - "integrity": "sha1-sJ/IWG6qF/gdV1xK0C4Pej9rEQU=", - "dev": true, - "requires": { - "source-map": "^0.1.34" - }, - "dependencies": { - "source-map": { - "version": "0.1.43", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz", - "integrity": "sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y=", - "dev": true, - "requires": { - "amdefine": ">=0.0.4" - } - } - } - }, "mute-stream": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz", @@ -8649,41 +8421,6 @@ "integrity": "sha1-09tNe1aBDZ5AMjQnZigq8HORcps=", "dev": true }, - "nomnom": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/nomnom/-/nomnom-1.8.1.tgz", - "integrity": "sha1-IVH3Ikcrp55Qp2/BJbuMjy5Nwqc=", - "dev": true, - "requires": { - "chalk": "~0.4.0", - "underscore": "~1.6.0" - }, - "dependencies": { - "ansi-styles": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-1.0.0.tgz", - "integrity": "sha1-yxAt8cVvUSPquLZ817mAJ6AnkXg=", - "dev": true - }, - "chalk": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-0.4.0.tgz", - "integrity": "sha1-UZmj3c0MHv4jvAjBsCewYXbgxk8=", - "dev": true, - "requires": { - "ansi-styles": "~1.0.0", - "has-color": "~0.1.0", - "strip-ansi": "~0.1.0" - } - }, - "strip-ansi": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.1.1.tgz", - "integrity": "sha1-OeipjQRNFQZgq+SmgIrPcLt7yZE=", - "dev": true - } - } - }, "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", @@ -8997,15 +8734,6 @@ "integrity": "sha512-H2RyIJ7+A3rjkwKC2l5GGtU4H1vkxKCAGsWasNVd0Set+6i4znxbWy6/j16YDPJDWxhsgZiKAstMEP8wCdSpjA==", "dev": true }, - "package-json-versionify": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/package-json-versionify/-/package-json-versionify-1.0.4.tgz", - "integrity": "sha1-WGBYepRIc6a35tJujlH/siMVvxc=", - "dev": true, - "requires": { - "browserify-package-json": "^1.0.0" - } - }, "pad-left": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/pad-left/-/pad-left-2.1.0.tgz", @@ -9288,13 +9016,13 @@ } }, "pbf": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/pbf/-/pbf-1.3.7.tgz", - "integrity": "sha1-Hj0Ee6PL6Ahq6FSiVQOrRTfUM10=", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/pbf/-/pbf-3.2.0.tgz", + "integrity": "sha512-98Eh7rsJNJF/Im6XYMLaOW3cLnNyedlOd6hu3iWMD5I7FZGgpw8yN3vQBrmLbLodu7G784Irb9Qsv2yFrxSAGw==", "dev": true, "requires": { - "ieee754": "^1.1.6", - "resolve-protobuf-schema": "^2.0.0" + "ieee754": "^1.1.12", + "resolve-protobuf-schema": "^2.1.0" } }, "pbkdf2": { @@ -9429,18 +9157,6 @@ "integrity": "sha1-0aIUg/0iu0HlihL6NCGCMUCJfEU=", "dev": true }, - "pngjs": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-2.3.1.tgz", - "integrity": "sha1-EdHhK5y2TWPjDBQ6Mw9MH1Z9qF8=", - "dev": true - }, - "point-geometry": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/point-geometry/-/point-geometry-0.0.0.tgz", - "integrity": "sha1-b8vK16gDtkGCR91uScKFPFhNr/c=", - "dev": true - }, "posix-character-classes": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", @@ -9803,6 +9519,23 @@ "resolve": "^1.1.6" } }, + "redeyed": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/redeyed/-/redeyed-0.4.4.tgz", + "integrity": "sha1-N+mQpvKyGyoRwuakj9QTVpjLqX8=", + "dev": true, + "requires": { + "esprima": "~1.0.4" + }, + "dependencies": { + "esprima": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz", + "integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0=", + "dev": true + } + } + }, "regenerate": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.0.tgz", @@ -10243,9 +9976,9 @@ "dev": true }, "rw": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/rw/-/rw-0.1.4.tgz", - "integrity": "sha1-SQPL2AJIrg7eaFv1j9I2p6mymj4=", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/rw/-/rw-1.3.3.tgz", + "integrity": "sha1-P4Yt+pGrdmsUiF700BEkv9oHT7Q=", "dev": true }, "rx-lite": { @@ -10303,6 +10036,12 @@ "get-assigned-identifiers": "^1.1.0" } }, + "seedrandom": { + "version": "2.4.4", + "resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-2.4.4.tgz", + "integrity": "sha512-9A+PDmgm+2du77B5i0Ip2cxOqqHjgNxnBgglxLcX78A2D6c2rTo61z4jnVABpF4cKeDMDG+cmXXvdnqse2VqMA==", + "dev": true + }, "semver": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", @@ -10399,6 +10138,37 @@ "integrity": "sha1-QV9CcC1z2BAzApLMXuhurhoRoXA=", "dev": true }, + "sharkdown": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/sharkdown/-/sharkdown-0.1.0.tgz", + "integrity": "sha1-YdT+Up510CRCEnzJI0NiJlCZIU8=", + "dev": true, + "requires": { + "cardinal": "~0.4.2", + "expect.js": "~0.2.0", + "minimist": "0.0.5", + "split": "~0.2.10", + "stream-spigot": "~2.1.2", + "through": "~2.3.4" + }, + "dependencies": { + "minimist": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.5.tgz", + "integrity": "sha1-16oye87PUY+RBqxrjwA/o7zqhWY=", + "dev": true + }, + "split": { + "version": "0.2.10", + "resolved": "https://registry.npmjs.org/split/-/split-0.2.10.tgz", + "integrity": "sha1-Zwl8YB1pfOE2j0GPBs0gHPBSGlc=", + "dev": true, + "requires": { + "through": "2" + } + } + } + }, "shasum": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/shasum/-/shasum-1.0.2.tgz", @@ -10424,12 +10194,6 @@ "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", "dev": true }, - "shelf-pack": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/shelf-pack/-/shelf-pack-1.1.0.tgz", - "integrity": "sha1-tGea/dAK1o39m70rWj6BkpOnTYI=", - "dev": true - }, "shell-quote": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.6.1.tgz", @@ -10470,6 +10234,15 @@ } } }, + "shuffle-seed": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/shuffle-seed/-/shuffle-seed-1.1.6.tgz", + "integrity": "sha1-UzwSaDurO0+j6HUfxOViFGdEJgs=", + "dev": true, + "requires": { + "seedrandom": "^2.4.2" + } + }, "signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", @@ -11186,6 +10959,41 @@ "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=", "dev": true }, + "stream-spigot": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/stream-spigot/-/stream-spigot-2.1.2.tgz", + "integrity": "sha1-feFF6Bn43Q20UJDRPc9zqO08wDU=", + "dev": true, + "requires": { + "readable-stream": "~1.1.0" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + } + } + }, "stream-splicer": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-2.0.0.tgz", @@ -11284,6 +11092,12 @@ "is-utf8": "^0.2.0" } }, + "strip-bom-string": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-bom-string/-/strip-bom-string-1.0.0.tgz", + "integrity": "sha1-5SEekiQ2n7uB1jOi8ABE3IztrZI=", + "dev": true + }, "strip-eof": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", @@ -11320,12 +11134,12 @@ } }, "supercluster": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/supercluster/-/supercluster-2.3.0.tgz", - "integrity": "sha1-h6tWCBu+qaHXJN9TUe6ejDry9Is=", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/supercluster/-/supercluster-4.1.1.tgz", + "integrity": "sha512-sF0FfUOPFp96DKzwWFLeQOEqqKu2PpcesxAFeFsknA/q7g7igVVn/p3NI2XHEghNSyDAqunKNKqAbqNO8+7NDQ==", "dev": true, "requires": { - "kdbush": "^1.0.1" + "kdbush": "^2.0.1" } }, "supports-color": { @@ -11750,12 +11564,6 @@ "through2": "^2.0.3" } }, - "to-utf8": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/to-utf8/-/to-utf8-0.0.1.tgz", - "integrity": "sha1-0Xrqcv8vujm55DYBvns/9y4ImFI=", - "dev": true - }, "toposort": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/toposort/-/toposort-2.0.2.tgz", @@ -11923,43 +11731,6 @@ "integrity": "sha512-4IcGSufhFshvLNcMCV80UnQVlZ5pMOC8mvNPForqwA4+lzYQuetTESLDQkeLmihq8bRcnpbQa48Wb8Lh16/xow==", "dev": true }, - "unassert": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/unassert/-/unassert-1.5.1.tgz", - "integrity": "sha1-y8iOw4dBfFpeTALTzQe+mL11/3Y=", - "dev": true, - "requires": { - "acorn": "^4.0.0", - "call-matcher": "^1.0.1", - "deep-equal": "^1.0.0", - "espurify": "^1.3.0", - "estraverse": "^4.1.0", - "esutils": "^2.0.2", - "object-assign": "^4.1.0" - }, - "dependencies": { - "acorn": { - "version": "4.0.13", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz", - "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=", - "dev": true - } - } - }, - "unassertify": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/unassertify/-/unassertify-2.1.1.tgz", - "integrity": "sha512-YIAaIlc6/KC9Oib8cVZLlpDDhK1UTEuaDyx9BwD97xqxDZC0cJOqwFcs/Y6K3m73B5VzHsRTBLXNO0dxS/GkTw==", - "dev": true, - "requires": { - "acorn": "^5.1.0", - "convert-source-map": "^1.1.1", - "escodegen": "^1.6.1", - "multi-stage-sourcemap": "^0.2.1", - "through": "^2.3.7", - "unassert": "^1.3.1" - } - }, "unc-path-regex": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", @@ -11978,22 +11749,6 @@ "xtend": "^4.0.1" } }, - "underscore": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz", - "integrity": "sha1-izixDKze9jM3uLJOT/htRa6lKag=", - "dev": true - }, - "unflowify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/unflowify/-/unflowify-1.0.1.tgz", - "integrity": "sha1-ouoNJcCv/MRpVeZHNXX3xaH0ppY=", - "dev": true, - "requires": { - "flow-remove-types": "^1.1.2", - "through": "^2.3.8" - } - }, "unherit": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/unherit/-/unherit-1.1.1.tgz", @@ -12165,12 +11920,6 @@ "unist-util-is": "^2.1.2" } }, - "unitbezier": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/unitbezier/-/unitbezier-0.0.0.tgz", - "integrity": "sha1-M79/XXKExTUL/Fx/dw+6dUnFSl4=", - "dev": true - }, "unset-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", @@ -12340,15 +12089,6 @@ "integrity": "sha1-a2GE2mUgzDIEzhtAfKwm2SYJ6/8=", "dev": true }, - "vector-tile": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/vector-tile/-/vector-tile-1.3.0.tgz", - "integrity": "sha1-BtUWqDsGPwTILvU5zxuxrr62lrQ=", - "dev": true, - "requires": { - "point-geometry": "0.0.0" - } - }, "verror": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", @@ -12541,14 +12281,14 @@ "dev": true }, "vt-pbf": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/vt-pbf/-/vt-pbf-2.1.4.tgz", - "integrity": "sha1-td98P5cGFW4LmIGpncsFY1dAtSI=", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/vt-pbf/-/vt-pbf-3.1.1.tgz", + "integrity": "sha512-pHjWdrIoxurpmTcbfBWXaPwSmtPAHS105253P1qyEfSTV2HJddqjM+kIHquaT/L6lVJIk9ltTGc0IxR/G47hYA==", "dev": true, "requires": { - "pbf": "^1.3.2", - "point-geometry": "0.0.0", - "vector-tile": "^1.1.3" + "@mapbox/point-geometry": "0.1.0", + "@mapbox/vector-tile": "^1.3.1", + "pbf": "^3.0.5" } }, "vue-template-compiler": { @@ -12629,12 +12369,6 @@ "integrity": "sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg==", "dev": true }, - "webworkify": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/webworkify/-/webworkify-1.5.0.tgz", - "integrity": "sha512-AMcUeyXAhbACL8S2hqqdqOLqvJ8ylmIbNwUIqQujRSouf4+eUFaXbG6F1Rbu+srlJMmxQWsiU7mOJi0nMBfM1g==", - "dev": true - }, "wgs84": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/wgs84/-/wgs84-0.0.0.tgz", @@ -12656,12 +12390,6 @@ "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=", "dev": true }, - "whoots-js": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/whoots-js/-/whoots-js-2.1.0.tgz", - "integrity": "sha1-vLIBw04OrzNfzOWuLPh0V5qZxIc=", - "dev": true - }, "window-size": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", diff --git a/package.json b/package.json index 56f4c7b7..00fb744f 100644 --- a/package.json +++ b/package.json @@ -47,13 +47,16 @@ "insert-css": "2.0.0", "lint-staged": "^8.1.5", "lodash.once": "^4.0.0", - "mapbox-gl": "^0.27.0", + "mapbox-gl": "^0.47.0", "sinon": "^7.2.7", "smokestack": "^3.3.1", "tap-status": "^1.0.1", "tape": "^4.10.1", "uglify-js": "^2.6.4" }, + "peerDependencies": { + "mapbox-gl": "^0.47.0" + }, "dependencies": { "@mapbox/mapbox-sdk": "^0.5.0", "lodash.debounce": "^4.0.6", diff --git a/test/test.geocoder.js b/test/test.geocoder.js index ea8df0ed..e76e48bd 100644 --- a/test/test.geocoder.js +++ b/test/test.geocoder.js @@ -7,6 +7,7 @@ var once = require('lodash.once'); var mapboxEvents = require('./../lib/events'); var sinon = require('sinon'); var localization = require('./../lib/localization'); +var exceptions = require('./../lib/exceptions'); mapboxgl.accessToken = process.env.MapboxAccessToken; @@ -34,18 +35,18 @@ test('geocoder', function(tt) { }); tt.test('set/get input', function(t) { + t.plan(4) setup({ proximity: { longitude: -79.45, latitude: 43.65 } }); geocoder.query('Queen Street'); + var mapMoveSpy = sinon.spy(map, "flyTo"); geocoder.on( 'result', once(function(e) { t.ok(e.result, 'feature is in the event object'); - map.once('moveend', function() { - var center = map.getCenter(); - t.notEquals(center.lng, 0, 'center.lng changed'); - t.notEquals(center.lat, 0, 'center.lat changed'); - t.end(); - }); + var mapMoveArgs = mapMoveSpy.args[0][0]; + t.ok(mapMoveSpy.calledOnce, 'the map#flyTo method was called when a result was selected'); + t.notEquals(mapMoveArgs.center[0], 0, 'center.lng changed') + t.notEquals(mapMoveArgs.center[1], 0, 'center.lat changed') }) ); }); @@ -232,12 +233,12 @@ test('geocoder', function(tt) { t.plan(1); setup({ zoom: 12 }); geocoder.query('1714 14th St NW'); + var mapMoveSpy = sinon.spy(map, "flyTo"); geocoder.on( 'result', once(function() { - map.once('zoomend', function() { - t.equals(parseInt(map.getZoom()), 12, 'Custom zoom is supported'); - }); + var mapMoveArgs = mapMoveSpy.args[0][0]; + t.equals(mapMoveArgs.zoom, 12, 'custom zoom is supported'); }) ); }); @@ -286,47 +287,45 @@ test('geocoder', function(tt) { }); tt.test('country bbox', function(t) { - t.plan(1); + t.plan(2); setup({}); geocoder.query('Spain'); + var fitBoundsSpy = sinon.spy(map, "fitBounds"); geocoder.on( 'result', once(function(e) { - map.once('moveend', function() { - var mapBBox = Array.prototype.concat.apply( - [], - map.getBounds().toArray() - ); - - t.ok( - mapBBox.some(function(coord, i) { - return coord.toPrecision(4) === e.result.bbox[i].toPrecision(4); - }) - ); - }); + t.ok(fitBoundsSpy.calledOnce, "map#fitBounds was called when a country-level feature was returned") + var fitBoundsArgs = fitBoundsSpy.args[0][0]; + // flatten + var mapBBox = [fitBoundsArgs[0][0], fitBoundsArgs[0][1], fitBoundsArgs[1][0], fitBoundsArgs[1][1]]; + t.ok( + mapBBox.some(function(coord, i) { + return coord.toPrecision(4) === e.result.bbox[i].toPrecision(4); + }) + ); }) ); }); tt.test('country bbox exception', function(t) { - t.plan(1); + t.plan(2); setup({}); geocoder.query('Canada'); + var fitBoundsSpy = sinon.spy(map, "fitBounds"); geocoder.on( 'result', - once(function(e) { - map.once('moveend', function() { - var mapBBox = Array.prototype.concat.apply( - [], - map.getBounds().toArray() - ); - - t.ok( - mapBBox.every(function(coord, i) { - return coord.toPrecision(4) != e.result.bbox[i].toPrecision(4); - }) - ); - }); + once(function() { + t.ok(fitBoundsSpy.calledOnce, 'the map#fitBounds method was called when an excepted feature was returned'); + var fitBoundsArgs = fitBoundsSpy.args[0][0]; + // flatten + var mapBBox = [fitBoundsArgs[0][0], fitBoundsArgs[0][1], fitBoundsArgs[1][0], fitBoundsArgs[1][1]]; + var expectedBBox = exceptions['ca'].bbox; + var expectedBBoxFlat = [expectedBBox[0][0], expectedBBox[0][1], expectedBBox[1][0], expectedBBox[1][1]] + t.ok( + mapBBox.some(function(coord, i) { + return coord.toPrecision(4) === expectedBBoxFlat[i].toPrecision(4); + }) + ); }) ); }); @@ -637,6 +636,84 @@ test('geocoder', function(tt) { t.end(); }); + tt.test('options.marker [true]', function(t) { + t.plan(2); + + setup({ + marker: true, + mapboxgl: mapboxgl + }); + var markerConstructorSpy = sinon.spy(mapboxgl, "Marker"); + + geocoder.query('high'); + geocoder.on( + 'result', + once(function() { + t.ok(markerConstructorSpy.calledOnce, "a new marker is added to the map"); + var calledWithOptions = markerConstructorSpy.args[0][0]; + t.equals(calledWithOptions.color, '#4668F2', 'a default color is set'); + markerConstructorSpy.restore(); + }) + ); + }); + + tt.test('options.marker [constructor properties]', function(t) { + t.plan(4); + + setup({ + marker: { + color: "purple", + draggable: true, + anchor: 'top' + }, + mapboxgl: mapboxgl + }); + var markerConstructorSpy = sinon.spy(mapboxgl, "Marker"); + + geocoder.query('high'); + geocoder.on( + 'result', + once(function() { + t.ok(markerConstructorSpy.calledOnce, "a new marker is added to the map"); + var calledWithOptions = markerConstructorSpy.args[0][0]; + t.equals(calledWithOptions.color, 'purple', "sets the correct color property"); + t.equals(calledWithOptions.draggable, true, "sets the correct draggable property"); + t.equals(calledWithOptions.anchor, 'top', "default anchor is overriden by custom properties"); + markerConstructorSpy.restore(); + }) + ); + }); + + tt.test('options.marker [false]', function(t) { + t.plan(1); + + setup({ + marker: false + }); + var markerConstructorSpy = sinon.spy(mapboxgl, "Marker"); + + geocoder.query('high'); + geocoder.on( + 'result', + once(function() { + t.ok(markerConstructorSpy.notCalled, "a new marker is not added to the map"); + markerConstructorSpy.restore(); + }) + ); + }); + + tt.test('geocode#onRemove', function(t){ + setup({marker: true}); + + var removeMarkerMethod = sinon.spy(geocoder, "_removeMarker"); + + geocoder.onRemove(); + + t.ok(removeMarkerMethod.calledOnce, 'markers are removed when the plugin is removed'); + t.equals(geocoder._map, null, "the map context is removed from the geocoder when the plugin is removed"); + + t.end(); + }) tt.test('geocoder#setLanguage', function(t){ setup({language: 'de-DE'}); t.equals(geocoder.options.language, 'de-DE', 'the correct language is set on initialization'); diff --git a/test/test.ui.js b/test/test.ui.js index 33bc5a54..48488ce8 100644 --- a/test/test.ui.js +++ b/test/test.ui.js @@ -28,12 +28,13 @@ test('Geocoder#inputControl', function(tt) { tt.test('input', function(t) { setup({ - types: 'place' + types: 'place', + mapboxgl: mapboxgl }); var inputEl = container.querySelector('.mapboxgl-ctrl-geocoder input'); var clearEl = container.querySelector('.mapboxgl-ctrl-geocoder button'); - t.plan(7); + t.plan(9); geocoder.on( 'loading', @@ -47,6 +48,7 @@ test('Geocoder#inputControl', function(tt) { 'result', once(function() { t.ok(inputEl.value, 'value populates in input'); + t.ok(geocoder.mapMarker, 'a marker is created to show the selection') clearEl.dispatchEvent(clickEvent); }) ); @@ -56,6 +58,7 @@ test('Geocoder#inputControl', function(tt) { once(function() { t.pass('input was cleared'); t.equals(geocoder.fresh, false, 'the geocoder is fresh again') + t.equals(geocoder.mapMarker, null, 'the marker was reset on clear') geocoder.setInput('Paris'); t.equals(inputEl.value, 'Paris', 'value populates in input'); @@ -122,7 +125,7 @@ test('Geocoder#inputControl', function(tt) { 'placeholder is localized based on language' ); t.end(); - }) + }); tt.test('_clear is not called on keydown (tab), no focus trap', function(t){ t.plan(3);