You are here

function views_plugin_style_kml::map_rows in KML 7

Same name and namespace in other branches
  1. 6.2 views/views_plugin_style_kml.inc \views_plugin_style_kml::map_rows()

File

views/views_plugin_style_kml.inc, line 127
Extending the view_plugin_style class to provide a kml view style.

Class

views_plugin_style_kml
@file Extending the view_plugin_style class to provide a kml view style.

Code

function map_rows($rows) {

  // Fields must be rendered in order as of Views 2.3,
  // so we will pre-render everything.
  $renders = array();
  $keys = array_keys($this->view->field);
  $renders = $this
    ->render_fields($rows);
  $points = array();
  foreach ($renders as $id => $row) {
    $point = array();
    foreach ($this->view->field as $key => $field) {
      if ($key == $this->options['fields']['name']) {
        $point['name'] = $row[$key];
      }
      elseif ($key == $this->options['fields']['description']) {
        $point['description'] = $row[$key];
      }
      elseif ($key == $this->options['fields']['longitude']) {
        $point['lon'] = $row[$key];
      }
      elseif ($key == $this->options['fields']['latitude']) {
        $point['lat'] = $row[$key];
      }
    }
    $point['point'] = $point['lon'] . ',' . $point['lat'] . ',0';
    unset($point['lat']);
    unset($point['lon']);
    if (isset($this->options['linestring']) && $this->options['linestring']['enable']) {
      $points[$point['group']][] = $point;
    }
    else {
      $points[] = $point;
    }
  }
  return $points;
}