Documentation

Directions Field

Last modified: January 14, 2025

Introduction

The Directions Field in Gravity Geolocation allows you to calculate and display directions, routes, and distances between multiple locations in your Gravity Forms. It integrates seamlessly with the Geocoder Field and Map Field for dynamic and interactive navigation experiences.

This field is ideal for delivery forms, logistics tracking, travel booking systems, and any applications requiring route calculations or distance-based services.

Gravity Forms Directions Field
Directions Field Front-end.

Configuring the Directions Field in Gravity Forms

Use the settings below to customize the Directions Field to fit your geolocation needs:

Directions field options
Directions Field Options.

1. Usage Type

Select the type of directions to calculate:

  • Driving Directions: Calculates the best route for vehicle navigation on standard roads, considering driving distance, duration, traffic, and road conditions (Default).
  • Straight-Line Computes the shortest distance between points as the crow flies, ignoring roads and terrain. Ideal for aerial or point-to-point analyses.

2. Route Points

Assign Geocoder fields to define origin, destination, and optional waypoints:

Origin Geocoder

Select the Geocoder Field for the starting location.

Destination Geocoder

Select the Geocoder Field for the destination location.

Waypoints Geocoders

Select Geocoder Fields as optional waypoints along the route.


3. Trigger Options

Configure how users trigger route calculations and customize button labels:

Trigger Type

Define the method for triggering route calculations:

  • Dynamic: Automatically trigger directions when location data is updated in the form (Default).
  • Manual: Require users to trigger directions manually using buttons.

4. Button Labels

Customize labels for manual trigger buttons:

Get Directions Button

Label for the "Get Directions" button ( Default: Get Directions).

Clear Directions Button

Label for the "Clear Directions" button. Leave it blank to hide the button ( Default: Clear Directions).


5. Map Options

Link the Directions Field to a Map Field for visual route display:

Map Field

Select a Map Field to display the route visually.

Polyline Options

Customize route appearance with attributes like color, weight, and opacity ( Example: strokeColor:'#0088FF', strokeWeight:6, strokeOpacity:0.6).


6. Travel Options

Customize travel preferences, including travel mode, units, and route restrictions:

Travel Mode

Choose the mode of travel for route calculations:

  • Driving: Optimized for vehicles on roads (Default).
  • Walking: Routes suitable for pedestrians.
  • Bicycling: Paths for bicycles, including bike lanes.
  • Transit: Public transportation routes.

Unit System

Define the measurement system for distances:

  • Imperial: Distances in miles (Default).
  • Metric: Distances in kilometers.

Avoid Ferries

Exclude ferries from route calculations.

Avoid Highways

Exclude highways from route calculations.

Avoid Tolls

Exclude toll roads from route calculations.


Setting Up and Using the Directions Field

Follow these steps to configure and use the Directions Field effectively:

  1. Add the Directions Field: Insert the field into your form using the Gravity Forms editor.
  2. Configure the Directions Field Options: Customize the field settings, including route points, trigger options, and map integration.
  3. Test Your Form: Preview the form and verify the directions, map display, and travel options function correctly.
menu-circle