You are here

public function location_handler_field_location_distance::render in Location 7.3

Same name and namespace in other branches
  1. 6.3 handlers/location_handler_field_location_distance.inc \location_handler_field_location_distance::render()
  2. 7.5 handlers/location_handler_field_location_distance.inc \location_handler_field_location_distance::render()
  3. 7.4 handlers/location_handler_field_location_distance.inc \location_handler_field_location_distance::render()

Render the field.

Parameters

array $values: The values retrieved from the database.

Overrides views_handler_field::render

File

handlers/location_handler_field_location_distance.inc, line 176
Coordinates field handler.

Class

location_handler_field_location_distance

Code

public function render($values) {
  if (empty($values->{$this->field_alias}) || $values->{$this->field_alias} == 'Unknown') {

    // Unset location, empty display.
    return;
  }
  $dist = (double) $values->{$this->field_alias};
  if ($this->options['units'] == 'km') {
    $dist = $dist / 1000.0;
    return theme('location_distance', array(
      'distance' => $dist,
      'units' => 'km',
    ));
  }
  else {
    $dist = $dist / 1609.347;
    return theme('location_distance', array(
      'distance' => $dist,
      'units' => 'mi',
    ));
  }
}