1.3.8 • Published 1 day ago
@frankhoodbs/gmaps-utils v1.3.8
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.
1.3.7
1 day ago
1.3.4
2 days ago
1.3.8
1 day ago
1.3.3
6 days ago
1.3.2
19 days ago
1.3.1
22 days ago
1.3.0
23 days ago
1.2.17
23 days ago
1.2.16
2 months ago
1.2.14
2 months ago
1.2.15
2 months ago
1.2.13
2 months ago
1.2.12
3 months ago
1.2.11
3 months ago
1.2.10
4 months ago
1.2.9
4 months ago
1.2.8
4 months ago
1.2.7
4 months ago
1.2.6
4 months ago
1.2.3
4 months ago
1.2.2
4 months ago
1.2.1
4 months ago
1.1.20
7 months ago
1.1.16
7 months ago
1.1.15
8 months ago
1.1.14
8 months ago
1.1.13
8 months ago
1.1.12
8 months ago
1.1.11
8 months ago