开发者

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

开发者 https://www.devze.com 2023-02-28 22:15 出处:网络
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?

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

精彩评论

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