Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now

Setting up the Location module


Drupal 6: Online Presentation of Data

with Tom Geller

Video: Setting up the Location module

When it comes to entering addresses in Drupal, you could of course just setup a bunch of CCK fields such as street, city, state and so on, then tie those CCK fields into a free geocoder, such as the one provided by Google's API and it would work. Fortunately though, you don't have to roll your own solution. Address entry in geocoding is such a common need that a Drupal developer named Brandon Bergren put together some modules that do it all for you. The first one we're going to look at is the location module, which you can get from Brandon also wrote the GMap module. We'll show you how to use that module in the video mapping with the GMap module.
Expand all | Collapse all
  1. 13m 21s
    1. Welcome
      1m 12s
    2. Reviewing requirements
      3m 35s
    3. Using the exercise files
      3m 36s
    4. Touring examples of data visualization
      4m 58s
  2. 27m 55s
    1. Planning data structure
      8m 26s
    2. Importing and manipulating data
      6m 39s
    3. Looking at Drupal's database
      6m 13s
    4. Deciding whether to store personal data as nodes or users
      6m 37s
  3. 1h 12m
    1. Understanding the Content Construction Kit (CCK)
      4m 57s
    2. Creating new content types with CCK
      7m 26s
    3. Hiding the Body field
      2m 46s
    4. Reflecting CCK field data in the Title field
      7m 28s
    5. Managing CCK field placement
      7m 32s
    6. Exploring CCK's other features
      8m 22s
    7. Using other CCK field types
      3m 25s
    8. Adding date information as a CCK field
      8m 43s
    9. Including images as CCK fields
      10m 23s
    10. Connecting content to existing nodes
      5m 58s
    11. Using taxonomies to categorize and group data
      5m 59s
  4. 53m 54s
    1. Understanding why views are useful
      6m 12s
    2. Using SimpleViews to create basic content views
      5m 49s
    3. Diving into the Views interface
      11m 16s
    4. Adding fields to a view
      7m 12s
    5. Understanding iconic controls in the Views interface
      7m 15s
    6. Surveying the Sort, Filter, and Field options in Views
      5m 40s
    7. Adding view displays as pages, blocks, and RSS feeds
      10m 30s
  5. 43m 48s
    1. Overriding default settings on view displays
      8m 56s
    2. Attaching more information to views
      10m 57s
    3. Improving view appearances with grid, list, and table formatting
      9m 20s
    4. Surveying other basic display settings in Views
      11m 3s
    5. Altering a view's appearance through CSS
      3m 32s
  6. 55m 0s
    1. Importing, exporting, and cloning views
      6m 9s
    2. Controlling access to views
      7m 19s
    3. Learning from built-in views
      5m 52s
    4. Creating views that aren't based on nodes
      10m 6s
    5. Extending views with arguments
      10m 9s
    6. Extending views with relationships
      7m 2s
    7. Going further with relationships
      8m 23s
  7. 46m 39s
    1. Understanding geographic data
      4m 25s
    2. Setting up the Location module
      16m 20s
    3. Entering geographic data with the Location module
      10m 10s
    4. Displaying basic maps with the GMap module
      6m 43s
    5. Integrating the GMap module with Views
      9m 1s
  8. 54m 21s
    1. Exporting data in tabular form
      11m 25s
    2. Planning with the calendar modules
      11m 31s
    3. Using the Charts module and Google Charts
      7m 11s
    4. Graphing data with Open Flash Chart
      4m 50s
    5. Making important data pop out with tag clouds
      7m 46s
    6. Putting it all together in an attractive package
      11m 38s
  9. 36s
    1. Conclusion

please wait ...
Watch the Online Video Course Drupal 6: Online Presentation of Data
6h 8m Intermediate Jul 01, 2009

Viewers: in countries Watching now:

Drupal's built-in data presentation tools offer several ways for web designers to clearly and attractively package their data. In Drupal 6: Online Presentation of Data, Tom Geller explains how Drupal handles data so users can set up intelligent structures and implement them with Drupal's Content Construction Kit. Tom also shows how a data-driven web site can improve its interactivity by using geographic data to connect real-world addresses to maps. Exercise files accompany the course.

Topics include:
  • Importing and manipulating data in Drupal
  • Presenting date-formatted information in calendars
  • Understanding Drupal's data-query interface, "Views"
  • Improving view appearances with grid, list, and table formatting
  • Importing, exporting, and cloning views
  • Extending views with arguments and relationships
Tom Geller

Setting up the Location module

