View Full Version : Google API and CACHE MANIFEST

27 Nov 2010, 8:18 AM
I did an application that use some map features. The purpose of this web app (iPad and iPhone) is to be able to be used offline.
As we cannot cache the : http://maps.google.com/maps/api/js?sensor=true

how can we deal to have the app working offline without being blocked by Google API call?

I put the google api call in the NETWORK section of my manifest file but the webapp won't launch if offline

Is there a conditional expression I could use in my code to solve this.

27 Nov 2010, 9:48 AM
I had trouble with this same thing - have not found a solution, but I do have a work around.

if (navigator.onLine) {

27 Nov 2010, 9:55 AM
Thanks, are you using that in the header that call the <script>?

In fact do you load the script only if you're online?

27 Nov 2010, 11:30 AM
Inside the 'if' I create a script tag - so yes, It only loads the script if your online.

27 Nov 2010, 11:34 AM
OK I got it thanks, I'll ry this tomorrow

29 Nov 2010, 11:00 AM
Did not work for me. The app once offline keeps requesting connection in order to launch

here's what I used :

if (navigator.onLine){<?php print("<script type=\"text/javascript\" src=\"http://maps.google.com/maps/api/js?sensor=false\"></script>"); ?> }

Noticed also a flash of code on the page before the app lauches when online.
I'll need to find something else.

29 Nov 2010, 11:05 AM
I'm not sure how that code you wrote would ever work. You need to actually create and insert a script tag using JavaScript.

if (navigator.onLine) {
var st = document.createElement('script');
st.type = 'text/javascript';
st.async = true;
st.src = 'http://www.blah.com/script.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(st, s);

NOTE: even though the code block says PHP, the code is all JavaScript.

29 Nov 2010, 12:03 PM
I'll try your solution wich is more sealess than mine.
One question, have you ever done a Sencha app that uses a fallback URL in the manifest file? In those case we could use another index for offline mode.

29 Nov 2010, 12:11 PM
Not sure - I haven't played with the FALLBACK section yet.

23 Jan 2011, 1:16 PM
Any solution for this problem so far? I am trying to do the same and I got an error and the application does not load the map even if I am offline

4 Oct 2011, 2:35 PM
has anyone figured this out yet??!?~o)

6 Oct 2011, 6:28 AM
I am looking into this as well. Maybe ultimately we will have to use something like OpenStreetMap, which is completely offline? Some iPhone/iPad apps seem to use it. The only post I could find so far was this one which seems quite complicated:


7 Oct 2011, 12:06 AM
I found this in the Google maps terms:

No Pre-Fetching, Caching, or Storage of Content. You must not pre-fetch, cache, or store any Content, except that you may store: (i) limited amounts of Content for the purpose of improving the performance of your Maps API Implementation if you do so temporarily, securely, and in a manner that does not permit use of the Content outside of the Service; and (ii) any content identifier or key that the Maps APIs Documentation specifically permits you to store. For example, you must not use the Content to create an independent database of “places.”

Have a look at this example bottom of the screen:


Have to do some more reading, but I wonder if this example would be much easier to cache??



2 Dec 2011, 7:41 AM
I read on a forum that someone had managed to successfully cache Google Maps API 3 by doing the following:

'You need to add these files below in the NETWORK section of the cache manifest file:


The site here has a different list:

Has anyone tried this or had any progress? I might give it a shot soon when I have time...