Setting up Location Module with zipcode search for Drupal 6.13

greenbirdmedia's picture

We really struggled with this module and thought this might help others avoid the black hole.

1. Setting up Location Module with zipcode search for Drupal 6.13
Location: 6.x-3.1-rc1: http://drupal.org/project/location
GMap: 6.x-1.1-rc1: http://drupal.org/project/gmap
CCK: 6.x-2.5
Views: 6.x-2.6

2. Prelim with Google:
Create a Google account. If you are using GMail or Google Analytics you probably already have one.
Get a Google Maps API: http://code.google.com/apis/maps/signup.html
Save the API key as you will need it later.

3. In Drupal:
Activate both the GMap and Locations Modules
Activate the CCK and Views modules
(GMAP, GMAP Location, Location, Location Search, Node Locations)
Turn on Content (and any other CCK options you want)

4. Create a new Content type
For this example we'll create a new Directory Listing content type: /admin/content/types/add

    Name: Directory Listing
    Type: directory_listing
    Description: Directory Listing

5. Config for Database:
Import the zipcode database into the zipcodes table of your Drupal database
use phpMyAdmin or command line
If using phpMyAdmin, make your Drupal database active by selecting it
Click the Import tab near the top of the phpMyAdmin interface.
Navigate to a local copy of the Location module, location/database/zipcodes.us.mysql
Click Open (or Choose), then the Go button
This may take a few minutes to import
Note: if you are using table prefixes you will need to add them to the zipcode file before importing.
Database prefixes are OK as is

6. Permissions for gmap_location module
Permissions- allow your admins and site editors to set user location
Config settings to show node map and show user map

7. Config for gmap_location module
Copy in your Google maps API Key:
Click the Save configuration button at bottom of page
Config for GMap Location-defaults OK

8. Permissions for location module:
Permissions: allow your admins and site editors to submit latitude/longitude

9. Config for location module:
Main settings tab-defaults OK
Map links tab-Uncheck all except United States: Google Maps
Geocoding tab-Click ON United States/Google Maps
Search options tab-defaults OK

10. Config for Collection settings:
Set Location name, Street location, City, State/Province, Postal code and Country to Allow, and Additional, and Coordinate Chooser to Do not Collect. The Country Default should be United States.
Under Display Settings, click the Hide the fields for Additional, Coordinate Chooser, Province name, Country name and Coordinates. Leave the other fields unchecked (not hidden) for now.
Click the Save content type button

11. Config Views:
Create a few sample Directory Listings with location information including zipcod

Add:
View name: location_by_zip
View Type: Node

Filters:
Node: Published (Yes)
Node: Type (Is one of: Directory Listing)
Location: Distance / Proximity
Country: United States
(Proximity Circular)

Expose:
Form mode: Postal Code (assume default country)

Fields:
Node: Title
Link this field to it's node
Save, Preview

12. Testing:
Enter a zip code and a distance to search
Add a Page display to the view by choosing Page from the pop-up menu (left column)
Add a path for the page under Page settings by clicking on the word "None" in Path: None and entering the path
Click Save one more time to save this view
Enter the path you set in another browser or new browser window to test

Susan | Green Bird Media Loves Drupal
"The secret to happiness to want what you have and don't want what you don't have" --The 14th Dalai Lama

Groups:
Login to post comments

Thank you

karlazz - Fri, 2009-10-30 17:58

This is very helpful and everything worked out just fine, even for this Drupal newbie.


Great little Tutorial

paulybarnes - Fri, 2009-11-20 23:13

Thanks so much for putting this together, been very helpful. I'll probably need to re-read it a couple of times because my search isn't processing any locations. I am even typing in the zipcode of one of the locations.

I am sure I missed something, but if you can think of anything let me know!