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

animateCamera appears to be broken on web #162

Closed
erik opened this issue Oct 6, 2022 · 6 comments
Closed

animateCamera appears to be broken on web #162

erik opened this issue Oct 6, 2022 · 6 comments

Comments

@erik
Copy link

erik commented Oct 6, 2022

Hi, I noticed that calls to animateCamera() seemed to have no effect when running web builds, but the same call worked fine on iOS.

Here's what I was calling:

    mapController.animateCamera(CameraUpdate.newLatLng(coordinates));

After some debugging I traced it back to this change, which appears to have triggered a null dereference: c3e941b#diff-4666b03e54f2025da49b0f804d0eb4401b13c0e9599cf74089d5d6a4abf144d0

Specifically, the use of .jsObject appears to be in the wrong place, as getProperty returns a null for unspecified options.

I put together a quick fix in a fork, but I do wonder if this is really the right approach. Maybe the CameraOptions class should be updated to reflect the nullability of its members instead.

For now I'm just using my fork as a dependency override, but if you think it's the right fix I can open a PR.

@stefanschaller
Copy link
Collaborator

stefanschaller commented Jun 15, 2023

It seems like that I have the same issue:

3main.dart.js:8078 Uncaught TypeError: Cannot read properties of undefined (reading 'get$jsObject')
    at main.dart.js:235136:26
    at _wrapJsFunctionForAsync_closure.$protected (main.dart.js:10936:15)
    at _wrapJsFunctionForAsync_closure.call$2 (main.dart.js:90469:12)
    at Object._asyncStartSync (main.dart.js:10900:20)
    at MaplibreMapController0.animateCamera$body$MaplibreMapController0 (main.dart.js:235159:16)
    at MaplibreMapController0.animateCamera$2$duration (main.dart.js:235113:19)
    at main.dart.js:232740:66
    at _wrapJsFunctionForAsync_closure.$protected (main.dart.js:10936:15)
    at _wrapJsFunctionForAsync_closure.call$2 (main.dart.js:90469:12)
    at Object._asyncStartSync (main.dart.js:10900:20)

with the following code:

    final cameraUpdate = CameraUpdate.newLatLngZoom(location, 16.5);

    await controller.animateCamera(
      cameraUpdate,
      duration: const Duration(milliseconds: 2100),
    );

@mariusvn @m0nac0

@JulianBissekkou
Copy link
Collaborator

@mariusvn or @m0nac0
Can some of you provide feedback?

@mariusvn
Copy link
Contributor

Hello, I'll take a look this weekend if i have time

@stefanschaller
Copy link
Collaborator

stefanschaller commented Jun 15, 2023

@mariusvn The issue is just in the release mode and it doesn't matter if the duration is assigned or not

    await controller.animateCamera(
      CameraUpdate.newLatLngZoom(location, 16.5),
      duration: const Duration(milliseconds: 2100),
    );

Also not working: (without the animation param)

await controller.animateCamera(CameraUpdate.newLatLngZoom(location, 16.5));

I also found out that moveCamera is working properly.

@JulianBissekkou
Copy link
Collaborator

I can verify that the fix that was suggested by @erik worked and I moved it into a pull request that can be reviewed.
#254

@JulianBissekkou
Copy link
Collaborator

Closing this as #254 is now merged and tested :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants