Source code from the Geolocation Toolkit challenge:
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Install apex-lang 1.17 managed package

Deploy code to org

Obtain Simplegeo oath key and secret key

Go to Setup | App Setup | Develop | Custom Settings
Click Manage for Global Variables
Click New
For name, enter SimpleGeo.OAuthKey and in the Value field, enter your oauth key
Click Save
Click New
For name, enter SimpleGeo.SecretKey and in the Value field, enter your secret key
Click Save

Add a Remote Site to:

Create some accounts with valid Billing Addresses in the United States (that's all Simplegeo supports)

Run following anonymously (to geocode accounts):

System.debug(                           //after running this command, the batch apex job ID will be output to the log
         'BillingAddress__c'            //address field name
        ,'Latitude__c'                  //the latitude field to update
        ,'Longitude__c'                 //the longitude field to update
        ,'Account'                      //the object name which contains the latitude and longitude fields
        ,null                           //criteria; null means attempt to geocode all records on the object
        ,''    //optional email to notify when complete

Once that's complete, go to VF page GeocodeSearchNearbyDemo and execute searches.

Since the idea is to create a toolkit, my main goal
was to make my code reusable for any SObject (not
just Account) and also define an easy way for
other geocoding service to be plugged in.  The main 
class is GeocodeService and I suggest the following 
methods in that class as a starting place for review: