A node library for consuming Cloudmade APIs. Currently only supports Geocoding.
- Geocoding
- Output types for JSON, GeoJSON, Property list and HTML
npm install cloudmade-lib
To retrieve results in JSON format, see the following example:
var
cloudmade = require('cloudmade-lib'),
geocoding = cloudmade.geocoding.initialize({
apikey : 'your_api_key_here'
});
geocoding.get('8727 148th Ave NE, Redmond, WA 98052', function (err, data) {
// work with results here...
});
By default, the timeout for connecting to the Cloudmade API is 5 seconds. This can be overridden via the options parameter which accepts a value in milliseconds.
var
cloudmade = require('cloudmade-lib'),
geocoding = cloudmade.geocoding.initialize({
apikey : 'your_api_key_here'
});
geocoding.get({ timeout : 10000 }, '8727 148th Ave NE, Redmond, WA 98052', function (err, data) {
// work with results here...
});
To retrieve results in GeoJSON format, see the following example:
var
cloudmade = require('cloudmade-lib'),
geocoding = cloudmade.geocoding.initialize({
apikey : 'your_api_key_here'
});
geocoding.getGeo('8727 148th Ave NE, Redmond, WA 98052', function (err, data) {
// work with results here...
});
To retrieve results in Plist format, see the following example:
var
cloudmade = require('cloudmade-lib'),
geocoding = cloudmade.geocoding.initialize({
apikey : 'your_api_key_here'
});
geocoding.getPlist('8727 148th Ave NE, Redmond, WA 98052', function (err, data) {
// work with results here...
});
To retrieve results in HTML format, see the following example:
var
cloudmade = require('cloudmade-lib'),
geocoding = cloudmade.geocoding.initialize({
apikey : 'your_api_key_here'
});
geocoding.getHtml('8727 148th Ave NE, Redmond, WA 98052', function (err, data) {
// work with results here...
});
Additional parameters, as outlined at http://developers.cloudmade.com/projects/show/geocoding-http-api#Parameters, can be supplied easily during the request.
var
cloudmade = require('cloudmade-lib'),
geocoding = cloudmade.geocoding.initialize({
apikey : 'your_api_key_here'
}),
options = {
around : '47.6742,122.1203'
results : 100,
skip : 100
};
geocoding.get(options, '8727 148th Ave NE, Redmond, WA 98052', function (err, data) {
// work with results here...
});
The results returned from the cloudmade API are wrapped with the following fields:
{
"apikey" : "your_api_key_here",
"data" : { /* Cloudmade Response Here */ },
"host" : "geocoding.cloudmade.com",
"path" : "/geocoding/v2/find.js",
"query" : "?query=8727%20148th%20Ave%20NE%2C%20Redmond%2C%20WA%2098052",
"secure" : false
}
For more information about cloudmade's response data: http://developers.cloudmade.com/projects/show/geocoding-http-api#Geocoding-responses
MIT, see LICENSE