flutter_map_location_marker icon indicating copy to clipboard operation
flutter_map_location_marker copied to clipboard

Heading keeps resetting to north

Open Lah123 opened this issue 9 months ago • 9 comments

Describe the bug Every time I turn my device the heading changes shortly but then resets to north.

To Reproduce Steps to reproduce the behavior: Just any map with the CurrentLocationMarker.

Expected behavior I do not expect the heading to reset to north.

Smartphone (please complete the following information):

  • OS: Andriod 13.0, physical device
  • Flutter map location marker version 10.1.0

This is the code snippit I use:

              CurrentLocationLayer(
                  style: LocationMarkerStyle(
                      marker: const DefaultLocationMarker(color: colorPrimary),
                      headingSectorColor: colorPrimary,
                      accuracyCircleColor: colorPrimary.withValues(alpha: 0.3)))

Additional context Here a video, during the recording I turn my phone from left to right. The map is oriented to the north. I'm facing west (ish) with my phone, so it should point down. Every time it janks to north is the bug I'm facing:

https://github.com/user-attachments/assets/510d4263-e8d5-4a67-97a6-f3056757e41d

Lah123 avatar Apr 19 '25 15:04 Lah123

Could you check if this issue persists when running the example project (navigation) on your phone? This will help determine if the problem is specific to your implementation or a more general issue.

tlserver avatar Apr 22 '25 00:04 tlserver

Thank you for your response. I checked the example project and it does the same there

https://github.com/user-attachments/assets/d5cbc57f-9305-4fa5-b043-90d80248a29d

Although less, it is still 'creeping' to north. I read on the internet that it can be someting of my phone (oneplus nord 2), but I did not have this issue in earlier versions of this package. Just to be sure I checked another phone (android) with your example project. There the 'creeping' is gone, but it shows the heading 180 degrees in the wrong direction. It shows south when I point to north. This same 180 degrees issue is showing on iOS phones with my own app (I dont have an iOS phone here so I cannot check it with your example app).

As a summary:

My phone (oneplus nord 2): My app and your example app are creeping to north Another android phone: My app and your example app are 180 degrees in the wrong direction iOS: My app 180 degrees in the wrong direction, unable to test your example app as I dont have a iOS phone right now

All of these issues were not there in my previous release. These are the dependencies of my previous release:

dependencies:
  flutter:
    sdk: flutter
  # Service locator
  get_it: ^7.6.7
  # Bloc for state management
  flutter_bloc: ^8.1.4
  hydrated_bloc: ^9.1.4
  # Value equality
  equatable: ^2.0.5
  http: ^1.2.1
  # Functional programming thingies
  dartz: ^0.10.1
  # Local cache
  shared_preferences: ^2.2.2
  google_fonts: ^6.1.0
  latlong2: ^0.9.0
  flutter_map: ^6.1.0
  flutter_map_marker_cluster: ^1.3.4
  flutter_map_location_marker: ^8.0.6
  location: ^7.0.0
  retry: ^3.1.2
  flutter_lints: ^4.0.0
  video_player: ^2.8.2
  visibility_detector: ^0.4.0+2
  flutter_image: ^4.1.11
  just_audio: ^0.9.36
  rxdart: ^0.28.0
  path_provider: ^2.1.2
  upgrader: ^10.1.0
  lottie: ^3.0.0
  transparent_image: ^2.0.1
  animated_text_kit: ^4.2.2
  geolocator: ^11.0.0
  maps_launcher: ^2.2.0
  flutter_animate: ^4.5.0
  flutter_emoji: ^2.5.1
  provider: ^6.1.1
  universal_html: ^2.2.4
  wakelock_plus: ^1.2.8
  permission_handler: ^11.3.0
  camera: ^0.11.0+2
  native_device_orientation: ^2.0.3
  percent_indicator: ^4.0.1
  app_tutorial: ^1.0.6
  slider_button: ^2.1.0
  url_launcher: ^6.3.0

