Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Drag a Pin to Update a Location

Let a service dispatcher drag a misplaced customer site to its real entrance on the map, then save the new latitude and longitude with Update Records.

A service dispatcher sees a customer site pinned in the middle of a park: the geocoder placed it from the address, but the loading dock is two blocks away. She drags the pin to the right spot and clicks Next, and the flow writes the new latitude and longitude to the account.

The same Mission map twice: on the left, Valencia Bikeworks pinned beside a playground near 20th Street; on the right, the same pin dragged about a block up Valencia Street.
The dispatcher drags the site to its real entrance, then clicks Next to save it.

Before you start

  • Dragging markers is a Leaflet feature. Leaflet maps load their tiles from OpenStreetMap: add https://tile.openstreetmap.org to Setup > Trusted URLs.

  • Accounts with a Billing Latitude and Billing Longitude.

  • Users of the flow need edit access to those two fields.

Steps

1

Get the sites to correct

  1. Create a Screen Flow.

  2. Add a Get Records element on Account, filtered to the sites to review (for example Billing City equals San Francisco), and store All records.

  3. Choose the fields to store yourself: Id, Name, Billing Latitude and Billing Longitude.

This tutorial uses the Variable data source on purpose: the Map then hands back the dragged records with their new coordinates already set, ready for Update Records.

2

Add the Map and point it at the records

  1. Add a Screen after Get Records and drag the Avonni Map onto it. Set its API Name to SiteMap.

  2. Click Edit Component. Set Type to Leaflet and Mode to Multiple Markers.

  3. Under Data Source, choose Variable and select the Get Records collection.

  4. In Data Mappings, map Title to Account Name, Location > Latitude to Billing Latitude and Location > Longitude to Billing Longitude. Keep Value on the record Id.

3

Turn on Draggable Markers

In the first group of the Properties tab, turn on Draggable Markers.

Leave Disable Auto Pan Markers off. The map then scrolls when the dispatcher drags a pin toward its edge, which helps when the right spot is just off screen.

The top of the Map's Properties tab with Type set to Leaflet, Mode set to Multiple Markers, Draggable Markers turned on and Disable Auto Pan Markers below it turned off.
Draggable Markers appears only on a Leaflet map.
4

Save the new positions with Update Records

Each drop updates the Map's Dragged Map Markers SObject output: one Account record per pin moved, with Billing Latitude and Billing Longitude set to the new position.

  1. After the screen, add a Decision with one outcome, Pins moved: {!SiteMap.draggedMapMarkersSObject} Is Empty False.

  2. On that outcome, add an Update Records element.

  3. Choose Use the IDs and all field values from a record or record collection and select Outputs from SiteMap > Dragged Map Markers SObject.

The Decision skips the update when the dispatcher clicks Next without moving anything.

5

Save and test

Activate the flow and run it with Debug or Run (dragging does nothing in the Component Builder preview). Drag one pin a few blocks and click Next. Open the account: Billing Latitude and Billing Longitude hold the position where you dropped the pin. Run the flow again and the pin starts from its new place.

Variations

  • Save on drop, without Next. In the Interactions tab, add a Marker Drag interaction. Set Type to Flow Navigation, then the second Type to Next Screen. Each drop moves the flow on and saves at once, which suits a dispatcher who fixes one site per run. See Flow Navigation.

  • Save only the last pin moved. The Map's Dragged Marker Latitude and Dragged Marker Longitude outputs are text. Create two Number formulas, VALUE({!SiteMap.draggedMarkerLatitude}) and VALUE({!SiteMap.draggedMarkerLongitude}), with a scale of 6 or more. Then use an Update Records element that finds the Account whose Id equals {!SiteMap.draggedMarkerValue} and sets Billing Latitude and Billing Longitude to the two formulas.

Troubleshooting

The pins do not move

Draggable Markers is off, Type is Google Maps instead of Leaflet, or you are testing in the Component Builder preview. Run the flow with Debug or Run.

The record is saved but the pin is back at its old place next time

Check whether an automation in your org recomputes Billing Latitude and Billing Longitude from the address after the save, such as an Account geocode clean rule. If it does, store the corrected position in a separate pair of number fields and map Location to those.

Was this helpful?