All Projects → googlemaps → Google Maps Services Js

googlemaps / Google Maps Services Js

Licence: apache-2.0
Node.js client library for Google Maps API Web Services

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Google Maps Services Js

google maps
🗺 An unofficial Google Maps Platform client library for the Rust programming language.
Stars: ✭ 40 (-98.36%)
Mutual labels:  maps, directions, elevation
GoogleMapsHelper
An easy to integrate Model Based Google Maps Helper (SVHTTPClient, AFNetworking) That lets you Geo Code , Reverse Geocode, Get Directions , Places Autocomplete.
Stars: ✭ 21 (-99.14%)
Mutual labels:  maps, directions, places
maps-app-ios
Your organisation's mapping app built with the Runtime SDK for iOS
Stars: ✭ 16 (-99.34%)
Mutual labels:  maps, directions
Mappa
A canvas wrapper for Maps 🗺 🌍
Stars: ✭ 290 (-88.08%)
Mutual labels:  google, maps
Google Map React
Google map library for react that allows rendering components as markers 🎉
Stars: ✭ 5,529 (+127.34%)
Mutual labels:  google, maps
svelte-googlemaps
Svelte Google Maps Components
Stars: ✭ 62 (-97.45%)
Mutual labels:  maps, places
ors-map-client
Openrouteservice API web SPA client using VueJS, Vuetify and Vue2Leaflet
Stars: ✭ 51 (-97.9%)
Mutual labels:  directions, places
Gmscore
Free implementation of Play Services
Stars: ✭ 4,356 (+79.11%)
Mutual labels:  google, maps
svelte-mapbox
MapBox Map and Autocomplete components for Svelte (or Vanilla JS)
Stars: ✭ 267 (-89.02%)
Mutual labels:  maps, geocode
Caranimation
A sample project about car animation in a route
Stars: ✭ 55 (-97.74%)
Mutual labels:  google, maps
Sketch Map Generator
Sketch plugin to fill a shape with a map generated from a given location using Google Maps and Mapbox
Stars: ✭ 824 (-66.12%)
Mutual labels:  google, maps
React Native Streetview
React Native Google's Panorama/StreetView component for iOS and Android.
Stars: ✭ 79 (-96.75%)
Mutual labels:  google, maps
geocoder
Geocoder is a Typescript library which helps you build geo-aware applications by providing a powerful abstraction layer for geocoding manipulations
Stars: ✭ 28 (-98.85%)
Mutual labels:  places, geocode
SimplePlacePicker
Android place picker module for searching and selecting a location on google maps
Stars: ✭ 42 (-98.27%)
Mutual labels:  maps, places
Yii2 Google Maps Library
Google Maps API library for Yii2
Stars: ✭ 104 (-95.72%)
Mutual labels:  google, maps
Vehicle In Motion
This is a basic implementation of location listener using Google Maps Api
Stars: ✭ 339 (-86.06%)
Mutual labels:  google, maps
Leku
🌍 Map location picker component for Android. Based on Google Maps. An alternative to Google Place Picker.
Stars: ✭ 612 (-74.84%)
Mutual labels:  google, maps
Google Api Nodejs Client
Google's officially supported Node.js client library for accessing Google APIs. Support for authorization and authentication with OAuth 2.0, API Keys and JWT (Service Tokens) is included.
Stars: ✭ 9,722 (+299.75%)
Mutual labels:  client-library, google
Placepicker
Free Android Map Place Picker alternative using Geocoder instead of Google APIs
Stars: ✭ 126 (-94.82%)
Mutual labels:  google, maps
Docker Lnmp
🔥 Mac/Linux Docker LNMP
Stars: ✭ 189 (-92.23%)
Mutual labels:  google

Node.js Client for Google Maps Services

npm CI Release codecov GitHub contributors semantic-release Discord

This library is a refactor of a previous version published to @google/maps. It is now being published to @googlemaps/google-maps-services-js. Source for the old version is at the @google/maps branch.

Use Node.js? Want to geocode something? Looking for directions? This library brings the Google Maps API Web Services to your Node.js application.

The Node.js Client for Google Maps Services is a Node.js Client library for the following Google Maps APIs:

Keep in mind that the same terms and conditions apply to usage of the APIs when they're accessed through this library.

