Is it possible to cache google map in a flutter app?

Viewed 2054

I’m making a flutter app and I need google map in it but it reloads each time I reopen the app I want to know if there is a way for me to cache google map inside my app to prevent this reloading

2 Answers

One possible workaround maybe using Maps Static API. It allows you to have an image of some region on the map, which can be downloaded without loading an entire map.

As per jabamataro’s comment, caching is a violation of Google Maps policy 3.2.3(b). So, no caching

Example use:

static String mapPreviewImage({double latitude, double longitude}) {
    return 'https://maps.googleapis.com/maps/api/staticmap?center=&$latitude,$longitude&zoom=16&size=600x300&maptype=roadmap&markers=color:red%7Clabel:A%7C$latitude,$longitude&key=$GOOGLE_API_KEY';
  }

So, you can use returned String as URL for your http request

As pointed out by @jabamataro, downloading and caching might be against Google Maps' ToS (as of Oct 21 2021)

(a) No Scraping. Customer will not export, extract, or otherwise scrape Google Maps Content for use outside the Services. For example, Customer will not: (i) pre-fetch, index, store, reshare, or rehost Google Maps Content outside the services; (ii) bulk download Google Maps tiles, Street View images, geocodes, directions, distance matrix results, roads information, places information, elevation values, and time zone details; (iii) copy and save business names, addresses, or user reviews; or (iv) use Google Maps Content with text-to-speech services.

Related