Loading...

Add coordinates to your records

The finished example knows where every airport is. "Near me" needs one thing your records probably already have somewhere: a location — a latitude and a longitude — that Search Stack can measure.

Give each record a location

Each record carries its position as a latitude and longitude. Whatever your places are — shops, cinemas, depots, airports — if you can put a pin on a map for them, you can search them by distance.

[
  { "name": "Riverside Cinema", "lat": 51.4545, "lon": -2.5879 },
  { "name": "Harbour Screen",   "lat": 50.7184, "lon": -1.8801 }
]

Mark the field as coordinates

Turn on coordinates for the list so Search Stack treats that latitude/longitude as a location, not just two numbers. That's what unlocks distance: with it on, the engine can measure how far each record is from any point and filter to a radius.

POST https://api.searchstack.dev/coordinates/Demo/places
X-API-Key: {your key}

Go deeper: Coordinate fields and geo search in the reference.

Top