How to get proximity search with Location module to work
Submitted by Matt on Tue, 10/20/2009 - 10:38
Like many of you, I wanted the proximity search function in the Location module to work on my site. Turns out, it doesn't really work "out of the box", and I spent many weeks working on it but now I believe I have it working and wanted to share my success with others who may be disgruntled with the entire process.
- Download the Location module, the 3.x-dev version (2009-Jul-31)
- Install module
- Import MySQL database of US zip codes from the database folder (located inside the location module folder).
- Download the proximity patch
- Place the patch in the Location module directory
- Run the patch from the command line: patch -p0 < location_proximity_rerolled_321114.patch
- Now that it's patched, go to the Locations module settings (admin/settings/location) and select the option "Enable JIT geocoding".
- Enable other settings in the Location module, making sure you have a mapping API enabled, such as Google and enabled for the United States (admin/settings/location/geocoding and admin/settings/location/maplinking)
- Create a new node type or edit an existing node type to allow for Locations to be attached to the node (from what I understand, CCK Location fields do not work).
- Add/edit nodes with location information
- Download and install the Views module, if it isn't already on your site
- Create a new View
- Type: Location
- Add field Location: Distance / Proximity
- Units: Miles
- Origin: Use Distance / Proximity Filter
- Add field Node:Title
- Add Filter Location: Distance / Proximity
- Expose the filter
- Operator: Proximity (Circular)
- Form Mode: Postal Code (Assume default country)
- Optional: You can add other options such as a sort option, other fields to display, filters, et al. The options above are the necessary ones.
- Create a page or block to display the view
- Last step (and kind of tricky): Go into your Drupal MySQL database and go to the Locations table. In there, you will see all of the nodes that have a location. You need to change all of them to have a value of "4" in the "Source" column
That's it! Everything should work now.
»
- Matt's blog
- Login or register to post comments
