Coder Social home page Coder Social logo

cloudmade-lib's Introduction

Cloudmade Lib

A node library for consuming Cloudmade APIs. Currently only supports Geocoding.

Build Status Coverage Status

Features

  • Geocoding
    • Output types for JSON, GeoJSON, Property list and HTML

Install

npm install cloudmade-lib

Usage

JSON

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...
});

Timeout for Execution

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...
});

GeoJSON

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...
});

Propert list

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...
});

HTML

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...
});

Optional Parameters

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...
});

Response Data

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

License

MIT, see LICENSE

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.