Skip to main content

Maps JavaScript API

Sources: console.cloud.google.com/apis/library/maps www.npmjs.com/package/@types/google.maps

image

add <script> to index.html

<script src="https://maps.googleapis.com/maps/api/js?key=MY_API_KEY"\></script\>

this adds the API as a global variable

image

which can be accessed in browser by typing: google into console to access {maps: {..}}

however, TS can not access this global variable w/o a type definition

install DefinitelyTyped definition of google maps

npm i @types/google.maps

!deprecated @tpes/googlemaps

!bug - need to close and reopen .ts @types/google.maps file for google namespace to register

<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyClHg1uM_mqqUDPsEt5HmRWWkRW183mR9Y"\></script\>

References