maplibre-native
maplibre-native copied to clipboard
Disable default style
The default style points towards the demo tiles, generating a lot of traffic towards them, and it should be set explicitly instead.
For projects that load the style async, the current implementation will briefly load demo-tiles, and then swap them with the intended style afterwards.
https://github.com/maplibre/maplibre-gl-native/blob/5a181c15742a3a35dc1a92782946b41ae2f9cbdd/src/mbgl/util/tile_server_options.cpp#L209-L228
@birkskyum what do you mean with set explicitly
? Can you give an example? Thanks!
I just mean that we can't have a default value there, so the style should either be provided on initialization or a set command after
Aren't the demotiles hosten on GitHub?
Does it matter that it generates a lot of traffic?
They are hosted on GitHub and served through cloudflare. Cloudflare donated us some free services, so it does not directly produce cost for us, but I think the default behavior should be that nothing is shown if you do not set explicitly a style path.
Indeed, we can confirm that the demo style is requested despite of custom style being configured before the map is added to the view hierarchy. Error logs indicate that the load of external style.json
was attempted and timed out
Task <9B3323BB-5C17-4712-A2D5-8E713A107533>.<1> finished with error [-1'001]
Error Domain=NSURLErrorDomain Code=-1001 "Zeitüberschreitung bei der Anforderung."
UserInfo={_kCFStreamErrorCodeKey=-2103,
_NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <9B3323BB-5C17-4712-A2D5-8E713A107533>.<1>,
_NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <9B3323BB-5C17-4712-A2D5-8E713A107533>.<1>"
), NSLocalizedDescription=Zeitüberschreitung bei der Anforderung.,
NSErrorFailingURLStringKey=https://demotiles.maplibre.org/style.json,
NSErrorFailingURLKey=https://demotiles.maplibre.org/style.json,
_kCFStreamErrorDomainKey=4}