Hi,

           I wrote the PHP script for planning route on google map and
plotting those details when user need. Here, the kml file syntax is
wrong and when i am clicking any route...it showing only the first
route plan only, what i mean even if i am clicking on the last route
plan...but the output is showing the first route plan output. I
understood there is problem with PHP file but i am not able to solve
this...cam any one please help me.

link:
http://googlemaps.uuuq.com/route/addroute2.html

this is my php code for generating kml:
<?php
require('routedb.php');

// Opens a connection to a MySQL server
$connection = mysql_connect ("localhost", $username, $password);

if (!$connection)
{
   die('Not connected : ' . mysql_error());
}

// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);

if (!$db_selected)
{
  die ('Can\'t use db : ' . mysql_error());
}



$query="SELECT * FROM route where route_name=" .$_GET['route_name'];

$result = mysql_query($query);
if (!$result)
{
  die('Invalid query: ' . mysql_error());
}

// Start KML file, create parent node
$dom = new DOMDocument('1.0','UTF-8');

//Create the root KML element and append it to the 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);

//Create a name element and append it to the KML element
$fnode = $dom->createElement('name','routeplan');
//$folderNode = $parNode->appendChild($fnode);
$docNode->appendChild($fnode);
$fnode1= $dom->createElement('description', 'route plan between two
selected places');
$docNode->appendChild($fnode1);

//Iterate through the MySQL results
while($row = @mysql_fetch_assoc($result))
{
//Create Styleid
$StyleNode=$dom->createElement('Style');
$StyleNode->setAttribute('id', 'Style' . $row['route_id']);
$StyleNode1=$docNode->appendChild($StyleNode);


// line style node
$LineStyleNode1=$dom->createElement('LineStyle');
$LineStyleNode=$StyleNode1->appendChild($LineStyleNode1);
//line colour
$LineColor=$dom->createElement('color','990000ff');
$LineStyleNode->appendChild($LineColor);
//line width
$LineWidth=$dom->createElement('width','4');
$LineStyleNode->appendChild($LineWidth);
$StyleNode1->appendChild($LineStyleNode);

//Create a Placemark and append it to the document
$node = $dom->createElement('Placemark');
$placeNode = $docNode->appendChild($node);

//Create name, description, and address elements and assign them the
values of
//the name, type, and address columns from the results

$nameNode = $dom->createElement('name',$row['route_name']);
$placeNode->appendChild($nameNode);
//$descNode= $dom->createElement('description', ' start_point to
end_point: ' . $row['start_point'] . "  to  " . $row['end_point']);
$descNode= $dom->createElement('description',  $row['start_point'] .
"  to  " . $row['end_point']);

$placeNode->appendChild($descNode);

$styleURL=$dom->createElement('StyleURL','#Style' . $row['route_id']);
$placeNode->appendChild($styleURL);

//Create a LineString element
$lineNode = $dom->createElement('LineString');
$placeNode->appendChild($lineNode);

$almodenode=$dom->createElement('altitudeMode','relativeToGround');
$lineNode->appendChild($almodenode);

 // Creates a coordinates element and gives it the value of the lng
and latt columns from the results.
     $coorStr = explode(";",$row['geo_points']);

 // for($i=0;$i<count($coorStr);$i++)
   //   {
    $coorNode = $dom->createElement('coordinates',implode(",0\n ",
$coorStr));

      $lineNode->appendChild($coorNode) ;
   //  }
  }


//$coorNode = $dom->createElement('coordinates',$row['coordinates']);
//$lineNode->appendChild($coorNode);
$kmlOutput = $dom->saveXML();

//assign the KML headers.
header('Content-type: application/vnd.google-earth.kml+xml');
echo $kmlOutput;
?>

Thanks in advance,
with sincerely,
sravan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to