Calculate Mileage with native Knack maps

How do I calculate mileage from point a to point b using native Knack mapping?

No native way to do this in Knack.

This thread may be of interest:

Highly recommend reaching out to Alejandro Zakzuk @Soluntech

Hi @Kyle - this is actually pretty simple to do with Make (formerly Integromat).

You set up a suitable trigger for your “Scenario” (Search, Updated or New Record etc) and then use the Google Maps module to calculate the distance for you. You can then update the same record with the result:

You needs a Google Maps API account to do this - which is fairly straightforward to set up and then connect your Make module to that.

The advantage is that this is still a NO CODE solution!

1 Like

Carl,
I read this last night and the way the thread ended seems like the original poster did not get it to work. I figured Knack would have a way to do in Here Map. I did not try the code you posted since I do not have a Google Map API code. Maybe I will have to try this. Have you used it?

Hi @Kyle - I’ve not had a use case for requiring mileage for an application yet. I’d recommend @JulianKirkness method as a no code approach is often easier.

Thanks, Knack said to use Make. Trying out Make.com

1 Like

Good day, Sir. I signed up Google Developer and got API key, copied this into Knack, enabled Google Map APIs that Knack suggested, signed up for Make and did what it says with Google. I got everyone connect, (i think) but I can not figure out how to build the Scenarios.
Trying to pull Knack address data from the field, SHIP FROM and SHIP TO into Google, then use these fields to calculate miles from these to points, then Google or Make should update the same record with calculated mileage into the Transport Miles Field in Knack. Not sure what I am doing wrong.

Any help would be greatly appreciated.
Kyle McAfee
McAfee Trucking
812-416-8964

Hi Kyle

Looks as though you are getting the scenario triggered by a new record or update - which is fine as long as both origin and destination are completed. However, when you trigger a scenario in this way, the trigger module only returns the ID of the record. So…

  1. After the New Event module, add a get record module and use the id from the new event to retrieve the record with the addresses in.

  2. Update the Maps module to have the to and from fields from the get record module as the Origin and Destination - BUT turn off the ‘Map’ option for the Origin and Destination and add an ‘item’ to each like this:

  3. Add an Update Record module to take the results from the map module and update your Distance field:

The arrow shows the value you need to select (if you want miles) - the other option is in metres I think.

This should then complete the process. One thing to warn you about is that the Maps module will give an error if either of the address fields are empty - so you should maybe add a filter before to stop the scenario if either are blank.

Hope this helps.

Julian

1 Like