开发者

In what units is speed measured by W3C geolocation?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