Hello All,
I'm trying to generate .kml file from my server. I'm using PHP with
mysql database and CI framework. this .KML file will be accessed and
used by blackberry appilcation.
I've succeed to generate .kml file to show location. But when I try to
make direction to find route from my current location or from some
place.
blackberry will send longitude and latitude of origin and destination
to server, and server will generate the route and make .KML file.
this is the way I generate .KML file to show a location :
// Creates the KML/XML Document.
$dom = new DOMDocument('1.0', 'UTF-8');
// Creates the root KML element and appends it to the root document.
$node = $dom->createElementNS('
http://earth.google.com/kml/2.1',
'kml');
$parNode = $dom->appendChild($node);
// Creates a KML Document element and append it to the KML element.
$dnode = $dom->createElement('Document');
$docNode = $parNode->appendChild($dnode);
$datapage=$this->Api_model->getcoordinate($data);
if($datapage->num_rows()>0)
{
foreach($datapage->result_array() as $row)
{
// Creates a Placemark and append it to the Document.
$node = $dom->createElement('Placemark');
$placeNode = $docNode->appendChild($node);
// Creates an id attribute and assign it the value of id column.
$placeNode->setAttribute('id', 'placemark' . $row['id']);
// Create name, and description elements and assigns them the
values of the name and address columns from the results.
$nameNode = $dom-
>createElement('name',htmlentities($row['nama']));
$placeNode->appendChild($nameNode);
// Creates a Point element.
$pointNode = $dom->createElement('Point');
$placeNode->appendChild($pointNode);
// Creates a coordinates element and gives it the value of the lng
and lat columns from the results.
$coorStr = $row['long'] . ',' . $row['lat'];
$coorNode = $dom->createElement('coordinates', $coorStr);
$pointNode->appendChild($coorNode);
}
}
$kmlOutput = $dom->saveXML();
header('Content-type: application/vnd.google-earth.kml+xml');
echo $kmlOutput;
The code above works well, so how can I create .KML file that show
routes from origin to destination? Really do need Your help...
Thanks
*I'm sorry for my bad english