Skip to content

Instantly share code, notes, and snippets.

@DukeBaird
Created August 26, 2014 14:47
Show Gist options
  • Save DukeBaird/9f93399459a1e78f3c3e to your computer and use it in GitHub Desktop.
Save DukeBaird/9f93399459a1e78f3c3e to your computer and use it in GitHub Desktop.
KML Maps
define('BASIC_AUTH', TRUE);
define('CMD_LINE_OK', TRUE);
require_once('KML.class.php'); //Should be online
$kml = new KML('File');
$document = new KML('Document');
$document->name = 'name';
$document->open = 1;
$folder = new KML('Folder');
$folder->name = 'folder_name';
$folder->visibility = "0";
$placemark = new KML('Placemark');
$placemark->name = htmlspecialchars("name");
$placemark->description = htmlspecialchars($desc);
$placemark->Snippet = '';
$center_point = new KML('Point');
$center_point->coordinates = "{$longitude},{$latitude},0";
$placemark->addObject($center_point);
$placemark->styleUrl = 'style.kml#style';
$folder->addObject($placemark);
$document->addObject($folder);
$kml->addObject($document);
echo $kml->output_kml();
<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
<Style id="style">
<LabelStyle>
<scale>0</scale>
</LabelStyle>
<IconStyle>
<scale>0.6</scale>
<Icon>
<href>url_to_image.png</href>
</Icon>
</IconStyle>
</Style>
</Document>
</kml>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment