Amani profile photo

Amani

Thoughts, realizations, accomplishments

Browser Geolocation and Maps

play.kilumanga.com

Amani Kilumanga

2 minutes read

The latest addition to play.kilumanga.com, apart from minor quality improvements, is a map page. It demonstrates geolocation using the browser.

The above GIF shows what a user accessing the /maps path for the first time should see:

  1. A popup from the browser, asking for permission to access location services
  2. An animated spinner, indicating that location is currently being approximated
  3. A map, centered on the user’s approximated location with:
    1. A marker at the user’s approximated location
    2. A circle, showing the full area where the user is approximated to be
    3. A popup, describing the elements on the map

I’ve had varied results when accessing this path from different machines. When I first tried it, I was sometimes getting something like a 30-kilometer radius, and only after waiting for the page to load for several minutes. Trying Microsoft Edge is normally not the first idea that comes to mind these days, but when I eventually did, I realized why it was acting up; location services were disabled in the OS. So, there are at least two points of failure for browser geolocation - the browser permissions, and the OS settings. Switching from a wired network to a Wi-Fi access point also seemed to change the location accuracy.

Regardless, for the best, and most relevant location data, you want to make sure you are either pulling it from a GPS enabled device, either directly or indirectly. Browser location can be a good supplement or replacement solution for when you can’t entice users to download an app.

Categories

About

A creative and meticulous Software Engineer who is passionate about delivering robust and general solutions through an iterative development process.