now my depencies are these:

dependencies:
  flutter:
    sdk: flutter
  # Service locator
  get_it: ^8.0.3
  # Bloc for state management
  flutter_bloc: ^9.1.0
  hydrated_bloc: ^10.0.0
  # Value equality
  equatable: ^2.0.7
  http: ^1.3.0
  # Functional programming thingies
  dartz: ^0.10.1
  # Local cache
  shared_preferences: ^2.5.2
  google_fonts: ^6.2.1
  latlong2: ^0.9.1
  flutter_map: ^8.1.1
  flutter_map_location_marker: ^10.0.0
  location: ^8.0.0
  flutter_lints: ^5.0.0
  video_player: ^2.9.3
  visibility_detector: ^0.4.0+2
  flutter_image: ^4.1.12
  just_audio: ^0.9.46
  rxdart: ^0.28.0
  path_provider: ^2.1.5
  upgrader: ^11.3.1
  lottie: ^3.3.1
  transparent_image: ^2.0.1
  geolocator: ^13.0.3
  maps_launcher: ^3.0.0+1
  flutter_animate: ^4.5.2
  flutter_emoji: ^2.5.1
  provider: ^6.1.2
  universal_html: ^2.2.4
  wakelock_plus: ^1.2.10
  permission_handler: ^11.4.0
  camera: ^0.11.1
  native_device_orientation: ^2.0.3
  percent_indicator: ^4.2.4
  app_tutorial: ^1.0.6
  slider_button: ^2.1.0
  url_launcher: ^6.3.1
  intl: ^0.19.0

output of flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.29.3, on Microsoft Windows [Version 10.0.26100.3775], locale en-NL)
[√] Windows Version (11 Home 64-bit, 24H2, 2009)
[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.12.3)
[√] Android Studio (version 2024.2)
[√] VS Code (version 1.99.3)
[√] Connected device (4 available)
[√] Network resources

• No issues found!

Does this help you?

Lah123 avatar Apr 22 '25 18:04 Lah123

@tlserver , would you need any other information from my side? I can't get this to work unfortunately.

Lah123 avatar Apr 28 '25 19:04 Lah123

Thank you for reporting this issue. I am currently unable to reproduce the problem on my device, so I will need some time to investigate the root cause. If anyone else is willing to help, please feel free to join the discussion here or submit a pull request.

This library is flexible and allows you to use any heading provider you prefer. Starting from version 10, the default heading provider was changed from flutter_compass to flutter_rotation_sensor because flutter_compass is no longer actively maintained.

For now, you can try switching to a different heading provider, such as compassx, or revert back to flutter_compass until this issue is resolved.

Here is an example of how you might configure the heading provider (note: this code is untested):

// In initState
// Configure CompassX or FlutterCompass before use (optional)
_headingStream = CompassX /* or FlutterCompass */.events!.map((event) => LocationMarkerHeading(
  heading: degToRadian(event.heading!),
  accuracy: event.accuracy != null ? degToRadian(event.accuracy!).clamp(0.1, 0.4) : 0.3,
));

// Then, in CurrentLocationLayer()
CurrentLocationLayer(
  headingStream: _headingStream,
);

Please let me know if you have any questions or further insights.

tlserver avatar Apr 29 '25 13:04 tlserver

I had the same problem. In iOS when starting my app the direction would start at north no matter what direction I was facing. From there it would track my movements but always in the wrong direction. I installed compassx with your code and it works great.

Hopefully you can fix the this bug.

jdevo2004 avatar May 22 '25 01:05 jdevo2004

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jun 21 '25 10:06 github-actions[bot]

In the end I also used the compassx to make it work. Hopefully you can find the cause as I would love to use your package.

Lah123 avatar Jun 21 '25 12:06 Lah123

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jul 22 '25 10:07 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Jul 29 '25 10:07 github-actions[bot]

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Nov 22 '25 10:11 github-actions[bot]