Custom Markers
Basic custom marker
To add a marker select the 'Styles' tab under Home » Administration » Structure » OpenLayers. Here you can [+ Add] a new marker.
Once you have created a marker you can choose it for the style of your layer. Go to edit your map from the 'Maps' tab under Home » Administration » Structure » OpenLayers. In the 'Layers & Styles' selection you should now be able to select your new style.
Selecting markers dynamically
Note: Given this commit, OpenLayers has changed its way of using field styles. If you were using replacement tokens such as ${xyz_render}, you need update your settings with the following steps.
You can change the file that is accessed for the marker based on replacement tokens from your view.
Go to your view, and select the 'OpenLayers Data' display. At the top of the preview you will see some text like:
You can use the following parameters in your styles as dynamic values
${title}
${field_point}
${name}These tokens can be used in the externalGraphic url field of your style.
Example: Selecting by icon by Content Type
In your view:
- Go to your view 'Openlayers Data' display.
- Add the 'Content: Type' field
- You usually don't want the field to be stylized with HTML and CSS, as they will appear in the filenames of your icons. Set the formatter of the field to be 'Plain Text'. In the Style Settings, under 'Customize field HTML' and 'Customize field and label wrapper HTML' choose HTML elements to be 'None'.
You should now see additional tokens in the preview section:
${type}
In Openlayers styles section:
- Go to the 'OpenLayers' settings page select the 'Styles' tab and add a new 'Style'.
- Under 'externalGraphic' in the section 'Style Properties', enter the URL to where you are going to store your icons using the new token
${type} to be replaced with the content type name e.g. sites/all/themes/[YOUR-THEME_NAME]/css/images/icons/icon-${type}.png
Add your icons:
Add your icon images to this folder. E.g. for a content type with a human readable name of 'Location', your icon's file name will be icon-Location.png
Openlayers preview in the view does not give examples of the exact replacement. For some fields you might not be sure what is going to be replaced. One way to work out the exact filenames is to try using the style and check the logs for the filenames of the not found images.
In your map:
In the Layers & Styles section you can now select this style to be used for your layer. If you use this style with a view without the field, for the token, 'undefined' will be used instead (so in this example: icon-undefined.png).
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