I’ve been experimenting with web-based Geolocation technologies in a small proof of concept Rails application. The application itself is pretty vanilla: I wanted to build something that shows me where I am right now, and where some determined locations are at a fixed position. The idea being that I could see how far away I am from my favourite donut shops. Read more...
The biggest challenge in designing a system like this is deciding how to track Geolocation information in the application. I already know there are many server-side IP-based Geolocation patterns. But HTML5 offers a Geolocation api, so I wanted to look into some of the patterns that are just emerging, so I could choose the best way to track location data.
Round Pegs, Round Holes
If you’re a real software engineer, you probably know interesting problems have many possible solutions - the best of which will depend on what you’re actually trying to accomplish. Based on what I wanted the app to do, I started to research both server-side and client-side solutions, with the intent of really understanding why to use one over the other.
Below I will explain some of the realized benefits and disadvantages of each.
Server-Side IP-Based Geolocation
– lives on the server, so signal strength isn’t a factor.
– does not require end-user permission, so your UX can be slightly simpler.
– usually relies on existing geo databases; which could become stale
– accuracy suffers - you can only locate people at the city level.
Where would I use this:
– Auto-selection of country specific information; language, currencies, etc.
Client-Side HTML5 Geolocation
– high accuracy (street level) - You can locate objects within a few metres of their actual location.
– requires end-user permission - People are fickle.
– browser compatibility (HTML5) - if you care about that sort of thing.
– depends on signal strength - EDGE may not cut it.
Where would I use this:
– Real-time indicator of users location, nearby points of interest, etc.
After gathering this research, I realized my application serves two primary functions: One to track a visitor’s current, ever-changing coordinates. The other to locate a destination based on fixed coordinates. I am using a combination of these technologies, and also a hybrid model which interfaces the client-side information back into the Rails application.
If you are interested in reading the source code of this proof of concept, take a peek at my Github repository.