Simon Ferndriger
Simon Ferndriger

Reputation: 4952

Can the HTML5 geolocation accuracy be detected?

When using the HTML5 navigator.geolocation.getCurrentPosition on a website, the result contains the coordinates of the website visitor (if the browser does support this feature).

However, the accuracy highly depends on the visitors device (i.e. mobile with GPS, WLAN; stationary with a specific browser; etc).


Is it possible to find out about the accuracy of the returned coordinates, i.e. if they are a rough estimate or highly precise?

Upvotes: 0

Views: 92

Answers (1)

Igor Gilyazov
Igor Gilyazov

Reputation: 777

According to spec:

interface Coordinates {
  ...
  readonly attribute double accuracy;
  readonly attribute double? altitudeAccuracy;
  ...
};

The accuracy attribute denotes the accuracy level of the latitude and longitude coordinates. It is specified in meters and must be supported by all implementations.

The altitudeAccuracy attribute is specified in meters. If the implementation cannot provide altitude information, the value of this attribute must be null.

The accuracy and altitudeAccuracy values returned by an implementation should correspond to a 95% confidence level.

If you want highly precise result, then set enableHighAccuracy option to true.

Upvotes: 1

Related Questions