Collect: With Mapbox or Google mapping engines, offline tiles are not rendered without an Internet connection

Created on 28 Feb 2020  路  7Comments  路  Source: getodk/collect

Software and hardware versions

Collect v1.25.2 and prior

Problem description

See https://forum.opendatakit.org/t/mapbox-mbtiles-layer-not-loading-without-network-connection/21774 for user report.

Steps to reproduce the problem

  1. Set the basemap source to Mapbox or Google
  2. Push an mbtiles file to /sdcard/odk/layers
  3. Turn off all networking
  4. Select that mbtiles file as a reference layer
  5. Go to a map-based question

Expected behavior

The offline reference layer should always show, even if the device is offline.

bug

All 7 comments

Hello @zestyping, you have been unassigned from this issue because you have not updated this issue or any referenced pull requests for over 15 days.

You can reclaim this issue or claim any other issue by commenting @opendatakit-bot claim on that issue.

Thanks for your contributions, and hope to see you again soon!

I investigated the issue and the behavior is not that bad. Offline layers will work offline if after installing the app we open GoogleMaps/Mapbox at least once with internet connection in order to initialize GoogleMaps/Mapbox.

It's a know limitation: https://issuetracker.google.com/issues/35823181 since 2013 devs has been begging google to fix it.
Here are more stackoverflow topics:
https://stackoverflow.com/questions/46055336/maps-android-api-doesnt-work-offline-without-online-initialization
https://stackoverflow.com/questions/16525822/offline-mode-for-android-app-using-the-google-maps-api?fbclid=IwAR1Zlbe8uz5Q8Bm8Z0JcExNcQx4YzCdbiHrcr_-kDo7v5dQgUeaY09n9EeY
https://stackoverflow.com/questions/16056156/using-the-android-google-maps-api-v2-as-a-viewer-of-offline-tiles-is-it-possibl

Looks as if Mabox works in the same way.

What we can do:

  • document the limitation and do nothing.
  • document the limitation and at least try to initialize GoogleMaps/Mapbox when the app is installed because then the chance that a user is online is pretty big but not guaranteed as well.

@lognaturel any thoughts?

I see, that makes a lot of sense and explains why there haven't been a ton of complaints. I guess it's not trivial to add a code path that doesn't require a API key check while requiring it elsewhere. I think that because we have the osmdroid option for now we can limit ourselves to documenting the limitation.

We have however discussed deprecating osmdroid in favor of MapBox because it's faster, provides better zooming, etc. Could you please do just a little more poking around to see whether there could be a workaround for Mapbox? I vaguely remember @zestyping discovering something about being able to access some functionality with a blank API key.

@grzesiek2010 are you sure that the Mapbox behavior is what you've described? Users seem to say that even if a connection was available at some point, offline tiles stop being displayed when offline:

If I start at the office with wifi or data connection, when I switch data connection off my maps disappears

(Edit: that was @mathieubossaert whose eyeballs I see above. 馃憖馃槉)

Also note what the initial reporter of the issue says about tethering to "fool" Mapbox into thinking it's online. I think there's a different problem for Mapbox.

Ok got it it's a bit trickier in case of Mapbox... generally it works like I described but when you are online you need to open Mapbox at least once with a layer you want to use later, where with Google Maps it doesn't matter you just need to open it once. I'll try to dig deeper.

Reopening as discussed here https://github.com/getodk/collect/pull/3804

Nope we've got https://github.com/getodk/collect/issues/3815 covering that

Was this page helpful?
0 / 5 - 0 ratings