Route Map
Puts a list of stops in the most efficient driving order and shows the route: the stops are numbered in the order to drive them, each with its distance and drive time, together with turn-by-turn directions and buttons that open the route in Google Maps. The ordered stop list is saved as the field's value, so it can be written into the record. Use it for a delivery run, a service route or a day of site visits.
Start Location - Required. Where the route starts: a street address, coordinates written as lat,lon such as 40.7354796,-96.7048616, a record field as [FieldName], or a field on this form as {FieldName}. A record field is read when the form opens; a form field is read when the route is calculated, so the route can start from an address the user has just entered.
End Location - Where the route ends, in any of the same forms. Leave it blank and the route returns to the start. The route always runs from the Start Location to the End Location; only the stops in between are put in order.
Distance Units - Miles or Kilometers, for the distances shown on the field and in the saved stop list.
Stops - The places to visit, up to 25. Each has a Location, which is a street address or coordinates as lat,lon, a Stop Name, and a Rec ID identifying it.
Where the stops come from
The stops come from the same places as the points on a Locations Map:
- typed into the Stops list
- the Dynamic Source under Custom Options, using the DMGETMAPLOCATIONS variable. The field it names for the location may hold a street address rather than coordinates.
- a Data Source field. Choose the Data Source Field, then say which of its columns is the Location Column (an address or lat,lon), the Title Column (the stop name) and the ID Column. The Description Column is not used by the Route Map.
A stop with a blank location is skipped, and the route is calculated from the rest. Skipped stops from the Stops list or its Dynamic Source are named in a warning; a Data Source row with no location is left out without one. Skipped stops do not count toward the 25.
Calculating the route
Nothing is calculated when the form opens. The route is worked out only when the Calculate Route action runs, so every Route Map needs a Button or Multi-Action that runs Calculate Route with this field as its Route Map Field. Each run works the route out again from the stops as they are at that moment.
Until then, the map shows a pin for each stop given as coordinates; a stop given as an address has no pin yet. Once the route is calculated, the stops are pinned with their numbers in driving order, S marks the start, and E marks the end when it is not the start.
If the route cannot be calculated, the field shows a message and changes nothing: the saved stop list and anything already on screen stay as they were. The messages are:
- "Route Map needs a Start Location."
- "There are no stops to route."
- "Route Map supports up to 25 stops; this list has", followed by the number of stops
- "Google returned no route for these stops. Check the addresses."
- "The route could not be calculated:", followed by the reason Google gives
When the stops change, through a Refresh Map or a Data Source that reloads, the route on screen is cleared and the map redraws the stops. The saved stop list does not change until Calculate Route runs again.
What is saved
The field's value is the ordered stop list as plain text, one stop per line, followed by the drive from the last stop to the end and the total:
1. Main Street Market - 410 Main St, Lincoln NE (3.2 mi, 8 min)
2. Oak Hill Cafe - 40.8136,-96.7026 (1.4 mi, 4 min)
Return to start: 1200 Libra Drive, Lincoln NE (5.0 mi, 11 min)
Total: 9.6 mi, 23 min
Each line's distance and time is the drive from the stop before it, or from the start for the first stop. A stop with no Stop Name shows only its location. When an End Location is set, the closing line begins with End: instead of Return to start:. Skipped stops are not in the list.
The list is saved like any other input field's value: turn on Save to Record and it is written into the record field named by the Field Name (see Common Field Settings). Calculate Route only fills in the field, so the form still has to be saved for the list to reach the record. In a Multi-Action, the actions after Calculate Route wait until the list has been written, so a save placed after it saves the new list.
The route itself is not kept. When the form is opened again, the map shows the stops but not the route, and the saved stop list stays as it is until Calculate Route runs again.
Directions and Google Maps
Below the map, the field shows the total distance and drive time, the start, and then each stop in driving order with the distance and time to reach it, ending with the drive back to the start or on to the end. Click a stop to show the turn-by-turn directions for the drive to it, or click Show turn-by-turn to open them all (Hide turn-by-turn closes them).
Turn-by-turn directions are never saved, in the field's value or anywhere else. Calculating the route again gives fresh ones.
The Open in Google Maps buttons open the route in Google Maps for live navigation. A Google Maps link can carry only a limited number of stops, so a route of 9 stops or fewer gets one Open in Google Maps button, and a longer route is split into sections: Open in Google Maps - stops 1-10, Open in Google Maps - stops 11-20 and so on, each section starting where the last one ended. When the last section is only the drive from the last stop to the end, its button reads Open in Google Maps - last stop to end. Google Maps accepts fewer stops per link in a phone's web browser than in the Google Maps app, so on a phone, use the Google Maps app rather than the browser.
Storing coordinates on records
The Route Map never saves the coordinates Google finds for an address; Getting Coordinates from Addresses shows how to add coordinates to your records with a free US Census service.
When the Census Geocoder cannot match an address, the call still succeeds but leaves both coordinate fields blank, which also clears any coordinates they held before.