When it comes to entering addresses in Drupal, you could of course just setup a bunch of CCK fields such as street, city, state and so on, then tie those CCK fields into a free geocoder, such as the one provided by Google's API and it would work. Fortunately though, you don't have to roll your own solution. Address entry in geocoding is such a common need that a Drupal developer named Brandon Bergren put together some modules that do it all for you. The first one we're going to look at is the location module, which you can get from Brandon also wrote the GMap module. We'll show you how to use that module in the video mapping with the GMap module.

So you'll see how a lot of hooks between the two modules allow them to operate in tendon. I should warn you ahead of time that this module isn't the most polished. You'll notice that in the demonstration ahead. But as with many things in Drupal, it's continually involving. So there is hope for improvement. Also the competitor module called GO holds a lot of promise, and might eventually supplant the location module. Right now though, the Location Module is the most popular and mature one out there that does what it does. But do check back, as they say in the Drupal community, the drop is always moving. The first thing that you need to do is download and install the Location Module.

Once you have it in your Drupal folder, go to Administer > Site building and Modules, then scroll down until you see the Location group and there it is. Location installs many modules; the only one you need to turn on at first is the one called Location. We'll discuss some of the other modules later in this video and also in the mapping with the GMap module video. But for now, we'll just go down to the bottom of the page, click Save configuration to turn it on. Once you've enabled that module, go to your Administer page, the configuration page for the location module is found in the Setting section under Site configuration, go down to Location and click on it.

There are three parts to configuring the location module. Let's look at the first one. That's Main settings. There actually aren't very many settings on this page; in fact, we don't need to change any of them. If you wanted to allow people to set their latitude and longitude by simply clicking on a map, then you'd enable this checkbox. As for the other settings there is plenty of explanatory text there should you want to explore them, but for us we'll just leave it as it is. The second tab here Map links, gives a list of the different services you can use with the location module. As we scroll down, you see it's very often Google, Yahoo! and MapQuest. Google Maps is always the one that's turned on by default so we'll also leave this turned on the way that it is just fine.

Finally, we come to Geocoding options. This is the part that's going to give us those points that we want from an address. You should turn on all of the countries that you think you might be mapping and there are quite a few here. So you'll spend a few minutes scrolling through and clicking in the radio buttons. The reason that they come turned off by default is that you should read the terms of use before turning on any of these. I know that people usually just whiz through these legal documents, but Google Maps has a few important restrictions you should know about. Notably, this section Restrictions on Use, spells out what you can and can't do. For example, you can't use Google Maps if you charge users to access the maps or for certain business application such as tracking a fleet of company owned trucks. But for our purposes, we'll assume that the terms are just fine.

We go back to our Geocoding options page. I'll turn off Albania and only go down to the United States, since that's the only country that I'm going to be mapping. The fastest way to find that is to hit Command+F or Ctrl+F on the PC then type in, United States. Once down there, scroll down a little bit, so you can see all your choices and we'll turn on Google Maps. Scroll to the end, and save our configuration. I recommend that you do these steps before you even start entering addresses. It is possible to enter addresses first and then geocode them later but the location module isn't very well setup for that. So it's best to take care of the Google Maps stuff right upfront.

The next thing that you need to do is sign up for a Google Maps API key. That's how that Google Maps knows who exactly is getting their geocoding information. Unfortunately, it's not that easy to find in the location module but you can find it if you go back to the Main Settings tab. Look down here where they talk about having a Google Maps API key. Click on that. It takes you to the Google Maps API page. From there you will see a link somewhere that says Sign up for Google Maps API key. Once again you see a long list of terms and conditions, at the bottom if you agree, you click this checkbox, and type in your URL. In our case that's simply local host. Although of course, if you do create your site locally and then put it on a server, you will need to get a new Google Maps API key otherwise your maps won't work.

Don't worry though. They're all free. I type in localhost and click on Generate API Key. If you haven't already created a Google account, you'll have to do so here. I have, so I'm going to enter it and then get my key. Once you're signed into Google, you're given your key, simply copy it by hitting Command+C on the Mac or Ctrl+C on the PC, and go back to your Drupal installation, I'll do that by hitting the Back button a few times. Once you have your gmap key, go back to Geocoding options and search once again for United States or whatever other countries you have enabled. After you had saved it, the last time you can now configure parameters including entering that API key.

Now, we just need to paste that key into our field. On the Mac, you use Command+V. On the PC you use Ctrl+V and click Save configuration. That's it for the initial setup. Now, let's start geocoding. What we're going to do is we're going to create a household for each person to live in. we're making the assumption that each person has only one household but that each household can contain many people and what's called a one to many structure. We could do it in other ways. For example, we could allow people to have more than household or we could force each person to enter their own household address and just forget about relating it altogether. Like all decisions, it's a tradeoff.

