You are here

class openlayers_behavior_tooltip in Openlayers 6.2

Same name and namespace in other branches
  1. 7.2 plugins/behaviors/openlayers_behavior_tooltip.inc \openlayers_behavior_tooltip

Attribution Behavior

Hierarchy

Expanded class hierarchy of openlayers_behavior_tooltip

1 string reference to 'openlayers_behavior_tooltip'
_openlayers_openlayers_behaviors in includes/openlayers.behaviors.inc
Implementation of hook_openlayers_behaviors().

File

includes/behaviors/openlayers_behavior_tooltip.inc, line 11
Implementation of OpenLayers behavior for tooltips.

View source
class openlayers_behavior_tooltip extends openlayers_behavior {

  /**
   * Provide initial values for options.
   */
  function options_init() {
    return array(
      'attribution' => '',
      'layers' => array(),
    );
  }

  /**
   * Form defintion for per map customizations.
   */
  function options_form($defaults) {

    // Only prompt for vector layers
    $vector_layers = array();
    foreach ($this->map['layers'] as $id => $name) {
      $layer = openlayers_layer_load($id);
      if (isset($layer->data['vector']) && $layer->data['vector'] == TRUE) {
        $vector_layers[$id] = $name;
      }
    }
    return array(
      'layers' => array(
        '#title' => t('Layers'),
        '#type' => 'checkboxes',
        '#options' => $vector_layers,
        '#description' => t('Select layer to apply tooltips to.'),
        '#default_value' => isset($defaults['layers']) ? $defaults['layers'] : array(),
      ),
    );
  }

  /**
   * Render.
   */
  function render(&$map) {
    drupal_add_js(drupal_get_path('module', 'openlayers') . '/includes/behaviors/js/openlayers_behavior_tooltip.js');
    return $this->options;
  }

}

Members