I would like to add a driving distance calculator from my location to a user inputed location

  • 5Kforms
    Asked on September 20, 2019 at 11:33 AM

    I want customers to calculate their travel fee by inputting their address. This address would be routed from our office location and the resulting drive time would be multiplied by an hourly rate resulting in their travel fee.

  • Richie JotForm Support
    Replied on September 20, 2019 at 12:49 PM

    We do have a widget that calculate the driving distance.

    https://widgets.jotform.com/widget/driving_distance

    Checked your form and it seems you have already added the widget in your form.

    However, it seems the widget is not working correctly.

    I would like to add a driving distance calculator from my location to a user inputed location Image 1 Screenshot 30

    Kindly add your Google Map API key for the widget to work.

    I would like to add a driving distance calculator from my location to a user inputed location Image 2 Screenshot 41

    To get the key, you can go to this link:https://developers.google.com/maps/documentation/javascript/get-api-key

    Hope this information helps.

  • 5Kforms
    Replied on October 10, 2019 at 3:10 AM

    I'm still having trouble with it. I would like my users to input their address without seeing the originaating address, then have their address copied to the "to" address. The I want to use the output of miles and hours to be used in calculations like strings. Is that possible? 

    Heres what i have so far:

    https://form.jotform.com/92821331857157

  • BJoanna
    Replied on October 10, 2019 at 3:57 AM

    You can hide the originating address of the Drivers Distance widget by adding the following CSS code to the widget's Custom CSS tab:

    input#ddFrom {

        display: none;

    }

    1570693939css Screenshot 10

    How to Inject CSS Codes to Widgets

    It is not possible to pass the data from the Address filed to the Driving Distance widget. Your users will need to enter the address directly inside of the widget. 

    To perform a calculation please check this guide:

    How to Perform Form Calculation Using a Widget

  • 5Kforms
    Replied on October 10, 2019 at 3:30 PM

    Thank you!

    Managed to hide the initial location, but now I cant get the widget to work. I put my api key in from google maps, but still won't work... says the page can't load google maps correctly.

    Also, I'm wondering how I can access the output data (drive time & mileage) in my form calculation?

  • Welvin Support Team Lead
    Replied on October 10, 2019 at 4:44 PM

    I checked, but you still do not have the key there. Kindly double check that.

    I would like to add a driving distance calculator from my location to a user inputed location Image 1 Screenshot 20

    I've cloned your form and can get it to work there with my API: https://form.jotform.com/92826494831972. That means you are only missing the API key, and it should work after. 

  • 5Kforms
    Replied on October 10, 2019 at 6:58 PM

    Put my API in, but its still not working, any ideas? https://www.jotform.com/build/92826977587178

  • KrisLei Jotform Support
    Replied on October 10, 2019 at 8:11 PM

    Hello,

    I checked your form and checked the console logs while in Preview mode. It shows that the API key is invalid or showing "Invalid Key Map Error". 

    1570752460Invalid key map error Screenshot 10

    Please generate a new API key and replace it as stated below.

    InvalidKeyMapError Error

    The API key included in the script element that loads the API is not found. Please make sure you are using a correct API key. You can generate a new API key in the Google Cloud Platform Console.

    For more information, see Get Started with Google Maps Platform.

    For your reference: https://developers.google.com/maps/documentation/javascript/error-messages#invalid-key-map-error

    Let us know if the issue still persists. 

  • 5Kforms
    Replied on October 11, 2019 at 12:37 AM

    Got it figured out, thanks everyone for all your help!