Attention!

This library is designed for server-side Node.js applications. Attempting to use it client-side, in either the browser or any other environment like React Native, may in some cases work, but mostly will not. Please refrain from reporting issues with these environments when attempting to use them, since server-side Node.js applications is the only supported environment for this library. For other environments, try the Maps JavaScript API, which contains a comparable feature set, and is explicitly intended for use with client-side JavaScript.

Quick Start

$ npm install @googlemaps/google-maps-services-js

Below is a simple example calling the elevation method on the client class.

Import the Google Maps Client using Typescript and ES6 module:

import {Client} from "@googlemaps/google-maps-services-js";

Alternatively using JavaScript without ES6 module support:

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

Now instantiate the client to make a call to one of the APIs.

const client = new Client({});

client
  .elevation({
    params: {
      locations: [{ lat: 45, lng: -110 }],
      key: "asdf",
    },
    timeout: 1000, // milliseconds
  })
  .then((r) => {
    console.log(r.data.results[0].elevation);
  })
  .catch((e) => {
    console.log(e.response.data.error_message);
  });

Reference Documentation

The generated reference documentation can be found here. The TypeScript types are the authoritative documentation for this library and may differ slightly from the descriptions.

Developing

In order to run the end-to-end tests, you'll need to supply your API key via an environment variable.

$ export GOOGLE_MAPS_API_KEY=AIza-your-api-key
$ npm test

Migration

This section discusses the migration from @google/maps to @googlemaps/google-maps-services-js and the differences between the two.

Note: The two libraries do not share any methods or interfaces.

The primary difference is @google/maps exposes a public method that takes individual parameters as arguments while @googlemaps/google-maps-services-js exposes methods that take params, headers, body, instance(see Axios). This allows direct access to the transport layer without the complexity that was inherent in the old library. Below are two examples.

Old (@google/maps):

const googleMapsClient = require('@google/maps').createClient({
  key: 'your API key here'
});

googleMapsClient
  .elevation({
    locations: {lat: 45, lng: -110}
  })
  .asPromise()
  .then(function(r) {
    console.log(r.json.results[0].elevation);
  })
  .catch(e => {
  console.log(e);
  });

New (@googlemaps/google-maps-services-js):

const client = new Client({});

client
  .elevation({
    params: {
      locations: [{ lat: 45, lng: -110 }],
      key: process.env.GOOGLE_MAPS_API_KEY
    },
    timeout: 1000 // milliseconds
  }, axiosInstance)
  .then(r => {
    console.log(r.data.results[0].elevation);
  })
  .catch(e => {
    console.log(e);
  });

The primary differences are in the following table.

Old New
Can provide params Can provide params, headers, instance, timeout (see Axios Request Config)
API key configured at Client API key configured per method in params object
Retry is supported Retry is configurable via axios-retry or retry-axios
Does not use promises by default Promises are default
Typings are in @types/googlemaps Typings are included
Does not support keep alive Supports keep alive
Does not support interceptors Supports interceptors
Does not support cancelalation Supports cancellation

Premium Plan Authentication

Authentication via client ID and URL signing secret is provided to support legacy applications that use the Google Maps Platform Premium Plan. The Google Maps Platform Premium Plan is no longer available for sign up or new customers. All new applications must use API keys.

const client = new Client({});

client
  .elevation({
    params: {
      locations: [{ lat: 45, lng: -110 }],
      client_id: process.env.GOOGLE_MAPS_CLIENT_ID,
      client_secret: process.env.GOOGLE_MAPS_CLIENT_SECRET
    },
    timeout: 1000 // milliseconds
  })
  .then(r => {
    console.log(r.data.results[0].elevation);
  })
  .catch(e => {
    console.log(e.response.data.error_message);
  });

Support

This library is community supported. We're comfortable enough with the stability and features of the library that we want you to build real production applications on it. We will try to support, through Stack Overflow, the public surface of the library and maintain backwards compatibility in the future; however, while the library is in version 0.x, we reserve the right to make backwards-incompatible changes. If we do remove some functionality (typically because better functionality exists or if the feature proved infeasible), our intention is to deprecate and give developers a year to update their code.

If you find a bug, or have a feature suggestion, please log an issue. If you'd like to contribute, please read How to Contribute.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].