Is there any package available on npm for google maps? Or am I really supposed to paste this
<script src="https://maps.googleapis.com/maps/api/jskey=YOUR_API_KEY"> </script>
to my index.html and download this js file on every refresh?
This is super annoying, because sometimes I get ReferenceError: google is not defined
.
The API is available for developers that have a free Google Maps API key. Usage of the API is not strictly free, but they do offer $200 of free monthly usage for most users. The pricing scales to fit your particular needs and you are only charged for your API usage.
The official google maps package (@google/maps) is for node only. In a browser environment, you need to use an unofficial package or include the official script on your site.
To the ReferenceError problem, make sure the script tag for google maps is above the script tag for your code so that it loads first. If it isn't, your script may run before the google global variable is created.
One unofficial package is google-maps, which can be used in a browser.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With