You are here

function openlayers_behaviors_process_tooltip in Openlayers 6

Callback for OpenLayers Behaviors (Tooltip)

Parameters

$behavior: Data about behavior

$map: Map array

Return value

Behavior array or FALSE if not valid

1 string reference to 'openlayers_behaviors_process_tooltip'
openlayers_behaviors_openlayers_behaviors_info in modules/openlayers_behaviors/openlayers_behaviors.module
Implementation of hook_openlayers_behaviors_info().

File

modules/openlayers_behaviors/includes/openlayers_behaviors.behaviors.inc, line 93
This file holds the main Drupal hook functions and private functions for the openlayers_behaviors module.

Code

function openlayers_behaviors_process_tooltip($behavior, &$map) {

  // Check to make sure the layer attribute is properly set.
  if ($behavior['layer'] && $map['layers'][$behavior['layer']]) {
    drupal_add_css(drupal_get_path('module', 'openlayers_behaviors') . '/openlayers_behaviors.css', 'module');

    // Designate some default values that match up with our default theme
    $behavior['attribute'] = !empty($behavior['attribute']) ? $behavior['attribute'] : 'name';
    $behavior['tooltip_id'] = !empty($behavior['tooltip_id']) ? $behavior['tooltip_id'] : $map['id'] . '-tooltip';
    $behavior['container_id'] = !empty($behavior['container_id']) ? $behavior['container_id'] : $map['id'] . '-tooltip-container';
    $behavior['attribute_id'] = !empty($behavior['attribute_id']) ? $behavior['attribute_id'] : $map['id'] . '-tooltip-text';
    $behavior['offset_top'] = !empty($behavior['offset_top']) ? $behavior['offset_top'] : 'height';
    $behavior['offset_left'] = !empty($behavior['offset_left']) ? $behavior['offset_left'] : 0;

    // Create container
    $behavior['container'] = theme('openlayers_behaviors_tooltip_container', $behavior, $map);
    return $behavior;
  }
  return FALSE;
}