I want to get Geo information through Geolocation API on mobile safari, but Coordinates object's heading attribute always return null. Does safari not support heading attribute?
Code blow:
window.onload=function(){
navigator.geolocation.watchPos开发者_运维问答ition(successCallback,errorCallback);
function successCallback(position) {
var coords=position.coords;
console.info(coords.heading);
}
function errorCallback(){}
}
mobile Safari does not support the heading attribute, but it does support its own proprietary attributes.
window.addEventListener('deviceorientation', function(e) {
var heading = 'heading: ' + e.webkitCompassHeading +
'\n' +
'headingAccuracy: ' + e.webkitCompassAccuracy;
alert(heading);
}, false);
精彩评论