A Tour of Web Capabilities

Location Accuracy

Maximiliano Firtman

Maximiliano Firtman

Independent Consultant
A Tour of Web Capabilities

Check out a free preview of the full A Tour of Web Capabilities course

The "Location Accuracy" Lesson is part of the full, A Tour of Web Capabilities course featured in this preview video. Here's what you'd learn in this lesson:

Max discusses some caveats with location accuracy on iOS and iPadOS. Users specify whether they want web applications to use precise or imprecise location data. This will apply to all web applications, and there is no API for determining which mode the user selected.


Transcript from the "Location Accuracy" Lesson

>> We have to see something else before leaving geolocation, and it has to do with iOS. Since iOS and iPadOS 14, users can decide if they want to share with apps precise or imprecise location. If you have an iPhone, you probably have seen that. When you see the dialog, I'm talking about native apps.

When you see the dialog about getting location permission, you can decide if you want precise or imprecise. The problem with web apps is that for the iOS, Safari is one app for all the websites. So, if the user, the first website that they have visited, with geolocation on that phone, if the user has selected imprecise, every website from that moment will get imprecise location.

And what's that? It will give you roughly the city, or in big city is the neighborhood. That's all. It will pick a random place there, and there is no API to know in which mode the user is, at least from a web point of view. For imprecise, in my testing, you will typically get the accuracy property between 3000 and 9000, that's meters.

So that's around between 2 and 6 miles. So that's a way to know when you look at the property from the results of the call back, if it's on that range, you know we are in the imprecise world. It's smart enough, that system, to work okay with borders.

I know, if you are close to the border to Mexico or Canada or between France and Spain, if you are in the French side, it will give you an imprecise location, but in France, okay? So it won't cross borders. So you will get the real country, at least, or the real state or province, okay?

In that case, it's good. It's not just a random place around. It will try to keep the same city, at least, okay? Makes sense? And Android 12 has something similar, but the issue is, in the case of progressive web app, is per app, not for Chrome as a whole as with Safari.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now