I'm sure you can see how these tradeoffs can have strong social and even political ramifications. So the way you plan your data structure really does mean a lot. But let's go ahead and create our content type. As you know we do that by going to Content management > Content types and Add content type. We'll call this content type Household. The machine name will be household with a lower case h. The Description is let's say 'A place where people and pets live.' Scroll down a little bit.

For our Submission forms settings, we'll be doing something interesting with the title in a minute. But I just want to change this Body field label. So it's Notes about this household. Just in case we want to keep such notes. We don't really need any submission guidelines. Scrolling down little further, let's make it so that it's not promoted to the front page. Technically that won't make a difference in our site because you remember our front page is actually that table showing all of the people. But we might as well keep it clean. Scrolling down further, we see this new area that we hadn't seen before, Locative information. This is where you actually specify how many locations and how they're displayed and so forth. The first setting is Number of locations.

Here the module does something strange by default. It says that you're going to have zero locations, but then you're going to add them three at a time. Well, that doesn't make any sense and it doesn't matter to us because we're just going to have one location, easy enough to change. Change it to 1 location minimum, 1 location maximum and 1 added at a time. Let's take a look at some of the other settings. For Collection settings, again the defaults are a little bit strange. The programmer for some reason did not have people entering their City, State or Postal code but we actually do want to allow people to do that, so we'll change that to Allow.

Incidentally, you can also force a default. So for example, since we're only working with United States, we could force default to United States. But I'm just going to leave it as it is. It doesn't really matter that much. If someone enters an address outside of the United States, it simply won't be mapped but it will still be on the database. There is another section here I want to make sure you notice, Collapsible and Collapsed. Again, a sort of strange default is that when somebody fills out this form, the location information doesn't show up. It shows up as one of those little tiny clickable areas like you see here and very often people filling out the form will miss it. My preference for location is to get rid of both Collapsible and Collapsed. That way they're forced to see the location and enter it.

Scrolling down further, we can change RSS Settings. We won't be getting into that. It's actually a fairly arcane subject, you can leave through the options if you like and read up about them on For Display Settings you have the option of hiding certain pieces of information. You can see which one of those are here. I'm just going to leave them all showing, so we can see what's going on. Finally, of course, you can allow people to put comments on locations, which we won't do. There's one final thing I want to do to this content type, all that I really wanted for is for people to enter an address. They don't have to enter a title for the address or anything else. I'm going to scroll up to the top and using a trick that you remember from earlier in the course. I'm going to give it an Automatic title. This is using the Auto Nodetitle module. I'll automatically generate the title and then look at my Replacement patterns.

When you installed the location module, it also installed a number of these new tokens. If you scroll down, you will see all of these new Location tokens. They all have this unusual thing at the end, _N that's because with locations, you remember you can have multiple locations in a node and the N value is what you used to say which location you want. If you wanted to point to the first location, you'd say location 0 because of the way computers count 0 is actually the first one. If you wanted the second one, it would be 1 and so forth. Well I'm not going to go through all of that right now. I happen to know exactly what sort of replacement pattern I want to use. It's going to be [location-street_0 ], [location-city_0], and then we could scroll down to the bottom and save our new content type, all the way down.

We're really getting quite fast at creating these content types and now, we're even ready to go and create our first household. We do that as usual by going to Create content. We see Household and there is our form. As expected, we don't actually see any title up here because it's being automatically created. There is our Notes about this household and as we scroll down further, this is where we actually enter the information. I'm going to call this house, House of Pretty Good Repute, the Street is 1 South Main Street, the City is Oberlin, Ohio, and the Postal code is 44074.

By the way if you get any bright ideas of going to that address, it's just a bank. Don't worry about it. Let's scroll to the bottom and click Save, and we have created it. Now, you we'll notice something that we didn't enter but that Google actually gave us, it's these, the coordinates. That's the geocoding magic. But I do want to mention something. If you can't get an address to geocode properly because the geocoder is getting information from a remote server, it only works if you are online. Also geocoding will only do as much as it can. In the Google maps API for example, it will figure out a zip code if you don't provide one. It'll geocode to the middle of a city, if you don't give the address.

But if you don't give a city and it doesn't really know where 1 Main Street is, it has a choice of many, many cities, obviously it won't be able to give you the coordinates. So we now have households, but we still don't have anyone living in them. Let's fix that now by adding a node reference field to the person's content type. What we're going to do is make it so that each person is referred to a household. To do so, we'll go back to our household content type. By clicking Administer > Content management and Content types. Then of course we go back to our Household and manage fields.

