Skip to Main Content
Mapping with Drupal
book

Mapping with Drupal

by Alan Palazzolo, Thomas Turnbull
December 2011
Intermediate to advanced content levelIntermediate to advanced
150 pages
3h 50m
English
O'Reilly Media, Inc.
Content preview from Mapping with Drupal

Data-Driven Styling

It is possible to change markers or styles based on data in your website. For example, a user can set the color of a marker, choosing a color when adding a new “Drupal User Group” to your website. This data-driven styling is achieved with Marker Handling in the GMap module, and with Attribute Replacement in OpenLayers. Both of these techniques are powered by the Views module, which includes the data needed for styling when doing the database query that creates the data layer for the map.

GMap Marker Handling

The GMap module uses Views to display Drupal data, as described earlier in Mapping with the GMap Module. The GMap Location module allows you to choose which markers to use based on Taxonomy Terms, Content Types, and User Roles. It is also possible to create a Field in your Content Type that contains a list of marker names. To select a marker for a particular content type, edit the content type and select a marker from the list. To use this setting when creating a map, you need to specify that in the “Marker handling” section of the View, as shown in Figure 6-6.

Marker handling for GMap Views formatter

Figure 6-6. Marker handling for GMap Views formatter

OpenLayers Attribute Replacement

In the OpenLayers module, it is possible to replace any Style value with data, specifically Views data. To achieve this in the OpenLayers modules, we first have to tell Views that we want to use new some fields, then use ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

High Performance Drupal

High Performance Drupal

Jeff Sheltren, Narayan Newton, Nathaniel Catchpole
Using Drupal

Using Drupal

Heather Berry, Angela Byron, James Walker, Jeff Eaton, Nathan Haug, Jeff Robbins

Publisher Resources

ISBN: 9781449311308Errata PageSupplemental Content