Skip to content

Instantly share code, notes, and snippets.

@suddeb
Last active August 29, 2015 14:20
Show Gist options
  • Save suddeb/d4cf553e3b07f756f9b9 to your computer and use it in GitHub Desktop.
Save suddeb/d4cf553e3b07f756f9b9 to your computer and use it in GitHub Desktop.
DistanceOperation
public class DistanceOperation {
public static void calculateDistance(){
Double myCurrentLocationLatitude = 10.20;
Double myCurrentLocationLongitude = 10.20;
List<Account> allAccounts = [SELECT ID FROM ACCOUNT WHERE
DISTANCE(Head_Office_Location__c,
GEOLOCATION(:myCurrentLocationLatitude, :myCurrentLocationLongitude),'mi') < 1];
if(allAccounts.size() > 0){
System.Debug('Total number of accounts: ' + allAccounts.size());
}else{
System.Debug('No Account Found');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment