-
Notifications
You must be signed in to change notification settings - Fork 120
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
moveCamera() doesn't work in onMapCreated callback #371
Comments
Can you try the onStyleLoadedCallback, please? |
Thanks for the reply! As I mentioned above, I did give that a try and unfortunately it had the same result. Even in the |
This issue specifically affects iOS devices, while it functions perfectly on Android devices. The problem originates from the onMapCreated and onStyleLoaded callbacks, which are triggered prematurely on iOS. The question is, what is not being waited for? Maybe @josxha, do you have an idea ? |
Apparently, flutter-maplibre-gl/maplibre_gl/ios/maplibre_gl/Sources/maplibre_gl/MapLibreMapController.swift Lines 130 to 143 in 5a3daa2
|
I see now, thanks for the clarification. The problem is that there isn't a proper solution, which is really frustrating. The only workaround so far is to add a delay. |
Yep, I agree. Have you tried to enforce the viewport of the map with the |
I want to initialize a map with an initial bounding box, and since
initialCameraPosition
appears to only support specifying a center position and zoom level, it appears the appropriate way to accomplish this is by callingmoveCamera()
in theonMapCreated
callback like so:However, this call to moveCamera doesn't seem to do anything; the camera position remains at whatever the initial camera position was set to when creating the widget.
Sleeping with a future before running the update resolves the issue, but this is obviously hacky and I'd like to find a more reliable solution.
I've also tried using
to delay calling
moveCamera()
until after the widget has been initialized, and oddly, using this method, the camera moves partially to the new position, but stops before reaching the new bounding box.I've tried all of the above in
onStyleLoaded()
as well with no luck. It seems as though even at the pointonMapCreated()
oronStyleLoaded()
are run, some state still isn't initialized which prevents the camera update from functioning. Can anyone offer some help here?The text was updated successfully, but these errors were encountered: