Online Book Reader

Home Category

Mapping With Drupal - Alan Palazzolo [31]

By Root 312 0
that contain the latitude and longitude. This makes it possible to use the GMap module in conjunction with the Geofield module, or with a content type that has latitude and longitude fields added in some other way.

The “Marker handling” field gives some options to choose which markers will be used on the map. For this example it could be left with the default “Use single marker type.” The other options provide ways to have different markers representing different information on the map:

By content type

To use markers by content type, configure the markers at admin/config/services/gmap_location. When configuring a location field for a content type at admin/structure/types/manage/drupal-company/fields/field_company_location, a particular style of marker can be chosen. This marker will then be used when a node of that content type is displayed on a map.

Use marker field

This advanced configuration requires a field on a content type that matches the markername of a marker. The markernames can be found in the .ini files contained in the markers folder inside the GMap module.

With “Use single marker type” selected, the “Marker / fallback marker to use” field defaults to “Drupal.” Change this to whatever marker you like, such as “Small Light Gray.”

There are some more advanced choices on this form, but the last two checkboxes provide some useful Behaviors that can occur when people interact with the map. Tick the “Display a tooltip when hovering over markers” checkbox and select “Content: Title” to have the company name show when the user moves their mouse over a marker. Tick the “Display a popup bubble with additional information when a marker is clicked” checkbox and select “Content: Title” to have the company name show when a user clicks on a marker.

Click the “Apply (all displays)” button to save the configuration.

The view that creates the map is now complete. Click the “Save” button on the top right. The map should look something like Figure 4-12.

Figure 4-12. The final map of Drupal companies

Having the same information show up both on hover and in the pop up bubble is not very useful. We can improve this by adding a second field to the view so as to display the body of the node (the description of the Drupal company).

Edit the map view again. In the “Fields” section, click the “add” button. Select “Content: Body” from the list of available fields and click “Add and configure fields.” Click the “Apply (all displays)” button to save the configuration.

Go back to the GMap settings for the view, as described in Step 10. Change the “Bubble pop-up field” drop-down to “Content: Body.” Click the “Apply (all displays)” button to save the configuration. Click the “Save” button on the top right to save these changes to the map. Clicking on a marker on the map should now display a more useful pop up bubble, as shown in Figure 4-13.

Figure 4-13. Pop up bubble with GMap

We have now used GMap and Views to create a map that displays all content of a particular type (Drupal businesses) with customized markers and useful information when hovering or clicking on a marker.

Other Ways of Displaying Spatial Data


Sometimes a map is not the most useful way to display spatial data. You may want to present information as a list, either on its own or alongside the same data on a map. Or it may be necessary to create an external feed so that your data can be pulled out into another service, such as Google Earth or a different website. Because maps made in Drupal are generally built using the Views module, it is a fairly simple process to output data in other formats.

Spatial Data in Tables and Lists


Foursquare on a mobile device is an example where it is more useful to have a list of nearby venues such as cafes, parks, or airports. Continuing with our example of upcoming Drupal events, it may be useful to see a list of events sorted by date, rather than a map of all of them. With the Views module, both of these are just List Views of the Map Views that we created earlier.

On the Views

Return Main Page Previous Page Next Page

®Online Book Reader