Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

Node.js - Mapbox Geocoder

mapbox-geocode.js takes a single query as a parameter and outputs the result.

Requirements

  • Node.js
  • A Mapbox access token with geocoding capabilities

Usage

Command line:

MapboxAccessToken=YOUR_ACCESS_TOKEN node ./mapbox-geocode.js '1600 Pennsylvania Ave Washington, DC'

Programmatic:

> var mapbox = require('./mapbox-geocode.js');
> mapbox('YOUR_ACCESS_TOKEN', '1600 Pennsylvania Ave Washington, DC', function(err, data) { console.log(data); });

{ type: 'FeatureCollection',
  query: [ '1600', 'pennsylvania', 'ave', 'washington', 'dc' ],
  features:
   [ { id: 'address.170282823806239',
       type: 'Feature',
       text: 'Pennsylvania Ave NW',
       place_name: '1600 Pennsylvania Ave NW, Washington, 20006, District of Columbia, United States',
       relevance: 0.863516129032258,
       center: [Object],
       geometry: [Object],
       bbox: [Object],
       address: '1600',
       properties: {},
       context: [Object] },
[...]