Skip to content

Instantly share code, notes, and snippets.

@giorrrgio
Last active December 15, 2015 19:09
Show Gist options
  • Save giorrrgio/5308824 to your computer and use it in GitHub Desktop.
Save giorrrgio/5308824 to your computer and use it in GitHub Desktop.
JSON TO KML
<?php
include('php-kml/lib/kml.php');
$jsonFile = file_get_contents("data.json");
$json_a = json_decode($jsonFile, true);
$a = new kml_Document();
$a->set_id('uid000000111');
foreach ($json_a as $poi) {
$myPlacemark = new kml_Placemark($poi['title']);
$myPlacemark->set_description($poi['html']);
$myPlacemark->set_Geometry(new kml_Point($poi['longitude'], $poi['latitude']));
$a->add_Feature($myPlacemark);
}
$a->dump(false);
[
{
"latitude": "48.86491238118212",
"longitude": "2.3293590545654297",
"title": "My title",
"html": "Description"
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment