0.0.10 • Published 4 years ago

@googlemaps/loader v0.0.10

Weekly downloads
600
License
Apache-2.0
Repository
github
Last release
4 years ago

Loader for Google Maps v3

NOTE: This package has been deprecated in favor of @googlemaps/js-api-loader. The interface remains the same.

Description

Load the Google Maps V3 script dynamically. This takes inspiration from the google-maps npm package but updates it with ES6, Promises, and TypeScript.

NPM

Available via NPM as the package @googlemaps/loader

Documentation

The reference documentation can be found at this link.

Example

import { Loader } from '@googlemaps/loader';

const loader = new Loader({
  apiKey: "",
  version: "weekly",
  libraries: ["places"]
});

const mapOptions = {
  center: {
    lat: 0,
    lng: 0
  },
  zoom: 4
};

Using a promise for when the script has loaded.

// Promise
loader
  .load()
  .then(() => {
    new google.maps.Map(document.getElementById("map"), mapOptions);
  })
  .catch(e => {
    // do something
  });

Alternatively, if you want to use a callback.

// Callback
loader.loadCallback(e => {
  if (e) {
    console.log(e);
  } else {
    new google.maps.Map(document.getElementById("map"), mapOptions);
  }
});

View the package in action here.

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.

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.

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

5 years ago