Community Documentation

API: Styles

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.

Comments

Please post on the OpenLayers

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

About this page

Drupal version
Drupal 6.x
Audience
Designers/themers, Programmers, Site administrators, Site users
Keywords
maps, theming

Site Building Guide

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here