Socket
Socket
Sign inDemoInstall

@googlemaps/google-maps-services-js

Package Overview
Dependencies
Maintainers
2
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@googlemaps/google-maps-services-js

Node.js client library for Google Maps API Web Services


Version published
Weekly downloads
283K
increased by3.95%
Maintainers
2
Weekly downloads
 
Created

What is @googlemaps/google-maps-services-js?

@googlemaps/google-maps-services-js is a Node.js client library for Google Maps Services. It allows developers to access various Google Maps APIs, such as Geocoding, Directions, Distance Matrix, Elevation, and Places, among others. This package simplifies the process of integrating Google Maps functionalities into Node.js applications.

What are @googlemaps/google-maps-services-js's main functionalities?

Geocoding

Geocoding converts addresses into geographic coordinates. This example demonstrates how to use the geocode method to get the latitude and longitude of a given address.

const { Client } = require('@googlemaps/google-maps-services-js');
const client = new Client({});

client.geocode({
  params: {
    address: '1600 Amphitheatre Parkway, Mountain View, CA',
    key: 'YOUR_API_KEY'
  }
}).then(response => {
  console.log(response.data.results);
}).catch(error => {
  console.log(error);
});

Directions

The Directions API calculates directions between locations. This example shows how to get directions from New York to Los Angeles.

const { Client } = require('@googlemaps/google-maps-services-js');
const client = new Client({});

client.directions({
  params: {
    origin: 'New York, NY',
    destination: 'Los Angeles, CA',
    key: 'YOUR_API_KEY'
  }
}).then(response => {
  console.log(response.data.routes);
}).catch(error => {
  console.log(error);
});

Distance Matrix

The Distance Matrix API provides travel distance and time for a matrix of origins and destinations. This example demonstrates how to get the distance and travel time between New York and Los Angeles.

const { Client } = require('@googlemaps/google-maps-services-js');
const client = new Client({});

client.distancematrix({
  params: {
    origins: ['New York, NY'],
    destinations: ['Los Angeles, CA'],
    key: 'YOUR_API_KEY'
  }
}).then(response => {
  console.log(response.data.rows);
}).catch(error => {
  console.log(error);
});

Places

The Places API allows you to search for places within a specified area. This example shows how to find nearby restaurants within a 1500-meter radius of a given location.

const { Client } = require('@googlemaps/google-maps-services-js');
const client = new Client({});

client.placesNearby({
  params: {
    location: { lat: 37.7749, lng: -122.4194 },
    radius: 1500,
    type: 'restaurant',
    key: 'YOUR_API_KEY'
  }
}).then(response => {
  console.log(response.data.results);
}).catch(error => {
  console.log(error);
});

Other packages similar to @googlemaps/google-maps-services-js

Keywords

FAQs

Package last updated on 31 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc