Mapping With Drupal - Alan Palazzolo [16]
Enter User Group as the Name.
Enter A local Drupal user group as the Description.
Change the “Title field label” to Group name.
All other options can remain as default for now. Click the “Save and add fields” button.
You are now taken to the “Manage fields” page for this content type at admin/structure/types/manage/user-group/fields. The third field listed should be “Body.” Click the “edit” link to change this.
Change the “Label” field from Body to Group description. All other fields can stay with the default values. Click the “Save settings” button.
On the “Manage fields” page, go to the “Add new field” row. Enter Group location as the Label and group_location as the Field name. In the “Select a field type” drop-down, choose “Geofield.” In the Widget drop-down choose “OpenLayers map.” Your configuration should now look like Figure 3-1.
Figure 3-1. Configuring the user group content type
Click the Save button at the bottom of the page to create this field.
You are first taken to the field level settings; there is no further configuration for this widget, so click “Save field settings” on the next screen.
On the final screen, tick the “Required field” checkbox so that a location has to be set for this content type. Enter some useful Help text, too: Click on the map to set the location for this group. There is currently just one option in the “OpenLayers Map” drop-down (Geofield Widget Map). As we go through the exercises in later chapters, more maps will be added to this list.
It is possible to set a default location for nodes of this content type by clicking on the map in the “Default value” section, but this is not useful for this example. It is also possible to change the “Number of values” for the location field, but leave this set to 1 for this example. Click the “Save settings” button.
Create a sample “User Group.” From the “Add Content” page at node/add, add a “User Group.” Enter the name of the group (e.g., New York City). Enter a description for the group. Zoom in on the map and click to set the location of the group. This should look something like Figure 3-2.
Figure 3-2. Adding content
Save the node.
When viewing this node, you’ll see the location displaying something like “POINT (-73.9987036058 40.7345513658).” This is the location in Well Known Text (WKT) format, as described in Data Types. Unless you are a robot, this display isn’t useful when searching for your local Drupal user group. To see what other display options are available, go to the “Manage Display” page for the User Group content type at admin/structure/types/manage/user_group/display.
In the “Format” column for the “Group location” field change the display from “Well Known Text (WKT)” to “OpenLayers.”
Click on the cog symbol on the right side to open the configuration options for the field display. Again, at this point, the only available map is the one that comes with the Geofield module for this purpose, so select “Geofield Formatter Map.” For the data option select “Use full geometry.” It should look as shown in Figure 3-3. Click “Update” to save your settings, then click “Save.”
Figure 3-3. Configuring Geofield display settings
Go to the content management page at admin/content/node and view the “User Group” content that you have just created. The location should now be shown as a dot at the center of a map, as shown in Figure 3-4.
Figure 3-4. A location displayed on a map
Congratulations! You now have a content type configured to collect spatial data using a point-and-click map interface. The information that is collected for a node is then displayed on a map.
Location Module
As mentioned in Location, when using the Location module, spatial information can only be attached to nodes and users. In this example we will create a new content type that will be used as a business listing for Drupal development companies.
Basic configuration of location
The Location module is fairly simple to configure, but it is important to understand which of the included modules