Setting up Location Module with zipcode search for Drupal 6.13

Events happening in the community are now at Drupal community events on www.drupal.org.
Susan Rust'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

Comments

Thank you

karlazz's picture

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

issues with collection settings

souleye's picture

Hi
I've been trying to follow the steps to implement the location module but when I reach 10, I don't know what 'Config for Collection settings' refers to. Also, I'm kinda baffled that for some reason, I'm getting an error with the gmap api key: This web site needs a different Google Maps API key. A new key can be generated at http://code.google.com/apis/maps/.
Any help will be appreciated.
Thanks

map key

tmcnamara98's picture

As for the second error, you do need a separate key for each site. In my case, I was developing on localhost and had a API key for that, but when I went to production, I got another key for the live site.

For your fist q, Collection Settings are set when editing the content type. You have to click on the link that says "Collection Settings" in the content type edit screen in order to configure it.

I hope this helps you.

-Tim

Great little Tutorial

paulybarnes's picture

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!

zip code not showing on search

souleye's picture

I don't know what i did wrong but on search I'm only seeing 'State/Province' and 'State'. No zip code. Any help will be appreciated. thanks

issues with location by zip

souleye's picture

I'm sweating over this one. I tried everything that I could possibly do. I'm trying to enable search location by zip. No matter what I do, it's still showing city and province.
url: www.autoreverseweb.com/

How do i make it work for

cithukyaw's picture

How do i make it work for Singapore postal codes ?

With Regards,
Sithu

Singapore postal codes

Rick Wagner's picture

Not aware of a source for those postal codes.

You might try the issue queue for the Location project:
http://drupal.org/project/location

See also installation notes:
http://drupal.org/node/1038010

It's always the small things

kehogo's picture

Thank you for your post! It took me a long time to figure out why my views query was showing:

'Unknown' AS location_distance

Thank you again!

San Diego DUG

Group categories

Event Classifications

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week