Created
September 18, 2015 17:19
-
-
Save dianashk/1a372d9e2601d80562fc to your computer and use it in GitHub Desktop.
Run search against multiple focus points with the same input text.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* To run do as follows: | |
* | |
* $ npm install request | |
* $ node locmux.js 'text i want to search for' | |
* | |
* If you'd like more locations to be searched just add them to the list below. | |
* | |
*/ | |
var request = require('request'); | |
var locations = [ | |
{ | |
name: 'London', | |
lat: 51.507222, | |
lon: -0.1275 | |
}, | |
{ | |
name: 'New York', | |
lat: 37.783333, | |
lon: -122.416667 | |
} | |
]; | |
var text = process.argv[2]; | |
locations.forEach(function (loc) { | |
request.get('http://pelias.bigdev.mapzen.com/v1/search?text=' + text + | |
'&focus.point.lat=' + loc.lat + '&focus.point.lon=' + loc.lon, function (err, res) { | |
var results = JSON.parse(res.body); | |
console.log('\n\n\nSearching for "' + text + '" near ' + loc.name); | |
console.log('> result count:', results.features.length); | |
results.features.forEach(function (feature) { | |
console.log(feature.properties.label); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment