Ver Mensaje Individual
  #1  
Antiguo 26-09-2008
Avatar de richy08
richy08 richy08 is offline
Miembro
 
Registrado: may 2007
Ubicación: Bucerias, Nayarit Mexico
Posts: 529
Reputación: 20
richy08 Va por buen camino
ejecutar archivo .kml desde php

Buenas tardes compañeros les comento estoy creando un fichero .kml dinamicamente en php, el problema es que no lo puedo ejecutar al buscar y darle click sobre el archivo si se ejecuta correctamente peor la idea es que se abra automaticamnete con el php el codigo que utilizo es el siguiente gracias pro cualquier comentario.

Código PHP:
[left]<?php
require('conexion.php');
// Opens a connection to a MySQL server.
$connection mysql_connect (localhostrootroot);
if (!
$connection
{
die(
'Not connected : ' mysql_error());
}

// Sets the active MySQL database.
$db_selected mysql_select_db(earth$connection);
if (!
$db_selected
{
die (
'Can\'t use db : ' mysql_error());
}

// Selects all the rows in the markers table.
$query 'SELECT * FROM marcadores WHERE 1';
$result mysql_query($query);
if (!
$result
{
die(
'Invalid query: ' mysql_error());
}

// Creates an array of strings to hold the lines of the KML file.

$kml.= '<?xml version="1.0" encoding="UTF-8"?>'."\n";
$kml.='<kml xmlns="http://earth.google.com/kml/2.1">'."\n";
$kml.= ' <Document>'."\n";
$kml.= ' <Style id="restsaurantStyle">'."\n";
$kml.= ' <IconStyle id="restuarantIcon">'."\n";
$kml.= ' <Icon>'."\n";
$kml.= ' <href>http://maps.google.com/mapfiles/kml/pal2/icon63.png</href>'."\n";
$kml.= ' </Icon>'."\n";
$kml.= ' </IconStyle>'."\n";
$kml.= ' </Style>'."\n";
$kml.= ' <Style id="barStyle">'."\n";
$kml.= ' <IconStyle id="barIcon">'."\n";
$kml.= ' <Icon>'."\n";
$kml.= ' <href>http://maps.google.com/mapfiles/kml/pal2/icon27.png</href>'."\n";
$kml.= ' </Icon>'."\n";
$kml.= ' </IconStyle>'."\n";
$kml.= ' </Style>'."\n";

// Iterates through the rows, printing a node for each row.
//while (
$row = @mysql_fetch_array($result); 
//{
$kml.= ' <Placemark id="placemark' $row['id'] . '">'."\n";
$kml.= ' <name>' htmlentities($row['name']) . '</name>'."\n";
$kml.= ' <description>' htmlentities($row['address']) . '</description>'."\n";
$kml.= ' <styleUrl>#' . ($row['type']) .'Style</styleUrl>'."\n";
$kml.= ' <Point>'."\n";
$kml.= ' <coordinates>' $row['lng'] . ',' $row['lat'] . '</coordinates>'."\n";
$kml.= ' </Point>'."\n";
$kml.= ' </Placemark>'."\n"
//} 
// End XML file
$kml.= ' </Document>'."\n";
$kml.= '</kml>';
//$kmlOutput = join("\n", $kml);

$archivo =$row['name'].'.kml';
if (
file_exists ($archivo)) 
{
unlink($archivo); 
}
$fp fopen($archivo"w+");
$write fputs($fp$kml);
//fclose ($write);

header('Content-type: application/vnd.google-earth.kml+xml'); 
header('Content-Disposition: attachment; filename='.$archivo); 
?>[/left]