en.osm.town is one of the many independent Mastodon servers you can use to participate in the fediverse.
An independent, community of OpenStreetMap people on the Fediverse/Mastodon. Funding graciously provided by the OpenStreetMap Foundation.

Server stats:

268
active users

OpenCage 👉🌍

1/ Time for this week's geo thread.

We have some fun planned for the coming weeks, but this week we're back to

Today's topic is something we often see people get confused about: browser geolocation.

What is it, and how is it different than geocoding?

2/ Browser geolocation is a functionality supported by web browsers which lets users share their location - in the form of geographic coordinates (longitude and latitude) - with a web service.

3/ 🚨 Achtung! 🚨 - location is private information 🕵️, the user has to actively give permission for the browser to receive this info.

developer.mozilla.org/en-US/do

4/ How exactly the browser determines the location varies.

It may be from GPS 🛰️ or cell towers 🗼(on mobile) or wifi 📶 or IP-to-location. each of these methods have pros and cons.

Developers can ask the browser for a more or less accurate location.

Here's what that looks like in basic javascript:

5/ Assuming the user gives permission 👍, the browser then receives a longitude and latitude, and potentially other info like altitude.

Important: depending on the tech used these coords may be more or less accurate 👉🌍 The accuracy value is a number in meters that the actual position may vary from the reported position.

developer.mozilla.org/en-US/do

Note: browsers also allow users to turn off location prompting.

6/ ok, so now we have geographic coordinates!

We use them as inputs into reverse geocoding, which is turning coordinates into location human-readable location info.

You may recall our thread about the nuances of reverse geocoding en.osm.town/@opencage/11174365

7/ We have a guide to this whole process of browser geolocation to geocoding with example javascript (where the code screenshots above came from)

opencagedata.com/guides/how-to

8/ Want to see browser geolocation in action?

Give it a go on this OpenLayers tutorial:
openlayers.org/en/latest/examp

But make sure you haven't disabled geolocation in your browser settings. Some browsers helpfully show this in the nav bar.

Please note also that if browser location relies on IP geolocation it can be misled by VPNs.

9/ Wrapping up - browser location is an interesting tool that can be used to improve the user's web application experience.

But ... it requires user permission, and even if that permission is granted it can be inaccurate or misleading.

👩‍🎓 Want to learn more? Here's the official W3C geolocation spec: w3c.github.io/geolocation-api/

w3c.github.ioGeolocation APIThe Geolocation API provides access to geographical location information associated with the hosting device.

10/ Thanks for reading (and sharing) this week's 🌍🧑‍🎓thread.

If you found this interesting you may also like our thread about the details of IP geolocation:
en.osm.town/@opencage/11068468

or our thread about the privacy implications of geocoding:
en.osm.town/@opencage/11226344

We have links to many more geothreads about geospatial technologies, of individual countries, geocoding, border disputes, etc listed on our blog:
blog.opencagedata.com/geothrea