I'm writing an HTML5 mobile application that uses Google Maps V3 with a custom layer of OpenStreetMap tiles.
The OSM tiles (from tile.openstreetmap.org
) are set to cache for just over 24 hours, and I'm using a cache-manifest for all my HTML/JS/CSS.
So the application could in theory be used offline, except the Google Maps interface isn't happy when offline.
It always wants to call to the Google Maps server at http://maps.google.com/maps/api/js?sensor=false®ion=GB
- when this fails, Google Maps fails to load.
Is there any way to use Google Maps V3 API offline?
Could I cache-manifest http://maps.google.com/maps/api/js?sensor=false®ion=GB
, or would that be a bad move?
(Sorry for this rather beginner question, let me know if I can explain better!)
I have
http://maps.google.com/maps/api/js?sensor=false
in theCACHE
section ofcache.manifest
, together with my application files and there isn't any problem.Although, I believe you also have to cache other files that the Google Maps API requests. You can take a look at the files downloaded by your app and include them.
Not possible!
Google map CDN URLs have dynamic nature,
No wildcard characters are allowed in CACHE section of the HTML5 cache manifest files
We can not have some thing like,
Google coders themselves have tackled this problem and unfortunately the information isn't well disseminated. But yes you can use cache-manifest to do exactly what you've described.
Required Readings
The Technique
Your cache file will look like (as per Missouri State):
Caveats
You will need to be entirely HTML5-based and recognize the impacts this will have on your users. This situation is handy where either your users are up-to-date on browser standards/devices or you have control over user choices.
Hope this helps.
I had a google map project that I needed offline. I found Bing Maps (https://www.bingmapsportal.com/ISDK/AjaxV7) is much better offline and switched my project over to that and I'm happy. I ran the google and bing version side-by-side in offline mode and Bing was great. Whereas google would immediatey fail on tile loads, Bing maps cached more tiles and appeared to even resize zoomed tiles to at least give you something in offline mode.
I know the question here is about Google maps; but if you don't care about bing vs. google and really just need offline support, I'd highly recommend trying Bing maps. It solved it for me.