Forum Documentation Showcase Pricing Learn more

Mileage tracking


#1

Anyone know a way to track mileage driven?


#2

You can use the API Connector to do this via Google Maps ?


#3

Yes I was looking at this earlier looks a little overwhelming at the moment.:thinking:


#4

Yeah, google APIs are not very friendly. And nor is the Developer Console.

Will have a look to see how possible it is.


#5

Much appreciated for your time Nigel.


#6

OK, so you need to go an get yourself a Google Maps API Key. Have a search on here, I think several have posted the steps to go via the Google Developers Console.

Then all you need to do is use the API

https://maps.googleapis.com/maps/api/distancematrix/json

Input your origins and destinations.

Slight wrinkle in that it returns multiple “rows” so you might need to pull out the first one with “firstitem”.

{
“destination_addresses”: [
“Hove, UK”
],
“origin_addresses”: [
“Brockham, UK”
],
“rows”: [
{
“elements”: [
{
“distance”: {
“text”: “53.7 km”,
“value”: 53708
},
“duration”: {
“text”: “54 mins”,
“value”: 3266
},
“status”: “OK”
}
]
}
],
“status”: “OK”
}


The "A distance From B" is a linear distance only, correct?
#7

Thank you Nigel I will investigate this.:+1:


#8

Hi @NigelG. I installed the Google Map extended plugin. But I don’t know how to use it.

I have input origin and input destination on my page. but I wasn’t sure how to display the driving distance in other input field.

Below is what I have so far. On first screen I have entered origin and destination based on input fields.

Below screen is the property of the third input which should show the distance, but I am confused what to enter in the “initial content”, it is asking either destination or origin address. But I have defined it under the “distance and duration” property.

googlemapextended2

Any example how to use this plugin. I am trying to calculate driving distance.


#9

Hi there,

Not a plugin I have used I am afraid. Are you still having difficulty ?


#10

Sorry, I thought you were using that plugin.

But yeah, I haven’t figured out how to do it yet. Which plugin are you using?


#11

No, not that one.

I have done mileage, but built my own Google API call in the API connector.

To do it with the plugin …

You get the same thing with the Google API, it gives you multiple rows back. But you could use firstitem I guess.


#12

This topic was automatically closed after 70 days. New replies are no longer allowed.