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.
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 ...
Get Mapping with Drupal now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.