You are here

function kml_networklink in KML 5

Same name and namespace in other branches
  1. 6 kml.module \kml_networklink()

A function for creating a KML Network Link for a specific KML feed.

1 call to kml_networklink()
kml_interface in ./kml.module
Default callback

File

./kml.module, line 1024
KML Module

Code

function kml_networklink($attributes = array()) {
  $title = $attributes['title'] ? $attributes['title'] : variable_get('site_name', 'drupal');

  // set link to KML feed to send out through Network Link
  $kml_feed = $attributes['kml_feed'] ? $attributes['kml_feed'] : url('kml/node', NULL, NULL, TRUE);

  // TODO: allow these to be customised in a settings page
  $url['name'] = $title;
  $url['href'] = $kml_feed;
  $url['viewRefreshMode'] = variable_get('kml_refreshmode', 'onStop');
  $url['viewRefreshTime'] = variable_get('kml_refreshtime', 2);
  $output = kml_format_networklink($title, $kml_feed, $url);
  $extension = variable_get('kml_usekmz', 0) == 1 ? '.kmz' : '.kml';
  $filename = variable_get('kml_networklinkfilename', 'networklink') . $extension;
  drupal_set_header('Content-Type: application/vnd.google-earth.kml+xml');
  drupal_set_header('Content-Disposition: attachment; filename="' . $filename . '"');
  print $output;
}