Skip to content

Conversation

@shenzhuxi
Copy link

@shenzhuxi shenzhuxi commented Sep 23, 2025

Platforms affected

Android

Motivation and Context

#78 gave sinHeading and cosHeading instead of heading like the original plugin.

Description

So, I followed https://github.com/CompassMB/MBCompass replaced deprecated Sensor.TYPE_ORIENTATION.

It also handled the screen orientation issue with remapCoordinateSystem. #51

MBCompass behave differently from most map apps - the compass orientation is based on the device orientation and different when the screen tilts forward/backward.
So, I used TYPE_GRAVITY to detect the screen pitch orientation. As long as you don't use the screen heading to the ground (negative pitch), the plugin's behave should be the same as Google Map.

Testing

Samsung Galaxy Tab S5 and Pixel 7a

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

https://github.com/CompassMB/MBCompass/blob/main/app/src/main/java/com/mubarak/mbcompass/sensor/AndroidSensorEventListener.kt

rewrite native code to replace TYPE_ORIENTATION with TYPE_ACCELEROMETER & TYPE_MAGNETIC_FIELD

handle screen orientation apache#51

use TYPE_GRAVITY solve compass orientation difference for tilted screen (MBCompass missed)
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

Successfully merging this pull request may close these issues.

1 participant