2.0.2 • Published 10 months ago
@frankhoodbs/gmaps-utils v2.0.2
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
- Import the utility:
import gMapsInit, { GmapsInitOptions } from './path-to-gMapsInit-file';
- 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
10 months ago
1.3.12
10 months ago
2.0.1
10 months ago
1.3.11
10 months ago
1.3.10
12 months 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
1 year ago
1.2.11
1 year ago
1.2.10
1 year ago
1.2.9
1 year ago
1.2.8
1 year ago
1.2.7
1 year ago
1.2.6
1 year 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