oferb / israelcoronamap

A website that shows Coronavirus cases in Israel
http://israelcoronamap.co.il/
Apache License 2.0
34 stars 21 forks source link

Location accuracy is low on desktop - should not show my position #75

Closed oferb closed 4 years ago

benjamingr commented 4 years ago

Hey, here https://github.com/oferb/israelcoronamap/blob/master/public/js/app.js#L22 you can pass enableHighAccuracy: true and check You can check the .accuracy parameter on the result. It's not documented in GitHub but it's part of the spec.

navigator.geolocation.getCurrentPosition((result) => {
  if (result.coords.accuracy < 20) { // assume less than 20 meters is GPS

  } 
}, dealWithError, { enableHighAccuracy: true })
oferb commented 4 years ago

Thanks @benjamingr! Problem is, we don't ask in advance location permission, only when the user presses the "zoom to my location" button. The reason is that we don't need that location until that button is pressed, and don't want to bother the user with that.

So if we add the button on desktop, what might happen is that the user will get an inaccurate location. So to prevent that entirely, we don't show on desktop.

Happy to hear your thoughts.

benjamingr commented 4 years ago

So if we add the button on desktop, what might happen is that the user will get an inaccurate location. So to prevent that entirely, we don't show on desktop.

I don't think there is a way to know ahead of time if getCurrentPosition will return an accurate location - so that sounds reasonable.

eilatc commented 4 years ago

we fix it by removing the current location on the desktop. closing.