Online Book Reader

Home Category

Mapping With Drupal - Alan Palazzolo [17]

By Root 321 0
to use. At the time of publication, there is not a stable release of the Location module for Drupal 7, but the development version works fine.

Download the latest development release of the Location module to your site’s modules directory.

WARNING

The Location module that you download contains several modules, two of which will be used in this example.

Confusingly, the Location module contains both the Node Location module and the Location CCK module. You should probably just ignore the Node Location module.

These two modules both allow a location to be attached to a node in different ways: the Node Location module is a relic of the way that modules worked in Drupal 4.7 and Drupal 5 and does not use the Fields API (or CCK in Drupal 6). If you use the Node Location module, the location form will show up in the vertical tabs at the bottom of the node adding form.

The Location CCK module takes advantage of the Fields API (or CCK in Drupal 6) and is usually the better option to use unless you are upgrading an old site and want a simpler migration process. It is usually a bad idea to enable both modules, as it can be confusing, and if you accidentally enable both methods of collecting location on a particular content type, the location data will be not be stored. More information about this is in the Location module issue queue, and also in the INSTALL.txt file in the Location module.

Enable two modules at admin/modules: the Location and Location CCK modules.

Configure permissions for the Location module at admin/people/permissions#module-location. The first three permissions should only be assigned to the Administrator role, but the “Submit latitude/longitude” permission will need to be given to the Authenticated User role. Click the “Save permissions” button.

TIP

If you ever need people to enter a location before they have an account on your site, remember to give the “Submit latitude/longitude” permission to the Anonymous User role. This setting would be necessary if people need to submit their location when creating their user profile.

No changes are needed on the Location module configuration page at admin/config/content/location.

The more important configuration page is the Geocoding options tab at admin/config/content/location/geocoding. Geocoding is the process of turning some text (such as an address) into numerical spatial information (such as a latitude and longitude). It will be discussed in more detail below in Geocoding.

The first field on the form sets how accurate we require geocoding to be. For our example, we are mapping the location of Drupal businesses, so it is quite important to know where these businesses are. However, people are not going to be using our maps to drive or walk to the location. To require a higher level of accuracy than the default, change the setting to “Town.”

The second group of choices are which geocoding service to use for every country in the world. Not every country has a service that can geocode an address (e.g., North Korea doesn’t), but for almost every country that does, Google is the only choice. Unfortunately you have to manually select Google Maps for each country, so do this for every country that you care about. For the United States and Australia you also have the choice of using Yahoo!’s geocoding service; for Canada there is the option of GeoCode.ca.

NOTE

If you need to work with lots of countries, see the Note for a simpler way to set up geocoding for the Location module.

After you click the “Save configuration” button, you will see a “Configure parameters” link next to each country for which you have enabled geocoding. Click on one of these links to bring up the form to enter the Google Maps API Key. Thankfully this API Key only needs to be entered once; it does not need to be repeated for each country. Go to the Google Maps API Sign Up page to get the key.

Read the terms, particularly the usage limits, as these can have a significant implication for your website if you expect high traffic volumes or if you are using the maps on an intranet

Return Main Page Previous Page Next Page

®Online Book Reader