Search code examples
iphonecompass-geolocation

Iphone access compass in a html page


I'd like to get the direction (N/S/E/W) pointed by an iPhone inside a webpage (not an app). Ideally it would be gotten in javascript.

It is likely to be impossible but I would like to be sure. Do you know a way to get this ?

Thank you


Solution

  • Actually I found a demo here : http://ariya.ofilabs.com/2011/10/magnetic-compass-via-device-orientation.html

    It was successfully tested on iOS 5.

    It is said to be supported on iOS < 4.2 too, but a bad implementation of DeviceOrientation makes the magnetic North undetectable.