The New field we are going to add is called Resident, field name is resident, and the field type is Node reference. I think I want to show people a whole list of checkboxes so that they could check exactly which people are in the household. Mind you if you start dealing with hundreds and hundreds of people, you'll probably want to use something else such is an auto complete field. But for our purposes since we only have about a dozen or so people, I'm going to go with that. Scroll down to the bottom and save, which takes us to our settings page. The only thing I'm going to change here is the Number of values. I want to allow any number of people to be living in this household. So I'll change that to Unlimited. What exactly goes into the household, a person, so that's the type that gets referenced here. Scroll down to the bottom and Save. Now we've households and we have people and we have a way to connect the two.

Let's go ahead and do that. We'll do that by going to Administer > Content management and Content and find the household that we just created, 1 South Main Street. Remember that title was automatically created from the address that we put in. We'll go and edit it, and as we scroll down, we see a list of all the people who can live there. I'm going to put Tom de Nada in that house, scroll down and save. Now, if we go back to that household, we actually see the residents who live there. That information continues to be referenced in other ways so that we can build a view for example that shows everybody who lives in every household and so forth. We could add more people, we can remove more people, we can click to go to Tom's node if we want and so forth.

So we've completely done exactly what we wanted to and if we want to, we can go back through and put all of the people into households as desired. In fact, if you go into your exercise files that's exactly what we've done. All you need to do is load up the exercise files and you'll see that people are now assigned to households. You might remember when we first installed it there were quite a lot of modules installed. I'm going to go back and just talk a little bit about what those modules are very briefly. I would recommend though that you spend a little bit of time if you start doing any sort of geo location Drupal sites and actually get to know what all of the location modules are.

To go and look at them, we go to Administer > Site building and Modules and I'm going to start scrolling down. Do you remember that there was a location group at the end of the screen, but also when you installed location it put something in the CCK group called Location CCK? So that's another way you can add locations, not just in the core of a node but as a CCK field. Scrolling down further we see all of these different ones. GMap, we'll be discussing when we show you how to map the different locations in Google Maps. Location Add Another lets you add multiple locations one after another in an interesting interface. Location Fax, Location Phone, these are simply fields that you add on to location. I personally have never found them very useful but maybe you will.

User Locations lets you assign locations to each individual member of your Drupal site and then later it shows you a map, showing where all of your members live, assuming that they entered their location. I find that very interesting, you'll see that particular functionality on a lot of sites. Finally, Location Search gives you some interesting options for example, for proximity searches, who is nearby, who is within 100 miles and so forth. Finally, I just want to mention one other thing. If you search this page for Locale, you see that there is actually a module in core called Locale. That causes a lot of confusion, because it's related to translations not location and on each user's account page, there is a section called Locale Setting that has to do with time zones. So just remember, when you're dealing with physical places, you want location and not locale.

But back location, as I mentioned it has many tricks up its sleeve. We're next going to look at a few of those with the video mapping with the GMap module.

Find answers to the most frequently asked questions about Drupal 6: Online Presentation of Data .

Expand all | Collapse all
please wait ...

Q: The exercise files for the course appear to be missing.

A: Full exercise files for this course were not provided because of the unusually large amount of images, modules, and other files that would have to be installed in specific places, in addition to the database. We hope to have a solution for future Drupal courses that installs all items in their correct places.

Q: During the course the author makes reference to being able to add data via the exercise files; however, the data is not in the exercise files.
A: During the recording of the title, some of the exercise files were removed, since the frequent updates to Drupal itself and to the modules that are needed to run the exercise files cause them to break.

The data referenced in the video consists mostly of names and addresses, which will need to be typed by hand.
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.

Mark all as unwatched Cancel


You have completed Drupal 6: Online Presentation of Data.

Return to your organization's learning portal to continue training, or close this page.


Upgrade to View Courses Offline


With our new Desktop App, Annual Premium Members can download courses for Internet-free viewing.

Upgrade Now

After upgrading, download Desktop App Here.

Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Start your FREE 10-day trial

Begin learning software, business, and creative skills—anytime,
anywhere—with video instruction from recognized industry experts. provides
Unlimited access to over 4,000 courses—more than 100,000 video tutorials
Expert-led instruction
On-the-go learning. Watch from your computer, tablet, or mobile device. Switch back and forth as you choose.
Start Your FREE Trial Now

A trusted source for knowledge.


We provide training to more than 4 million people, and our members tell us that helps them stay ahead of software updates, pick up brand-new skills, switch careers, land promotions, and explore new hobbies. What can we help you do?

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.