Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

When online, the offline cache region is load online. #10977

Closed
noramimiyuma opened this issue Jan 22, 2018 · 4 comments
Closed

When online, the offline cache region is load online. #10977

noramimiyuma opened this issue Jan 22, 2018 · 4 comments
Labels
Core The cross-platform C++ core, aka mbgl offline

Comments

@noramimiyuma
Copy link

Platform:
iOS / Android

Mapbox SDK version:
Both are latest.

Steps to trigger behavior

  1. Save any map area as offline cache.
  2. Load the offline cached map area online.

Expected behavior

If the tile to be read is offline cached, using the cache.

Actual behavior

Tiles are always loaded online

Problem

Because offline cached maps are assumed to be used in environments with weak radio waves, this operation requires a considerably long time to read maps and is not practical.

Solution

If there is an offline cache, is there an option to use the cache preferentially?
Please tell me if there is a way to realize the expected behavior with the existing mechanism.

@tobrun tobrun added offline Core The cross-platform C++ core, aka mbgl labels Jan 22, 2018
@tobrun
Copy link
Member

tobrun commented Jan 22, 2018

On Android you can workaround this by overriding the connectivity changed information so the engine itself thinks it's offline and will fetch the data from the cache instead.

 /**
   * Manually sets the connectivity state of the app. This is useful for apps which control their
   * own connectivity state and want to bypass any checks to the ConnectivityManager.
   *
   * @param connected flag to determine the connectivity state, true for connected, false for
   *                  disconnected, and null for ConnectivityManager to determine.
   */
  public static synchronized void setConnected(Boolean connected) {
    // Connectivity state overridden by app
    INSTANCE.connected = connected;
  }

You can use above method as follows:

Mapbox mapbox = Mapbox.getInstance(context, accessToken);
mapbox.setConnected(false);

@noramimiyuma
Copy link
Author

@tobrun Thank you for your answer. I will share it to our Android team.

However, I could not find equivalent property in the iOS SDK.
Do you have any information about iOS?

@barnaclebarnes
Copy link

@noramimiyuma See this related issue - #7443

Not being able to block network access is blocker for us to switch to Mapbox. I wonder how hard this is to implement and if anybody is wanting to do this for a bounty?

@kkaefer
Copy link
Member

kkaefer commented Feb 8, 2018

Duplicate of #7443. Let's track this there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Core The cross-platform C++ core, aka mbgl offline
Projects
None yet
Development

No branches or pull requests

5 participants