function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Akeel WaniAkeel Wani 

How to display the list of nearby accounts using the geo location feature of latitude and lomgitude

Our Sales persons are always on the road. When they visit a customer (Account), they like to find out is there another customer (Account) nearby where they can visit for maximum utilization of their time. I know this scenario can be  automated using the Geolocation feature. I have a formula field on the account object Location_Address__c   
Formula is  ShippingStreet + ' ' + ShippingCity + ' '+ ShippingState + ' '+ShippingPostalCode

On the Account object I have the Shipping Latitude  and Shipping Longitude fields on my page layout which gives me the latitude and longitude.

My requirement is to have a Get NearBy” button on the detail page of Account record or have something similiar which can fethch the nearby accounts.
When the user will click on this record, we will display a list of nearby Accounts sorted by distance from the current account. The Salesperson can then decide which customers he will like to visit.
I know we can use SQL query but I am not sure how to populate the nearest accounts. 

I have already activated the Data Integration Rules for  account object. I havea activated Geocodes for Account Shipping Address and  Geocodes for Account Billing Address for account object.
Jason A HoultJason A Hoult
This will help write the SOQL statement using distance. https://help.salesforce.com/articleView?id=custom_field_geolocate_overview.htm&type=5
Morrison WelchMorrison Welch
In this article we take a look at how location information can be used to sort a list of items on a webpage. This might be useful for local search results; for example ‘Restaurants near me’ type searches, or for sorting a predefined list of locations such as a company’s office locations in order of distance from the user https://www.paygonline.us/
LOGAN FUENTESLOGAN FUENTES
Hi Akeel, wondering if you found a viable solution? I am working with a similar use case to find accounts nearby my mobile users