Skip to content

Google Maps Api

Google Developers console

GMaps script to HTML

  • Add the gmaps script above the other js scripts
  • Create a div with an id to place the map
<body>
  <div id="map" style="height: 100vh;"></div>
  <script src="https://maps.googleapis.com/maps/api/js?key=yourapikey"></script>
  <script src="./src/index.ts"></script>
</body>

Typescript support

  • Install @types/googlemaps for TS support in the project
  • Add the following statement to the top of the index.ts
/// <reference types="@types/googlemaps" />
  • Or create a tsconfig.json at the root folder with the following
{
  "types": ["google"]
}
  • 'google' will work as a global variable