GithubHelp home page GithubHelp logo

find-lat-lng's Introduction

find-lat-lng Build Status

Finds latitude and longitude for an array of street names.

Install

$ npm install --save find-lat-lng

# or with yarn

$ yarn add find-lat-lng

Usage

import findLatLong from 'find-lat-lng';

const GOOGLE_API_KEY = 'your_google_api_key'; // (https://developers.google.com/maps/documentation/javascript/get-api-key)
const client = findLatLng(GOOGLE_API_KEY);
const items = ["Lönnrotinkatu 5, Helsinki", "Lönnrotinkatu 4, Helsinki"];

(async () => {
  const itemsWithLatLng = await client(items, { debug: false });
  console.log(itemsWithLatLng);

  /*
  [
    { address: 'Lonnrotinkatu 5', lat: 60.166924, lng: 24.939788},
    { address: 'Lonnrotinkatu 4', lat: 60.167142, lng: 24.940959},
    ...
  ]
  */
})();

If lat and/or lng is not found null is returned

API

findLatLng(GOOGLE_API_KEY)(items [,options])

findLatLng must be initialized with your Google Maps API Key. After calling the initialized client it returns a promise for an array of address, lat, lng objects.

Items must be an array of addresses to search for.

Options

Type: Object default: {debug: false}

Object of optional options.

debug

Type: Boolean default: false

If true, console.warns about lat/lngs that were not found.

CLI

See find-lat-lng-cli for a CLI for this module

Related

License

MIT © Pete Nykänen

find-lat-lng's People

Contributors

petetnt avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

find-lat-lng's Issues

Manage errors properly

For example, if the APIs are not enabled you should receive this error:

{                                                                                                             │
    "error_message": "This API project is not authorized to use this API.",                                   │
    "results": [],                                                                                            │
    "status": "REQUEST_DENIED"                                                                                │
}

Instead of returning null/null for lat/lng

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.