bee
bee

Reputation: 11

Does Google Maps API have session timeout?

I am building an info screen application in Angular which displays various useful information on dedicated screen. I want it to display road traffic in certain city area during morning hours. So I use Google Maps with traffic layer to implement this. I create a map this way:

ngAfterViewInit()
{
  this.map = new Map(document.getElementById('map'));
  this.traffic = new TrafficLayer({map: this.map});
  this.map.fitBounds(this.bounds);
}

And display the component this way:

<app-map
      *ngIf="layout == Layout.MORNING"
      id="map"
      [bounds]="{west: -0.4833681, east: -0.0807662, north: 51.716128, south: 51.5147982}"
></app-map>

And load google maps library with this in my index.html

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

Everything works perfectly for couple of days, but then the map is displayed all grey with only map control buttons on it. This is very difficult to debug as you need to wait at least two days to reproduce the problem. There are no errors in the console and no 4xx http responses. Looks like some session timeout/expiration after initial script load to me. Can workaround by reloading whole the application say every 24 hours but looking for proper solution. Any ideas in what direction to dig?

Upvotes: 1

Views: 1160

Answers (2)

ifadey
ifadey

Reputation: 1062

Google Maps session timeout after 24 hours. You will see NotLoadingAPIFromGoogleMapsError error in developer console once it expires.

The only way to fix it is to reload your page.

Upvotes: 1

captainigloo
captainigloo

Reputation: 21

Yes, google maps does time out. See this bug report:

https://issuetracker.google.com/issues/65212482

They say "sessions are limited in time, you will have to reload your page if you want to keep displaying a map". They don't say how long the session lasts nor do they say explicitly that you can prevent the timeout in any way (ie by using the map).

Upvotes: 1

Related Questions