开发者

In what units is speed measured by W3C geolocation?

开发者 https://www.devze.com 2023-03-19 17:10 出处:网络
In what units is spee开发者_如何学Pythond measured by W3C geolocation? I have tested in on my Android using Phonegap:

In what units is spee开发者_如何学Pythond measured by W3C geolocation?

I have tested in on my Android using Phonegap:

When I am running it shows 5-6, when I am walking it shows 1-2.


From W3C specification, §5.4:

"The speed attribute denotes the magnitude of the horizontal component of the hosting device's current velocity and is specified in meters per second..."


Here is a code that displays the speed in MPH:

var speedEl = document.getElementById('speed');
navigator.geolocation.watchPosition(function(geodata){
    var speed = geodata.coords.speed;
    if(speed === null || speed === 0){
        speedEl.innerHTML = "You are standing still";
    }else{
        speedEl.innerHTML = (speed * 2.23693629) + "Mph";
    }
},function(){
    speedEl.innerHTML = "Unable to determine speed :-(";
}, {enableHighAccuracy: true});
0

精彩评论

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