PinPoint Distance calculates straight-line distance between any two coordinates, and can find the N nearest locations from a list of Things relative to a source point — using the Haversine formula, no external mapping API required.
HOW IT WORKS
1. Place an As PinPoint Distance element anywhere on your page (it's invisible — position doesn't matter).
2. For a simple two-point distance: set lat1 / lng1 / lat2 / lng2 to any dynamic values. The distance states update automatically — no action or workflow needed.
3. For finding nearest locations from a list: call the Find N Nearest action with a source point, a list of Things, and how many results you want.
4. Read the results from the states below, or listen for the "nearest calculated" event to chain further workflow steps.
ACTIONS
- Find N Nearest — takes a source location and a list of Things, returns the closest N sorted by distance
EVENTS
- nearest calculated — fires once Find N Nearest has finished sorting and slicing results; use with the states below
STATES
- distance_km — distance between point 1 and point 2, in kilometers (updates live from lat1/lng1/lat2/lng2)
- distance_miles — same distance, in miles
- distance_meters — same distance, in meters
- distance_feet — same distance, in feet
- distance_nautical_miles — same distance, in nautical miles
- nearest_ids — list of text; Unique IDs of the N nearest Things, sorted nearest first
- nearest_distances — list of number; distances parallel to nearest_ids, in the unit chosen on Find N Nearest
- nearest_count — total number of results returned (may be less than N if the source list was smaller)
NOTES
- Works with any custom data type for Find N Nearest — just tell the action which fields hold latitude and longitude.
- nearest_ids and nearest_distances are parallel arrays: index N in one corresponds to index N in the other. This lines up correctly inside a Repeating Group cell via "Get index in current list."
- To display a nearest result's own fields, set a Repeating Group's data source to nearest_ids (type of content: text), then inside each cell use: Do a search for [YourType]:filtered by (Unique id = Current cell's text):first item's FieldName
- The simple two-point distance (lat1/lng1/lat2/lng2 → distance states) works with static coordinates, database fields, or Bubble's built-in Address/Geographic type — no action needed for that part.
Demo Editor:
https://bubble.io/page?id=pinpoint-distance-demoLive Demo:
https://pinpoint-distance-demo.bubbleapps.io/version-test