Howto: Create some basic location aware nodes.
You are browsing documentation for an older version of Drupal, which is not supported any longer, and the information may not be correct. See current documentation for Contributed modules
Requirements:
- CCK module so that custom fields can be created. ( http://drupal.org/project/cck )
- Install the location module ( http://drupal.org/project/location ).
- Install the gmap module ( http://drupal.org/project/gmap ).
- Obtain a Google Maps API key ( https://code.google.com/apis/console/ ).
This last step is required so that your drupal installation can query google maps. You will need one google api key per each website that will talk to google maps. This also includes your local development environment, the URL would be something like http://localhost/ if you are developing on your local PC. Keep a note of the API key that is provided as it will not be sent by email to your google account.
Once the above has been completed we can go ahead and enable the needed components from the Drupal administration menu.
Administer -> Site Building -> Modules
Enable the following modules:
Location CCK
Content
GMAP
GMAP Location
Location
Choose Save.
Next go to Administer -> Site configuration -> Gmap
In the "Google Maps API Key" field. Enter the Google MAP API key that was created previously.
Choose save.
Next go to Administer -> Site configuration -> Location
In the main settings enable the following:
In "Toggle location display", choose "Enable the display of locations."
Also check the box "Use a Google Map to set latitude and longitude "
Choose Save.
Then head over to the "Geocoding options" tab.
Enable Google maps for the Countries that you want to allow geocoding.
We can now create our location aware Content Type.
Go to Administer -> Content management -> Content types.
You can either create a new content type or use that you have created previously.
Once you have your content type created. Choose "Manage fields".
Enter a label and name for your new field. For the type choose "Location". Then choose save.
In the next screen choose the fields that you want to allow/require for the address information. For this example I chose the following:
Location name (Allow).
Street location (Require).
Additional (Allow).
City (Require).
State/Province (Require).
Country (Require).
Coordinate Chooser (Allow).
Phone number (Allow).
Fax number (Allow).
Chose "Save field settings".
We can now create location aware nodes using the content type that we just created.
Go to "Create content" and choose the a content type from the previous step.
In the content creation screen enter any necessary information and for your address fields enter a valid address from a country that google maps supports. In used the Red Hat headquarters in Raleigh as an example:
1801 Varsity Drive
Raleigh,
North Carolina
27606
USA
After hitting the save button. You should see your newly created node with the coordinates automatically calculated by google maps Happy days! :-)
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion