You are here

function openlayers_views_style_data_image::render in Openlayers 7.2

Render the map.

Overrides views_plugin_style->render

Overrides views_plugin_style::render

File

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

Class

openlayers_views_style_data_image
@class Extension of the Views Plugin Style for OpenLayers

Code

function render() {
  $view = $this->view;

  // Render fields to trigger rewriting and other field processing.
  $this->view->style_plugin
    ->render_fields($this->view->result);
  $image_field = isset($this->options['config']['image_field']) ? $this->options['config']['image_field'] : NULL;
  $factor_x = !empty($this->options['config']['factors']['x']) ? $this->options['config']['factors']['x'] : 1;
  $factor_y = !empty($this->options['config']['factors']['y']) ? $this->options['config']['factors']['y'] : 1;
  $numzoomlevels = !empty($this->options['config']['numZoomLevels']) ? $this->options['config']['numZoomLevels'] : 1;
  $maxextent = !empty($this->options['config']['maxExtent']) ? $this->options['config']['maxExtent'] : NULL;
  foreach ($this->view->result as $count => $row) {
    if (isset($view->style_plugin->rendered_fields[$count][$image_field])) {
      $image = $view->style_plugin->rendered_fields[$count][$image_field];
      $value = $view->style_plugin
        ->get_field_value($count, $image_field);
      $field_output = array_shift($value);
      $data[] = array(
        'file' => $image,
        'size' => array(
          'w' => floatval($field_output['width']),
          'h' => floatval($field_output['height']),
        ),
        'factors' => array(
          'x' => floatval($factor_x),
          'y' => floatval($factor_y),
        ),
        'numZoomLevels' => floatval($numzoomlevels),
        'maxExtent' => $maxextent,
      );
    }
  }
  if (!empty($data)) {

    // Skip rendering if view is being edited or previewed.
    if (empty($this->view->live_preview)) {
      return $data[0];
    }
    else {
      return print_r($data[0], 1);
    }
  }
  else {
    return '';
  }
}