13

The Google map component (com.google.android.gms.maps.GoogleMap) allows one to render custom tiles (OpenStreetMap or other). These tiles can be on the device and available offline which is what I am doing by extending TileProvider. Doing this in conjunction with a:

mMap.setMapType(GoogleMap.MAP_TYPE_NONE);

I am not pulling any data from Google map servers and the component can reasonably be expected to work without an internet connection. (I emphasize here that I am not trying to cache Google's data; I am working with offline tiles independently of Google's map servers.)

I thought everything was fine until I realized that the map component won't work if, when it is executed for the first time, the device is offline. In such cases I get a message:

failed to load map. could not contact google servers

I imagine the reason behind this is Google's API keys which require my app to authenticate in order for the component to be allowed to execute.

Can anyone confirm this is correct? What I would really like to be sure of is that provided that the component is executed once online, it will run ok afterwards. I must make sure that there are no time-out issues which would require the component to re-authenticate later on and which would basically make my app useless. That would require that I move on to some other component (such as OS Android).

Any light on this would be greatly appreciated. Even being pointed to the channel through which I could hope to get a reply from the google developers would be useful.

Thanks

guibar
  • 435
  • 1
  • 5
  • 12
  • "Even being pointed to the channel through which I could hope to get a reply from the google developers would be useful." -- http://code.google.com/p/gmaps-api-issues/issues/list – CommonsWare Apr 17 '13 at 11:26
  • Thanks for the comment. The issues I was pointed too were useful. – guibar Apr 18 '13 at 13:05
  • Find a better solution? I am running into the exact same problem. I am sideloading my app onto phones that may never have internet access, seems ridiculous to have to verify the API key if I don't intend to use the maps. – lostintranslation Mar 11 '14 at 00:14
  • @lostintranslation - I faced the same problem now - have you resolve this problem? – alena_fox_spb Oct 14 '16 at 12:54

1 Answers1

9

As of 3.0.27 of Google Play Services APK it is fixed and the server is required to be contacted just once. You will see error in the logcat every time, but it will work.

More info here: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4817

and here: http://code.google.com/p/gmaps-api-issues/issues/detail?id=5017

MaciejGórski
  • 22,187
  • 7
  • 70
  • 94
  • 1
    Thanks for this useful answer. I still have a doubt thought after reading the issues you pointed to. They say: "This should be fixed with the latest update to the Google Play services APK (3.0.27). There is still a requirement for an internet connection when the application is first loaded but there is no longer an issue with later opening the application and using the map while there is no connection." By "first loaded", do they mean first time it is run or just installing it with a connection is enough? In my case, it seems necessary to run the application once. – guibar Apr 18 '13 at 13:01
  • 1
    It is required to be run with internet connection for the first time. – MaciejGórski Apr 19 '13 at 18:29
  • There are ways Googlers could improve that: 1) not forcing the verifiaction, which would be useful when you use MAP_TYPE_NONE 2) Google Play Services APK could sneak on apps being installed and when it finds one that uses maps or any other API, would verify API key just after installation - this is when you usually have internet connection. Maybe issue a feature request like this on gmaps-api-issues? – MaciejGórski Apr 19 '13 at 18:56
  • Thanks, this requirement is a pain. I will put a feature request along those lines. – guibar Apr 24 '13 at 12:01
  • 2
    Here is the issue someone wrote. Please 'star' if you would like to see this fixed. https://code.google.com/p/gmaps-api-issues/issues/detail?id=5496&sort=-stars&colspec=ID%20Type%20Status%20Introduced%20Fixed%20Summary%20Internal%20Stars – lostintranslation Mar 11 '14 at 17:20