Roufid

Angular Uncaught ReferenceError: google is not defined – Solution

Angular

When trying to integrate google maps with your Angular application, you may encounter the following error : Angular Uncaught ReferenceError: google is not defined. This tutorial will show how to fix it.

Solution

First you need to install @types/googlemaps :

Then if you are using Angular-cli, add googlemaps to types in src/tsconfig.app.json :

Note that if you want to call a constructor you must do it after maps api is loaded. Exemple of working with @agm/core :


The tutorial source code is available on Github. Download the source

References