Maps - and iOS / android directions

Hi - another question!

I have a public defib database - with a map. Knack

Ideally I want a button that says “take me to nearest defib” that will load either android maps or iOS maps and provide directions to the nearest defib…

im guessing it will have to be a page which just shows 1 record which is nearest to their location, and then they click, get record, and then choose iOS or android, but it;s a lot of clicks when someone is having a heart attack! If there is any way to bypass any of these steps etc that would great.

trial nearest page

thanks as always!

cheers

Andrew

What you can’t do (out-of-the-box) :man_technologist:

  • Automatically detect someone’s live GPS location without them submitting it.
  • Run geospatial queries like “show nearest within X miles” natively in Knack alone.

Pretty sure you’ll need to code it.

Hi Andrew

Here’s a suggestion from Deepseek to get you on your way to finding a solution.

The most reliable method would be to:

  1. Create a custom “Near Me” page in Knack
  2. Use the geolocation API as shown above
  3. Configure your asset records with latitude/longitude fields
  4. Use Knack’s distance calculation functions to sort results

Automated GPS Detection

// Sample code for Knack view to auto-detect location
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
function(position) {
// Pass coordinates to Knack
Knack.showSpinner();
Knack.views.yourViewName.filters({
latitude: position.coords.latitude,
longitude: position.coords.longitude
}).then(function() {
Knack.hideSpinner();
});
},
function(error) {
console.error(“Geolocation error:”, error);
},
{enableHighAccuracy: true, timeout: 5000}
);
}

Please let us know how you get on as we might incorporate the solution into our app to save clicks, not that time is off the essence for us going to the nearest asset.

Good luck.

Dean