Now let me explain this new feature with a small code snippet.
In my account object, I have created one custom field of type Geolocation with name Head Office Location (API Name: Head_Office_Location__c).
Below is the code snippet –
As you can see in the above code what I am trying to find all the accounts whose head office is located within 1 miles from my current location. To achieve this, I have used my current location’s latitude and longitude as apex bind variable in SOQL query.
The way DISTANCE and GEOLOCATION function work are given below –
DISTANCE(mylocation1, mylocation2, ‘unit’)
GEOLOCATION(latitude, longitude)
Now after Summer’15, you can replace any of the parameters used in the above two functions by apex bind variable.
So to me, it is really a good feature. What do you guys think? Please provide your feedback. Thanks.
I think you've got a little bug in your example: DISTANCE(…) > 1 should be DISTANCE(…) < 1 as you've said that these are HQ within 1 mile.
Yes, you are correct. Thanks for letting me know. I have updated the code snippet.