Skip to main content

Store Locator — End to End

Problem: A customer types an address. Show them the nearest store by drive time, on a map, with directions. This example combines four HERE APIs. Three of them are called at most once per session, and one of them is never called at all until the user clicks “Directions.” That distribution is the design.

The flow

Most visitors never click “Directions.” Computing the route on page render bills for a feature nobody used.

Prerequisites

  • HERE platform API key with Geocoding & Search, Matrix Routing, Routing, and Map Rendering entitlement
  • PostGIS with stores in an indexed geography column
  • export HERE_API_KEY="..."

Schema

Backend

Rendering

Leaflet — tiles, markers, route

Where the cost is

A 5,000-store network and a 50-store network cost the same per lookup. The shortlist bounds the matrix; the matrix does not scale with your network.That is why stage 3 exists.

Common mistakes

Ranking by straight-line distance. A store 800 m away across a river is not close. This is the defect that gets locators rebuilt. Matrix over the whole network. Shortlist first. Ten routing calls instead of one matrix call. Querying /discover or /browse for your own stores. Your stores are in your database. A public place index will silently miss the one that opened last week. Undebounced autocomplete. No AbortController. Paying to receive stale responses. Re-geocoding the selected label instead of /lookup by id. Routing to position instead of access. Directions on page render. No GIST index. Silently expanding the radius until something is found. A locator that cheerfully sends people 200 miles. Unrestricted API key in frontend JavaScript. No CDN on tiles.

Store Locator

The architecture, and the build-versus-buy decision.

Distance Matrix

Modes, ceilings, and the flat row-major array.

Render a HERE Map

Raster Tile v3, CDN, domain restriction.

Autocomplete an Address

Debouncing, cancellation, and /autocomplete vs /autosuggest.

HERE documentation


Need production HERE API keys or implementation support? Placematic is an official HERE Technologies reseller and implementation partner. Talk to us.