ianrose / directions-to-geojson

Convert Google Map direction polyline to geojson

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Google Map Directions to Geojson

Install

npm install directions-to-geojson --save

Example

1. Google Directions

Google Directions

2. JS

const directionsToGeoJson = require('directions-to-geojson')

const opts = {
  apiKey: GOOGLE_MAP_API_KEY, // Google Maps API key
  stroke: '#ff1800', // Color of line
  fileName: './test/datafile.geojson', // The output
  origin: 'New Orleans, Louisiana', // Starting location of the directions
  destination: 'Manhattan, New York, NY', // The destination of the directions
  waypoints: [ // The locations between the beginning and destination
    'Oak Ridge, Tennessee',
    'Philadelphia, Pennsylvania'
  ]
}

directionsToGeoJson(opts)

3. Output

Geojson output

About

Convert Google Map direction polyline to geojson

License:MIT License


Languages

Language:JavaScript 100.0%