Last updated June 15, 2012. Created by tmcw on November 2, 2009.
Edited by ifrik, simonep, 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

<?php
/**
* 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 OpenLayers.org.

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:

<?php
/**
* 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 Drupal.org forums, or join #drupal-support in IRC.

Comments

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