Last updated 15 June 2012. Created on 2 November 2009.
Edited by ifrik, Anonymous (not verified), tom_o_t, BWPanda. Log in to edit this page.

OpenLayers styles definitions are a light wrapper around the functionality provided by styles in the OpenLayers javascript library. A simple style definition (one of the defaults included by the module) is

 * Implements hook_openlayers_styles().
function modulename_openlayers_styles() {
  $styles = array();
  $style = new stdClass();
  $style->api_version = 1;
  $style->name = 'default';
  $style->title = t('Default style');
  $style->description = t('Basic default style.');
  $style->data = array(
    'pointRadius' => 5,
    'fillColor' => '#FFCC66',
    'strokeColor' => '#FF9933',
    'strokeWidth' => 4,
    'fillOpacity' => 0.5
  $styles[$style->name] = $style;
  return $styles;

The contents of $style->data are passed directly to the OpenLayers javascript, and therefore have documentation on

Coded Styles

To provide custom styles in a module or feature, implement hook_openlayers_styles(), and return an array of styles, keyed by style name (like seen above).

Also, in order to tell CTools about your new hook, you will have to implement the following hook, like so:

 * Implements hook_ctools_plugin_api().
function modulename_ctools_plugin_api($module, $api) {
  if ($module == "openlayers") {
    switch ($api) {
      case 'openlayers_styles':
        return array('version' => 1);


Any bug reports and support requests should be reported in the OpenLayers issue queue.

Looking for support? Visit the forums, or join #drupal-support in IRC.


tmcw’s picture

Please post on the OpenLayers Issue queue with any bug reports and support requests. We cannot provide support on Book Pages.