Skip to main content

Introduction

The @aptuitiv/gmaps library helps you add a Google map to your website and show markers, popups, tooltips, InfoWindows, polylines and other map components.

Inspired by Leaflet.

Goals​

Some of the goals of this library include:

  • Streamline the process of loading the Google Maps Javascript API to display maps.
  • Absract away some of the boilerplate code to display the map and elements on the map.
  • Make it easier to configure the elements on the map.
  • Provide built-in functionality for advanced functionality like marker clustering and bulk management of markers and polylines.
  • Make it easier to display a custom styled popup when clicking on markers or other elements.
  • Make it easier to show a custom styled tooltip when overing a mouse on markers or other elements.

Install​

npm install @aptuitiv/gmaps

How you use it from there depends on how your site's Javascript is built. See the installation pages for a bundler, a standalone browser script, or CommonJS — and for the entry points that let you leave out the parts of the library you don't use.

Available objects​

The different objects in the library are available under the global G variable.

You use one of the following functions to set up the object that you need.

Chainable methods​

If an object's method returns an instance of that method, then the method is chainable.

For example:

const icon = G.icon()
.setUrl('https://mywebsite.com/images/marker.png')
.setSize([10, 32])
.setScaledSize([5, 16]);