Alexey Zakharov
Alexey Zakharov

Reputation: 25102

In what units is speed measured by W3C geolocation?

In what units is speed 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.

Upvotes: 1

Views: 2395

Answers (2)

Andrei
Andrei

Reputation: 1005

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

Upvotes: 0

Alexey Zakharov
Alexey Zakharov

Reputation: 25102

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..."

Upvotes: 5

Related Questions