DEV Community

Cover image for How Do Laptops Know Where You Are Without a GPS Chip? (And How to Handle It in Web Apps)
Onyedikachi Emmanuel Nnadi
Onyedikachi Emmanuel Nnadi

Posted on

How Do Laptops Know Where You Are Without a GPS Chip? (And How to Handle It in Web Apps)

While building a location-critical feature for a web application recently, I encountered a fascinating technical challenge that highlighted a major difference between mobile phones and laptops: How web browsers determine physical location.

The Problem

I was implementing a GPS verification system for a tutor-student matching platform to verify the base locations of tutors offering home lessons. During testing on a laptop, the GPS verification kept identifying my location as "Awka North," when I was clearly sitting in "Awka South."

Furthermore, because Awka is a large area, the system only outputted the generic LGA name without narrowing down to specific streets. This led to a deeper investigation into how laptops handle geolocation compared to mobile devices.

The Science: How Web Geolocation Actually Works

Unlike smartphones and tablets, laptops and desktops do not have built-in GPS chips. So, when a web app calls the browser's Geolocation API, how does it get coordinates? The browser utilizes three methods, cascading down depending on available hardware:

GPS Satellites: This requires a physical GPS chip. It is the default on mobile devices but non-existent on laptops.

Wi-Fi Triangulation: The laptop scans the hardware IDs (MAC addresses) of all nearby Wi-Fi routers. It sends this scan list to a location service (like Google Location Services), which matches them against database records mapped by billions of active mobile devices.

IP Geolocation: If Wi-Fi is unavailable or the nearby routers aren’t mapped, the browser falls back to the internet provider’s IP address database. In developing tech markets, routing hubs can easily place a user in a neighboring town or district.

The Solution

To build a reliable user experience, i had to address two issues: the lack of precision on laptops and the potential for inaccurate automated guesses locking users out.

Here is how we solved it:

Precision Enhancement: I updated our geocoding service logic. Instead of just grabbing the nearest municipal, I combined all available address segments from the reverse geocoding API concatenating [Road/Street, Suburb/Neighborhood, City, LGA]. This immediately narrowed the location display down to specific roads.

Decoupling Coordinates from the Address Text: The raw coordinates (latitude/longitude) remain securely locked and hidden for tamper-proof distance calculations.

Verified-Only Editable Fields: I converted the user-facing address fields (LGA, State, Country) into text inputs that are hidden by default. They are only revealed after a tutor successfully clicks the "Verify My Location" button.

Key Takeaway

When building location-based software, always account for hardware limitations.

As a developer what do you think i could have done better? πŸ‘‡

Top comments (0)