Using the android Google Maps API v2 as a viewer o

2019-01-14 04:41发布

问题:

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

回答1:

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