1.0.9 • Published 1 year ago

wl-google-maps v1.0.9

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Node.js wrapper for Google Features

Using package find travel distance and time between source and destination and other features.

Installation

npm install wl-google-maps

Initialize

import WLGoogleMaps from 'wl-google-maps';

let wlobj = new WLGoogleMaps('GOOGLE_API_KEY');

To create your google application's API key:

1. Go to the API Console. https://console.developers.google.com/
2. From the projects list, select a project or create a new one.

image-1.png

3. Open the left side menu and select APIs & services.

image-2.png

4. Enable "Geocoding API" & "Diatance Matrix API"

image-3.png image-4.png

4. On the left, choose Credentials.

5. Click Create credentials and then select API key to get key. 

image-5.png

6. Use this while initializing.

Usage

Get Travel time and distance between two locations (Coordinates)

let source_latitude = 16.989065
let source_longitude = 82.247467
let destination_latitude = 17.385044
let destination_longitude = 78.486671

wlobj.calculateDistance(source_latitude,source_longitude,destination_latitude,destination_longitude)
  .then((res) => {
    console.log(res); 
  })
  .catch((err) => {
    console.log(err);
  });

Get Travel time and distance between two locations (addresses)

let source_address = 'Kakinada';
let destination_address = 'Hyderabad, India';

wlobj.calculateDistance(source_address,destination_address)
  .then((res) => {
    console.log(res); 
  })
  .catch((err) => {
    console.log(err);
  });

Find latitude and longitude from address

let address = 'Kakinada, 533006';

wlobj.getCoordinatesByAddress(address)
  .then((res) => {
    console.log(JSON.stringify(res)); 
  })
  .catch((err) => {
    console.log(err); 
  });

Find address from latitude and longitude

let latitude = 16.989065
let longitude = 82.247467

wlobj.getAddressFromCoordinates(latitude, longitude)
  .then((res) => {
    console.log(JSON.stringify(res)); 
  })
  .catch((err) => {
    console.log(err); 
  });
1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago