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

It's off by 90°, it claims east is north #11

Open
hipunk opened this issue Apr 28, 2020 · 5 comments · May be fixed by #13
Open

It's off by 90°, it claims east is north #11

hipunk opened this issue Apr 28, 2020 · 5 comments · May be fixed by #13

Comments

@hipunk
Copy link

hipunk commented Apr 28, 2020

Like described it thinks east is where north is.
Tested on two devices with multiple browsers.

@hipunk hipunk changed the title It's off by 90°, it claims east is It's off by 90°, it claims east is north Apr 28, 2020
@DenJansen
Copy link

DenJansen commented Apr 28, 2020

I ran into—and corrected—this issue, but only for Android and only for Chrome (I have more work I'm doing on this project).

The issue is that a year after Lamplightdev wrote this code, the event handler window.ondeviceorientation changed to calculate orientation relative to your device's current position, NOT True North. So every time you refresh, it's always going to point relative to the direction you're facing when you accessed the page.

The fix I've implemented so far (and again, only confirmed to work on Android and only on Chrome) is to change the event handler to window.ondeviceorientationabsolute .

See the code here (note, this version is not designed to point to True North, but a designated location here in Vancouver, WA):
https://github.com/DenJansen/CompassTest/blob/master/index.html

Edit: here's the implementation in my actual project, which uses trigonometry to turn it into a compass that points at a user-designated location rather than True North: https://github.com/DenJansen/SakanyTaurus/blob/master/sakanytaurus/sakanyapp/templates/sakanyapp/compass.html

@AC0793
Copy link

AC0793 commented Jul 28, 2020

@DenJansen Was that implementation in your project the last update? Or have you made any more progress in fixing this issue for other browsers?

@DenJansen
Copy link

@AC0793 I'm afraid that's the last update at the moment. I've been busy with other projects, and haven't really prioritized this one, since a pub crawl app seems a little anachronistic at this time :-/

I do plan on exploring this more in the future. It's going to involve digging through documentation on event handlers for various devices/browsers, as there doesn't seem to be a universal event handler for this information.

@alitaba1349
Copy link

hi there
thanks for modifications but,
it doesn't work on chrome (iphone / android) and ios 13.5 too !
just worked on ios 9 , 10
can anybody help on this?

@DenJansen
Copy link

Hi, just as an FYI to everyone, I did play around with the compass a little more about a month ago. If you're interested in capturing device orientation events, I recommend checking out the Generic Sensor API. It's the best effort so far to create a universal event for capturing info from device sensors. Still nowhere near 100%, but definitely better than the ondeviceorientation events for universality: https://mobiforge.com/design-development/the-generic-sensor-api

@antgiant antgiant linked a pull request Dec 26, 2021 that will close this issue
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 a pull request may close this issue.

4 participants