开发者

why Coordinates object's heading attribute always return null in mobile safari?

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);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