开发者

How to get 'heading' info from GPS on an iPhone WebApp

I am making a mobile webapp for iPhone and probably other devices and am able to get the lat/long with a reasonable acc开发者_如何转开发uracy but I'm not getting any other values from the phone's GPS. The 'heading' is quite important for what I'm wanting to do. Is there a way for Mobile Safari to give this info or is it not supported yet? I haven't found any information about how much of the W3C Geolocation API spec is supported by the iPhone.

I have tried a few libraries but haven't found them to give more functionality to the iPhone. I'm using:

navigator.geolocation.watchPosition(on_success, on_failure, options);

The watch position works better than getCurrentPosition seemingly because the GPS doesn't give a good reading when only called once. With watchPosition, the position is updated as it gets more accurate then I clear it when it's an acceptable value. I've tested with iPhone 4 and iPhone 3GS both with iOS 4.0.2. altitude, altitudeAccuracy, heading, speed all come back null. Parameters like enableHighAccuracy and a longer responseTime or timeout did not have any effect.

Any insight, even if that it is definitively not supported, would be appreciated. Thanks!


You should have a look at Geo Meter from Alex Gibson: http://miniapps.co.uk/geometer/

He outputs heading in his webapp.

/Mogens


Thanks /Morgens for your link, but Alex Gibson's script doesn't give access to the heading coords.

I just find this from apple which gives acces to.

http://developer.apple.com/library/safari/documentation/SafariDOMAdditions/Reference/DeviceOrientationEventClassRef/DeviceOrientationEvent/DeviceOrientationEvent.html#//apple_ref/javascript/instm/DeviceOrientationEvent/initDeviceOrientationEvent

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