Google Routing Field

The Google Routing field enables you to retrieve route information in WordPress forms. Simply specify two form fields to act as a start and end location and WS Form will automatically make the calculations for you.

The following information can be obtained using this field:

  • Route distance
    • Text description
    • Value (miles, yards, kilometers and meters)
  • Route duration
    • Text description
    • Value (seconds, minutes, hours, days, weeks and years)
  • Summary (A short description of the route)
  • Latitude and Longitude of Start and End locations

Furthermore the route can also be shown on a WS Form Google Map field.

The above information is retrieved using a single API call to the Distance Service API each time the start and end locations are completed and/or changed.

Demo

How It Works

When a user enters a start and end location, the Google Distance Service API will request route information. If a route can be determined, information about the route is populated to fields on your form. The Google Routing field itself can be used to show information or it can be hidden if it is not required.

The Google Routing field can be used in conjunction with Google Address fields for easy choosing of start and end locations, as well as the Google Map field to show the route on a map.

Each Google Routing component can be mapped to one or many fields on your form, giving you complete flexibility over how the data is used.

The output can also be used in conjunction with Conditional LogicCalculated Fields and E-Commerce Fields.

WS Form PRO - Google Routing - Field Mapping

Setup

The Google Routing field requires:

To enter your Google API key into WS Form:

  1. Click Settings from the WS Form admin menu.
WS Form - Admin Menu Settings
  1. Click the Advanced tab.
  2. Enter your API key into the API Key setting under Google.
  3. Click Save.

Once the key has been added and saved you can add the Google Routing field to your form.

Adding a Google Routing Field

To learn how to add, edit, clone, move, resize, offset, or delete a Google Map field, please click here.

Templates

A good way of getting familiar with the Google Routing field is to try one of the ready-to-use templates. To use a template:

  1. Click Add New from the WordPress admin menu.
  2. Click the Google Maps tab at the top of the page.
  3. Choose one of the Google Routing templates.

Field Settings

To edit the settings for this field type, click the settings icon on the field itself. Click the Save & Close or Save button to save your changes. If you do not want to save your changes, you can click the Cancel button or click any other form element to close the field settings sidebar.

WS Form - Field Settings Icon

Basic

The basic tab contains settings that the majority of WS Form users will need to control a field. The settings are as follows:

Label

This is the label shown alongside the field. As well as entering a label into this field, you can also double click the label of the field in the editor. You should enter an easy-to-understand label for your field, for example First Name or Email.

Show Label

If enabled the label will be shown on your form. If you do not want the label to appear for a particular field, uncheck this box.

Required

If checked, the Google Address field must be clicked on by the user.

Hidden

If checked the field will be hidden on the form. It can be shown again using conditional logic or your own JavaScript.

Help Text

The help text setting enables you to add smaller text under the field to assist the website visitor in completing that field.

WS Form variables can be entered into this field.

Route

Start

Choose a field to use for the start location. You can choose the follow field types:

When using a Google Address field the user can conveniently enter a partial address and then select a full address from a dropdown list. When both the start and end location are chosen, WS Form will make a request for the route. Your Google API key will require the Places API enable on it to use this feature.

Other field types such as Text and Hidden can be used to allow a user to enter an address manually, or you can enter a fixed address to be used for either the start or end location.

Furthermore, other field types can also be populated with latitude and longitude values. They should be entered in the following format:

28.385233,-81.563873

A combination of Google Address and other field types can also be used.

End

Choose a field to use for the end location. See Start above for further details about this setting.

Field Mapping

Use this section to map the route components such as distance, duration and summary information to your form fields.

To map a field:

  1. Click the Add  icon at the bottom right of the field mapping section.
  2. In the left-hand column, select the routing component.
  3. In the right-hand column, select your form field.
  4. Repeat this process for each address field on your form.
  5. Click the Save button at the bottom of the sidebar to save your changes.

Google address components can be mapped to the following field types:

Travel Mode

Choose which transportation mode to use when calculating the route. The available options are:

  • Bicycling
  • Driving (Default)
  • Transit
  • Walking

Unit System

When mapping text based components (e.g. Distance – Text) this setting determines which unit is used when displaying that text.

Avoid Highways

If checked, the routes between origins and destinations will be calculated to avoid highways where possible.

Avoid Tolls

If checked, the directions between points will be calculated using non-toll routes, wherever possible.

Avoid Ferries

If checked, the routes between origins and destinations will be calculated to avoid ferries where possible.

Google Map

Choose the Google Map field to show the route on. Your Google API key will require the Maps API enabled on it.

Accessibility

ARIA Label

Accessible Rich Internet Applications (ARIA) defines ways to make web content and web applications more accessible to people with disabilities.

This setting enables you to define what text is made available to ARIA applications. This would, for example, provide a screen reader with specific text to read to someone with a disability.

The value of this setting defaults to your field label. If you would like to change this, enter a new value.

WS Form variables can be entered into this field.

Exclusions

Exclude From Emails

By default, WS Form uses the #email_submission variable in email templates. This provides a simple way of displaying all of the submitted fields in emails. Sometimes there might be a need to exclude a field from an email, for example, you might want to not include some introductory copy on a form, or hide a field you’re using with conditional logic to show or hide an element.

To hide a field from emails, check this box.

Other WS Form integrations may add exclusions in this section too, such as the WooCommerce integration which allows you to exclude certain fields from the cart entries.

Hidden Behavior

Always Include in Actions

This setting allows you to change the behavior of a field if the hidden setting is checked (See above), or if you set a field as hidden using conditional logic.

The normal behavior for a field that has been hidden is that it will not be included if an action has a Clear Hidden Fields setting enabled. For example, if you have a Send Email action, WS Form will not include fields that are hidden.

If this setting is checked, this field will always be included in actions if it is hidden.