Comments (4)
Thanks for looking into this issue.
I was assuming that onMapLoaded
indicates that the MapView
is ready to be used, ie animating viewport changes, start observing events such as location/camera updates etc etc. Therefore I have a spinner as an overlay on the map view until onMapLoaded
is called. Thus users cannot interact with the map until such time.
What is the maximum time it can take until this operation is considered fail, and thus onMapLoaded
or onMapLoadingError
will be called?
The reason Im asking, is because I have waited more than 30 seconds for the callback onMapLoaded
but still not received it. And in my experience both as an end-user and app-developer, I dont believe end users will wait longer than that on any UI to be loaded in a mobile context.
So one could also ask, if its good-enough to wait for onStyleLoaded
before starting to "work" with the map, then what is the added value that onMapLoaded
will give to a dev-user of your API given that it might take quite a long time before that callback is called?
In what scenarios would one need to use onMapLoaded
then? If there are no practial scenarios, perhaps it should be removed from the API in order to decrease confusion?
Best Regards
Dennis
from mapbox-maps-ios.
Thank you for that elaborate answer @persidskiy
And thanks for linking to depiction of the general flow of loading.
I will rewrite my code not to wait for onMapLoaded
based on your answer then.
👍
from mapbox-maps-ios.
@BinaryDennis Hi, thank you for the report.
This situation may happen when the root StyleJSON is loaded, but some resources like sprites, or tiles aren't loaded yet. Then the engine will try reload them with some backoff.
Most of the time using the onStyleLoaded
is safe and may be a better alternative. What's your use-case?
from mapbox-maps-ios.
@BinaryDennis Thank you for the details. I'll try to address your questions.
The map loading process is progressive, meaning the map can be rendered on the screen much sooner than it is "completely loaded" (onMapLoaded
event). This way, the end user will see the map as soon as possible, like a web page.
In the worst case scenario, in slow and inconsistent networks, the full load may take minutes. When the network is available, the engine retries loads. This is done because there is no "refresh" button in maps, unlike browsers and our ultimate goal is to render the map.
The loading process itself is quite complicated because the style can have subresources such as images, sources, and other imported styles. Also, the cache may be used. The general idea of the loading flow is demonstrated here https://docs.mapbox.com/ios/maps/api/11.5.0/documentation/mapboxmaps/mapboxmap
At the style loaded stage (onStyleLoaded event), the StyleJSON is loaded and applied, so the engine starts to render it while some parts are still being loaded. The style model is known, so 99.9% of the API is safe to use. In some rare cases when you want to modify the source loaded from the style of something like that, some other event may be used.
I'll comment some of your statements below
I was assuming that
onMapLoaded
indicates that the MapView is ready to be used, ie animating viewport changes, start observing events such as location/camera updates etc etc.
It's safe to do at any time, even before the style is loaded.
I have a spinner as an overlay on the map view until onMapLoaded is called
It's better to avoid this, or use onStyleLoaded
at least.
In general, the API (especially SwiftUI) is designed in a way to allow the developer to just tell the map what to render and not care much about the loading process. For example, the Annotations/Layers/Sources that you put into Map
just render as soon as possible, observing the loading process internally. The Viewport API observes the style loading process internally to work with the camera correctly.
In what scenarios would one need to use onMapLoaded then? If there are no practial scenarios, perhaps it should be removed from the API in order to decrease confusion?
One can use it for logging purposes or something else. But we probably will revisit it in the major versions.
from mapbox-maps-ios.
Related Issues (20)
- Allow applying a shader to a raster layer.
- Can't install on SPM - invalid archive errors HOT 4
- Any plan to support building with xcode 16 on 10.12.x? HOT 2
- How to use `CustomGeometrySource`
- [GestureSettings] Align the name between Android and iOS HOT 1
- Error `called from a thread that is not owning the object` HOT 1
- Can't animate moving `MapViewAnnotation` HOT 3
- Puck snaps to wrong roads HOT 3
- Disable long press gesture on map HOT 4
- GeoJSON Source Loads Data Even When Layer is Hidden HOT 1
- Offline Load Tile Region in version above 11.3 not work with custom style.
- Interprocess communication with main thread when returning `compatibleAuthorizationStatus` HOT 1
- [Error, maps-core]: {}[Style]: Failed to load tile 5/5/12=>5 for source composite: HTTP status code 401 HOT 1
- Need Help in coverting a mapbox function HOT 1
- Adding a polyline with a set .linePattern property breaks other polyline annotations inside of the same annotation manager
- .netrc file in Github Actions? HOT 1
- Swift 6 support
- Crash when using CustomRasterSourceTileRenderer
- Crashed: com.mapbox.common.TileStoreFileSource
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapbox-maps-ios.