The new summer’16 feature automatic geocode for the address helps to track your nearby prospects and clients but you can also able to create location-based activities for the account, lead or contact records. Let’s see how to create location-based activity records. In this, below example, I will use the account record geolocation to track my activity records.
As a first step, set up the geocode clean rules - https://developer.salesforce.com/blogs/developer-relations/2016/07/making-salesforce-data-location-aware.html?language=en Once you setup the rule then, geocodes are automatically added to existing accounts, contacts, and leads. New accounts, contacts, and leads get this information when they’re saved.
Next, I have created custom checkbox field in activity object called ‘Remind me at a Location’. Enable the checkbox field when creating the activity record. This is to identify which task I want to see based on the current geo-location so this activity record will use the Account billing address geolocation in our custom page.

Lightning component
Now let's create a lightning component to display the activity records based on the current location in the Salesforce1 mobile app or in the browser. The lightning component has two logics first to identify the current geolocation of the user and next display the account activity records which is nearby based on the current geo-location.
Getting current geolocation
When the page loads first the lightning controller will get the current geolocation of the user and assign it to the component attributes. Below the simple code to get the current geolocation in lightning components
currentgeoLocation.js
doinit : function(component, event, helper) {
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(function(position){
component.set("v.comLat",position.coords.latitude);
component.set("v.comLong",position.coords.longitude);
});
}
}
Now we have the current geo-location of the user, using that geo information we can able to retrieve the account task records which is nearby 20 mi. The SOQL query to retrieve the task record is as follow
SOQL
Database.Query('Select Id,Name,(select Id,subject,Account.Name,Status,priority from Tasks where remindatalocation__c = True and isClosed = False)
from Account where Distance(BillingAddress,Geolocation('+lati+','+longi+'),\'mi\') < 20 limit 10');
When the user opens the lightning page in the salesforce1 mobile or in the browser then it will display the only activity records which are nearby based on the account record geolocation.
You can deploy this component by clicking this below button

You can deploy this component by clicking this below button
Source code - https://github.com/Karanrajs/Location-Reminder

