1/ Time for this week's geo thread.

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

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.

https://developer.mozilla.org/en-US/docs/Web/API/Geolocation

#geoeducation

Geolocation - Web APIs | MDN

The Geolocation interface represents an object able to obtain the position of the device programmatically. It gives Web content access to the location of the device. This allows a website or app to offer customized results based on the user's location.

MDN Web Docs

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:

#geoeducation

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.

https://developer.mozilla.org/en-US/docs/Web/API/GeolocationCoordinates

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

#geoeducation

GeolocationCoordinates - Web APIs | MDN

The GeolocationCoordinates interface represents the position and altitude of the device on Earth, as well as the accuracy with which these properties are calculated. The geographic position information is provided in terms of World Geodetic System coordinates (WGS84).

MDN Web Docs

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 #geoeducation thread about the nuances of reverse geocoding https://en.osm.town/@opencage/111743653275940467

OpenCage πŸ‘‰πŸŒ (@[email protected])

Attached: 1 image Let's close out the week with a geo thread. This time #geoeducation rather than #geoweirdness Today's topic is one that doesn't get as much respect as it should. Ask most people about geocoding, they automatically think forward geocoding - turning text (an address or placename) into coordinates. Today though we'll cover the opposite: reverse geocoding 1/n

OSM Town | Mapstodon for OpenStreetMap

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

https://opencagedata.com/guides/how-to-determine-user-location-via-browser-geolocation

#geoeducation

Browser geolocation and geocoding

OpenCage guide to using browser geolocation and geocoding to determine a website visitor's location with detailed javascript tutorial

8/ Want to see browser geolocation in action?

Give it a go on this OpenLayers tutorial:
https://openlayers.org/en/latest/examples/geolocation.html

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.

#geoeducation

Geolocation

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: https://w3c.github.io/geolocation-api/

#geoeducation

Geolocation API

The Geolocation API provides access to geographical location information associated with the hosting device.

10/ Thanks for reading (and sharing) this week's #geoeducation πŸŒπŸ§‘β€πŸŽ“thread.

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

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

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

OpenCage πŸ‘‰πŸŒ (@[email protected])

In this week's thread we take a little break from #geoweirdness to switch to #geoeducation πŸŒπŸ§‘β€πŸŽ“ Today we clarify an oft confused and conflated topic that we get asked about a lot: the difference between geocoding and IP geolocation 1/n

OSM Town | Mapstodon for OpenStreetMap