Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

getting magnetic field values

16 views
Skip to first unread message

Jacks

unread,
Apr 29, 2013, 11:53:52 AM4/29/13
to
Hi guys

I'm a begginer in web apps and I'm trying to get the magnetic field values x, y and z, like I do in Android, but I don't know how to do that.
On this page https://developer.mozilla.org/en-US/docs/DOM/Mozilla_event_reference
there is no reference to magnetometer in SensorEvents. I can get the values from accelerometer, gyroscope and every other sensor except magnetometer.

thank you guys

Harald Kirschner

unread,
Apr 29, 2013, 12:54:21 PM4/29/13
to Jacks, dev-w...@lists.mozilla.org
Hi Jacks,

you need the deviceorientation event, using the event property alpha.

The event API: https://developer.mozilla.org/en-US/docs/DOM/Mozilla_event_reference/deviceorientation

A demo: https://developer.mozilla.org/en-US/demos/detail/simple-compass/launch

And some more in-depth description of the values: https://developer.mozilla.org/en-US/docs/DOM/Orientation_and_motion_data_explained

Good luck!

---
Harald Kirschner | Partner Engineer & Web Craftsman | har...@mozilla.com (mailto:hkirs...@mozilla.com)
> _______________________________________________
> dev-webapps mailing list
> dev-w...@lists.mozilla.org (mailto:dev-w...@lists.mozilla.org)
> https://lists.mozilla.org/listinfo/dev-webapps
>
>


joao.mcm...@gmail.com

unread,
Apr 29, 2013, 1:52:32 PM4/29/13
to
Hi Harald, thank you for your time.

I don't want magnetic north, I want the values from the 3 axis (x,y and z), to be able to calculate magnetic field strength. I know that with the alpha from orientation sensor we can get magnetic north but this is not what I want.
In android, with TYPE_MAGNETIC_FIELD it is possible to get x value with event.values[0], y with event.values[1] and z with event.values[2]. This is what I want and I don't know how.

thanks
0 new messages