Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Data URLs in offlineRegionDefinitions styleURL #609

Open
mariusvn opened this issue Dec 16, 2022 · 5 comments
Open

Allow Data URLs in offlineRegionDefinitions styleURL #609

mariusvn opened this issue Dec 16, 2022 · 5 comments
Labels
android enhancement New feature or request

Comments

@mariusvn
Copy link

Is your feature request related to a problem? Please describe.
The offline region definition require an URL to define the style of the downloaded data. This makes the download of custom style generated on the fly impossible.

Describe the solution you'd like
Would be nice to allow raw json or data URL that contains a style definition.

Describe alternatives you've considered
As i said before, I tried with the data URLs in the style URL but it doesn't seems like the URL parser parse it.

Additional context
MapLibre gives me this message followed by the content of the styleURL: [HTTP] Unable to parse resourceUrl

@boldtrn
Copy link
Collaborator

boldtrn commented Dec 19, 2022

Yes, I think we should allow to pass a Style.Builder to the offline regions.

@mariusvn
Copy link
Author

yeah that would be even better

@louwers
Copy link
Collaborator

louwers commented Jul 19, 2024

This is apparently working on iOS (using a file:// URL), but not on Android. This error is coming from here:

HttpLogger.log(Log.ERROR, String.format("[HTTP] Unable to parse resourceUrl %s", resourceUrl));

So apparently this hits the 'HTTP file source' instead of the 'Local File Source' implementation. Maybe fixing this is as easy as changing

bool canRequest(const Resource& resource) const override {
return resource.hasLoadingMethod(Resource::LoadingMethod::Network);
}

to return false when the URL scheme of the requested resource is file://, i.e. the inverse of

bool acceptsURL(const std::string& url) {
return 0 == url.rfind(mbgl::util::FILE_PROTOCOL, 0);
}

@ccannell
Copy link

Interested in a fix. This is a blocker for an app I'm writing for a client.

@mariusvn
Copy link
Author

it may be an error that came with android 13 new storage restrictions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants