2.0.2 • Published 11 months ago

@frankhoodbs/gmaps-utils v2.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

Gmaps Utils

A lightweight utility to help initialize Google Maps JavaScript API with ease.

Features

  • Simplified Google Maps JavaScript API initialization.
  • Supports setting language and region.
  • Uses the latest version of Google Maps on a weekly basis.
  • Includes the 'places' library by default.

Usage

  1. Import the utility:
import gMapsInit, { GmapsInitOptions } from './path-to-gMapsInit-file';
  1. Initialize Google Maps:
const gmapsOptions: GmapsInitOptions = {
  apiKey: 'YOUR_API_KEY',
  language: 'en', // Optional. Default is 'it'
  region: 'US'    // Optional. Default is 'IT'
};

gMapsInit(gmapsOptions)
  .then((googleMaps) => {
    // Google Maps is now initialized and can be used.
    const map = new googleMaps.Map(document.getElementById('map'), {
      center: {lat: -34.397, lng: 150.644},
      zoom: 8
    });
  })
  .catch((error) => {
    console.error('Error loading Google Maps', error);
  });

API Reference

GmapsInitOptions

  • apiKey (string): Required. Your Google Maps API key.
  • language (string, optional): Preferred language for the maps display. Default is 'it'.
  • region (string, optional): Region biasing for address localization. Default is 'IT'.

gMapsInit(options: GmapsInitOptions): Promise<google.maps.MapsLibrary>

Initializes the Google Maps JavaScript API and returns a promise. When resolved, you can use the Google Maps API as you normally would.

2.0.2

11 months ago

1.3.12

11 months ago

2.0.1

11 months ago

1.3.11

11 months ago

1.3.10

1 year ago

1.3.9

1 year ago

1.3.7

1 year ago

1.3.4

1 year ago

1.3.8

1 year ago

1.3.3

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.17

1 year ago

1.2.16

1 year ago

1.2.14

1 year ago

1.2.15

1 year ago

1.2.13

1 year ago

1.2.12

2 years ago

1.2.11

2 years ago

1.2.10

2 years ago

1.2.9

2 years ago

1.2.8

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.1.20

2 years ago

1.1.16

2 years ago

1.1.15

2 years ago

1.1.14

2 years ago

1.1.13

2 years ago

1.1.12

2 years ago

1.1.11

2 years ago