I have a salesforce geolocation field that i've put in coordinates.

Is it possible to be able to get driving distance from that field? Or would i have to do it with google maps API?

There was another question regarding distance but it seems to not involve driving distance; It involves straight line distance.

2 Answers 2


Sort of... Salesforce now has a DISTANCE() function which can be used in formula fields, but it is only "straigh-line" distance and not the distance you would travel is using roads.

I use this in a custom formula field today to help sales agents priortize and identify Leads nearest them.

One Example: Distance between two geolocation fields

DISTANCE(warehouse_location__c, store_location__c, 'mi')

This formula returns the distance, in miles, between the warehouse and the store. In this example, warehouse_location__c and store_location__c are the names of two custom geolocation fields.


To easily get driving directions, you can create a custom formula field with type of URL that will open GoogleMaps with the geocoordinates populated as parameters. You can use Merge fields in salesforce to get the lat/lon values for each geolocation.


saddr is your starting point daddr is your destination

When the map loads, you can see driving distance and instantly get directions. What's nice is this also works seamlessly on mobile devices from salesforce1 app.


The DISTANCE SOQL function works on straight line distances. There's some discussion of that here.

I think the Google API would be your best bet for driving distances.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .