Comparing version 0.11.0 to 0.12.0
@@ -295,2 +295,4 @@ ## `bulkFeatureUpdate` | ||
* `options.proximity` **`Object`** a proximity argument: this is a geographical point given as an object with latitude and longitude properties. Search results closer to this point will be given higher priority. | ||
* `options.types` **`string`** a comma seperated list of types that filter results to match those specified. See https://www.mapbox.com/developers/api/geocoding/#filter-type for available types. | ||
* `options.country` **`string`** a comma seperated list of country codes to limit results to specified country or countries. | ||
* `options.dataset` **`[string]`** the desired data to be geocoded against. The default, mapbox.places, does not permit unlimited caching. `mapbox.places-permanent` is available on request and does permit permanent caching. (optional, default `mapbox.places`) | ||
@@ -327,3 +329,4 @@ * `callback` **`Function`** called with (err, results) | ||
* `location.longitude` **`number`** decimal degrees longitude, in range -180 to 180 | ||
* `options` **`[Object]`** additional options meant to tune the request (optional, default `{}`) | ||
* `options` **`[Object]`** additional options meant to tune the request. (optional, default `{}`) | ||
* `options.types` **`string`** a comma seperated list of types that filter results to match those specified. See https://www.mapbox.com/developers/api/geocoding/#filter-type for available types. | ||
* `options.dataset` **`[string]`** the desired data to be geocoded against. The default, mapbox.places, does not permit unlimited caching. `mapbox.places-permanent` is available on request and does permit permanent caching. (optional, default `mapbox.places`) | ||
@@ -330,0 +333,0 @@ * `callback` **`Function`** called with (err, results) |
@@ -0,1 +1,5 @@ | ||
## 0.12.0 | ||
- Add types & country options to geocoder [#65](https://github.com/mapbox/mapbox-sdk-js/pull/65) | ||
## 0.11.0 | ||
@@ -2,0 +6,0 @@ |
@@ -5,4 +5,4 @@ // We keep all of the constants that declare endpoints in one | ||
module.exports.DEFAULT_ENDPOINT = 'https://api.mapbox.com'; | ||
module.exports.API_GEOCODER_FORWARD = '/geocoding/v5/{dataset}/{query}.json{?proximity}'; | ||
module.exports.API_GEOCODER_REVERSE = '/geocoding/v5/{dataset}/{longitude},{latitude}.json'; | ||
module.exports.API_GEOCODER_FORWARD = '/geocoding/v5/{dataset}/{query}.json{?proximity,country,types}'; | ||
module.exports.API_GEOCODER_REVERSE = '/geocoding/v5/{dataset}/{longitude},{latitude}.json{?types}'; | ||
module.exports.API_DIRECTIONS = '/v4/directions/{profile}/{encodedWaypoints}.json{?alternatives,instructions,geometry,steps}'; | ||
@@ -9,0 +9,0 @@ module.exports.API_DISTANCE = '/distances/v1/mapbox/{profile}'; |
@@ -12,2 +12,7 @@ 'use strict'; | ||
function roundTo(value, places) { | ||
var mult = Math.pow(10, places); | ||
return Math.round(value * mult) / mult; | ||
} | ||
/** | ||
@@ -24,2 +29,7 @@ * Search for a location with a string, using the | ||
* higher priority. | ||
* @param {string} options.types a comma seperated list of types that filter | ||
* results to match those specified. See https://www.mapbox.com/developers/api/geocoding/#filter-type | ||
* for available types. | ||
* @param {string} options.country a comma seperated list of country codes to | ||
* limit results to specified country or countries. | ||
* @param {string} [options.dataset=mapbox.places] the desired data to be | ||
@@ -80,2 +90,12 @@ * geocoded against. The default, mapbox.places, does not permit unlimited | ||
if (options.country) { | ||
assert(typeof options.country === 'string', 'country option must be string'); | ||
queryOptions.country = options.country; | ||
} | ||
if (options.types) { | ||
assert(typeof options.types === 'string', 'types option must be string'); | ||
queryOptions.types = options.types; | ||
} | ||
this.client({ | ||
@@ -96,3 +116,6 @@ path: constants.API_GEOCODER_FORWARD, | ||
* @param {Object} [options={}] additional options meant to tune | ||
* the request | ||
* the request. | ||
* @param {string} options.types a comma seperated list of types that filter | ||
* results to match those specified. See https://www.mapbox.com/developers/api/geocoding/#filter-type | ||
* for available types. | ||
* @param {string} [options.dataset=mapbox.places] the desired data to be | ||
@@ -129,6 +152,9 @@ * geocoded against. The default, mapbox.places, does not permit unlimited | ||
var dataset = 'mapbox.places'; | ||
var queryOptions = { | ||
dataset: 'mapbox.places' | ||
}; | ||
if (options.dataset) { | ||
assert(typeof options.dataset === 'string', 'dataset option must be string'); | ||
dataset = options.dataset; | ||
queryOptions.dataset = options.dataset; | ||
} | ||
@@ -142,9 +168,13 @@ | ||
if (options.types) { | ||
assert(typeof options.types === 'string', 'types option must be string'); | ||
queryOptions.types = options.types; | ||
} | ||
queryOptions.longitude = roundTo(location.longitude, precision); | ||
queryOptions.latitude = roundTo(location.latitude, precision); | ||
this.client({ | ||
path: constants.API_GEOCODER_REVERSE, | ||
params: { | ||
longitude: roundTo(location.longitude, precision), | ||
latitude: roundTo(location.latitude, precision), | ||
dataset: dataset | ||
}, | ||
params: queryOptions, | ||
callback: callback | ||
@@ -154,7 +184,2 @@ }); | ||
function roundTo(value, places) { | ||
var mult = Math.pow(10, places); | ||
return Math.round(value * mult) / mult; | ||
} | ||
module.exports = MapboxGeocoder; |
{ | ||
"name": "mapbox", | ||
"version": "0.11.0", | ||
"version": "0.12.0", | ||
"description": "interface to mapbox services", | ||
@@ -5,0 +5,0 @@ "main": "lib/mapbox.js", |
@@ -35,2 +35,8 @@ # mapbox-sdk-js | ||
Not currently public | ||
* Datasets | ||
* Retrieve, add, and edit datasets. | ||
* **Note: The Mapbox Datasets API is in private beta. Currently, all end user requests to this API from outside of Mapbox will 404.** | ||
## Installation | ||
@@ -37,0 +43,0 @@ |
@@ -50,2 +50,38 @@ /* eslint no-shadow: 0 */ | ||
t.test('options.country', function(t) { | ||
var client = new MapboxClient(process.env.MapboxAccessToken); | ||
t.ok(client); | ||
var tester = { client: function(opts) { | ||
var params = opts.params; | ||
t.equals(params.country, 'ca', 'country option is set'); | ||
opts.callback(); | ||
}}; | ||
client.geocodeForward.apply(tester, ['Paris', { | ||
country: 'ca' | ||
}, function(err) { | ||
t.ifError(err); | ||
t.end(); | ||
}]); | ||
}); | ||
t.test('options.types', function(t) { | ||
var client = new MapboxClient(process.env.MapboxAccessToken); | ||
t.ok(client); | ||
var tester = { client: function(opts) { | ||
var params = opts.params; | ||
t.equals(params.types, 'country,region', 'types option is set'); | ||
opts.callback(); | ||
}}; | ||
client.geocodeForward.apply(tester, ['Paris', { | ||
types: 'country,region' | ||
}, function(err) { | ||
t.ifError(err); | ||
t.end(); | ||
}]); | ||
}); | ||
t.test('options.proximity', function(t) { | ||
@@ -70,3 +106,3 @@ var client = new MapboxClient(process.env.MapboxAccessToken); | ||
}); | ||
t.ok(opts.params.proximity, 'proximity is set') | ||
t.ok(opts.params.proximity, 'proximity is set'); | ||
opts.callback(); | ||
@@ -78,3 +114,3 @@ }}; | ||
proximity: { latitude: 33.6875431, longitude: -95.4431142 } | ||
}, function(err, results) { | ||
}, function(err) { | ||
t.ifError(err); | ||
@@ -92,3 +128,3 @@ t.end(); | ||
}); | ||
t.ok(opts.params.proximity, 'proximity is set') | ||
t.ok(opts.params.proximity, 'proximity is set'); | ||
opts.callback(); | ||
@@ -101,3 +137,3 @@ }}; | ||
precision: 1 | ||
}, function(err, results) { | ||
}, function(err) { | ||
t.ifError(err); | ||
@@ -140,5 +176,24 @@ t.end(); | ||
t.test('dataset option', function(t) { | ||
t.test('options.types', function(t) { | ||
var client = new MapboxClient(process.env.MapboxAccessToken); | ||
t.ok(client); | ||
var tester = { client: function(opts) { | ||
var params = opts.params; | ||
t.equals(params.types, 'country,region', 'types option is set'); | ||
opts.callback(); | ||
}}; | ||
client.geocodeReverse.apply(tester, [ | ||
{ latitude: 33.6875431, longitude: -95.4431142 }, | ||
{ types: 'country,region' }, | ||
function(err) { | ||
t.ifError(err); | ||
t.end(); | ||
}]); | ||
}); | ||
t.test('options.dataset', function(t) { | ||
var client = new MapboxClient(process.env.MapboxAccessToken); | ||
t.ok(client); | ||
client.geocodeReverse( | ||
@@ -161,4 +216,4 @@ { latitude: 33.6875431, longitude: -95.4431142 }, | ||
}); | ||
t.ok(opts.params.longitude, 'longitude is set') | ||
t.ok(opts.params.latitude, 'latitude is set') | ||
t.ok(opts.params.longitude, 'longitude is set'); | ||
t.ok(opts.params.latitude, 'latitude is set'); | ||
opts.callback(); | ||
@@ -171,3 +226,3 @@ }}; | ||
longitude: -95.4431142 | ||
}, function(err, results) { | ||
}, function(err) { | ||
t.ifError(err); | ||
@@ -185,4 +240,4 @@ t.end(); | ||
}); | ||
t.ok(opts.params.longitude, 'longitude is set') | ||
t.ok(opts.params.latitude, 'latitude is set') | ||
t.ok(opts.params.longitude, 'longitude is set'); | ||
t.ok(opts.params.latitude, 'latitude is set'); | ||
opts.callback(); | ||
@@ -197,3 +252,3 @@ }}; | ||
precision: 2 | ||
}, function(err, results) { | ||
}, function(err) { | ||
t.ifError(err); | ||
@@ -200,0 +255,0 @@ t.end(); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
501391
10809
74
0
101