Store Locators: Placing a Pin on the Map

From time to time we build a store locator or a similar location and map search component of a website. The basic idea is a website visitor can type in their zip code hit submit and the site will produce a map with a bunch of pins in and around the previously entered zip code. Sounds useful right?

When building these type of components into a website there are a number of “hidden” complexities that we encounter each time. The most common complexity we run into is geocoding.

What is geocoding? The short answer: Convert a real address to the latitude and longitude. The address itself isn’t directly used for the placement on a map it’s the “lat and long”.

Since most people don’t keep a list of lat and longs for their addresses we have to use a 3rd party service to geocode them. We largely use Google, it’s free-ish and it’s easy enough to use from a developer’s point of view. The catch to using Google is they only allow 2,500 geocode requests per day and their API doesn’t like it if you ask for too many at the same time. They do offer an enterprise license that removes most limitations, in the situation where the license doesn’t make sense or is cost prohibitive we have to get creative.

To work within those limitations we build into the project a way to trickle convert those addresses. The trick is to make a request every few minutes over a number of days until the entire list has been geocoded. The length of time depends on the number of address. So let’s say you sell a consumer product that is sold in stores nationwide. The list of stores you want in your locator is upwards of 30,000 addresses. If we do the math it means it will take about 12 days to geocode every location.

In most situations this isn’t a big deal as long as the part of the project that depends on these addresses is built at the start of the project and not the tail end. We can work on other aspects of the project while the addresses are being geocoded in the background.