Zip code to coordinates
The math needs latitude and longitude, and people type zip codes. So before the form submits, the browser asks Google’s Geocoding API for the center of that zip code, waits for the answer, and sends the coordinates along in hidden fields.
- Google APIs
- JavaScript
- jQuery
A map that frames itself
Results show up on a Google map with branded pins lettered A through Z (doubling up after that), a home marker for the zip code, and hover cards with the address, phone number and distance. Clicking a pin opens that address in Google Maps.
My favorite detail is the zoom. The map draws an invisible circle around the zip code, sized to the farthest result (miles × 1,609 to get meters), and fits itself to that circle. Whether the stores are 2 miles away or 80, the map frames exactly the results and nothing else.
Search from anywhere
Every product page had its own “Where to buy” link that passed the product along, so the form arrived already filled in. If a product had no store data yet, the page said so and pointed to online retailers instead of showing an empty map. The search form worked from any page on the site, carrying its values through the session to the results page, where the list paged itself five at a time with letters matching the pins.
- C#
- ASP.NET
- Kentico
- JavaScript