See new documentation page for geofield that shows how to setup a basic proximity search (it is based on MotoTribe's answer, but with a bit more info)
As requested, some of the link content:
Instructions
Required modules
You must download the latest modules. These instructions have been tested with the 'dev' versions of geocoder, geofield, and addressfield modules. I believe these modules have a dependency on geophp, maybe others, install any dependent modules that you are instructed to when installing. Make sure to download the 'dev' versions!
Steps
Setup your content type:
- Create a content type for whatever you want to locate (e.g. Dealers, Stores, etc)
- In manage fields: Add an addressfield field to the content type (use options as you see fit).
- In manage fields: Add a geofield field to the content type. When adding, make sure to select 'Geocode from another field' from the 'widget' dropdown! The geofield option are pretty straightforward, just make sure to select the addressfield field you created earlier for the 'Geocode from field' option.
- Now, create a few records with addresses using your new content type.
That was easy! Now, let's setup the view result...
Setup your views query:
- Create a view, can be any kind. Select the content type you created earlier for the results.
- Add a field: '[name of your geofield] - proximity' (there are a number of geocoding related fields, you want the one with '- proximity' appended)
- In the field settings: For the 'Source of Origin Point' field, select 'Exposed Geofield Proximity Filter'.
- Add any other identifying fields, such as title, address, etc.
- Add a new 'Filter Criteria' for your view for the '[name of your geofield] - proximity' field.
- Choose 'Expose this filter to visitors, to allow them to change it'
- For 'Operator', choose 'Is less than', because you want results that are closer than a certain distance from the value your users enters, e.g. less than 100 kilometers, etc.
- For 'Source of Origin Point', choose 'Geocoded Location', which will allow the user enter friendly values such as city, state, zip/postecode, state, etc. (basically, anything you can put into Google location searches).
- For Geocoding Service, choose 'Google Geocoder'.
- Add a Sort Criteria: '[name of your geofield] - proximity'. Also, remove any other sort filter already existing, since sorting by date first will foil your proximity filter!
- Set to sort ascending, since you probably want to show the closest results first.
- Set 'Source of Origin Point' to 'Exposed Geofield Proximity Filter'.
- Test your new proximity search!