Reputation: 2445
I am trying to follow this tutorial to display google maps in my Angular 9 app, but I am facing the below issue.
I carried out the below steps:
I ran npm install @angular/google-maps
Imported the below Module & added it to my imports array in AppModule:
import { GoogleMapsModule } from '@angular/google-maps';
<script src="https://maps.googleapis.com/maps/api/js?key=myKey"></script>
<google-map></google-map>
But when I load the page I get this error in the console:
Can someone please tell me what is causing this error, & how it can be resolved? I've followed the steps in the tutorial so I'm not sure what I'm doing incorrectly.
Upvotes: 1
Views: 4477
Reputation: 2528
I found this would only work when I imported the script into the head of my index.html. Anywher below that and I get errors.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>apoms</title>
<base href="/">
<script src="https://maps.googleapis.com/maps/api/js?libraries=places&key=[APIKey]"></script>
....
</head>
<body>
<app-root></app-root>
<!-- <noscript>Please enable JavaScript to continue using this application.</noscript> -->
</body>
</html>
Upvotes: 2
Reputation: 53
Have you imported import { MapInfoWindow } from '@angular/google-maps'; in your component and use @ViewChild(MapInfoWindow, { static: false }) infoWindow: MapInfoWindow; in class?.
Upvotes: 0