I wonder if it is possible to improve the accuracy of geolocation on openlayers 5, currently it is off by 5000 meters although I enabled highaccuracy option.

   var geolocation = new ol.Geolocation({
  // take the projection to use from the map's view
    trackingOptions: {
          enableHighAccuracy: true
    projection: view.getProjection()  

OpenLayers Geolocation makes use of the browser's geolocation interface which uses the operating system to get the user's location (http://openlayers.org/en/latest/apidoc/module-ol_Geolocation-Geolocation.html). The accuracy depends on the OS, its settings and the used sensors (e.g. the quality of the GPS signal).

enableHighAccuracy asks the OS to hand over "the best possible results. This may result in slower response times or increased power consumption. The user might also deny this capability, or the device might not be able to provide more accurate results than if the flag wasn't specified." (https://www.w3.org/TR/geolocation-API/#high-accuracy)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.