You are here

class openlayers_views_style_map in Openlayers 6.2

Same name and namespace in other branches
  1. 6 modules/openlayers_views/views/openlayers_views_style_map.inc \openlayers_views_style_map
  2. 7.2 modules/openlayers_views/views/openlayers_views_style_map.inc \openlayers_views_style_map

@class Extension of the Views Plugin Syle for OpenLayers

This class extended the default views plugin class to provide a style plugin for the Open Layers module.

Hierarchy

Expanded class hierarchy of openlayers_views_style_map

1 string reference to 'openlayers_views_style_map'
openlayers_views_views_plugins in modules/openlayers_views/views/openlayers_views.views.inc
Implementation of hook_views_plugins().

File

modules/openlayers_views/views/openlayers_views_style_map.inc, line 17
This file holds style plugin for OpenLayers Views

View source
class openlayers_views_style_map extends views_plugin_style {

  /**
   * Set default options
   */
  function option_definition() {
    $options = parent::option_definition();
    $options['preset'] = array(
      'default' => variable_get('openlayers_default_preset', 'default'),
    );
    return $options;
  }

  /**
   * Options form
   */
  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);

    // Map Preset
    $form['preset'] = array(
      '#type' => 'select',
      '#title' => t('Map preset'),
      '#description' => t('This is map that will be used to render the view.'),
      '#options' => openlayers_preset_options(),
      '#default_value' => $this->options['preset'] ? $this->options['preset'] : variable_get('openlayers_default_preset', 'default'),
    );
  }

  /**
   * Query - override to make sure this doesn't get run
   */
  function query() {
    $this->view->built = TRUE;
  }

  /**
   * Renders views (map)
   */
  function render() {
    $output = '';

    // Check for live preview.
    if (!empty($this->view->live_preview)) {
      return t('OpenLayers views are not compatible with live preview.');
    }

    // Get selected preset
    $preset = openlayers_preset_load($this->options['preset']);
    $map = openlayers_render_map($preset->data, $preset->name);
    return theme($this
      ->theme_functions(), $this->view, $this->options, $map);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
openlayers_views_style_map::options_form function Options form
openlayers_views_style_map::option_definition function Set default options
openlayers_views_style_map::query function Query - override to make sure this doesn't get run
openlayers_views_style_map::render function Renders views (map)