我正在尝试使用 php 生成 KML,但在第 1 行出现错误屏幕,这是我的文档:
<?php
header('Content-type: text/xml');
include('../../../../../../config.php');
// Print the head of the document
echo htmlentities('<?xml version="1.0" encoding="UTF-8"?>');
echo '</br>';
echo htmlentities('<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">');
echo '</br>';
echo htmlentities('<Document>');
echo '</br>';
// Finally query the database data
$result = mysql_query("SELECT * FROM acars_airports ORDER BY id DESC");
// Now iterate over all placemarks (rows)
while ($row = mysql_fetch_array($result)) {
// This writes out a placemark with some data
// -- Modify for your case --
echo htmlentities('<Placemark>');
echo '</br>';
echo htmlentities('<name>'.$row['icao'].'</name>');
echo '</br>';
echo htmlentities('<description>'.$row['name'].'</description>');
echo '</br>';
echo htmlentities('<Point>');
echo '</br>';
echo htmlentities('<coordinates>'.$row['lon'].' , '.$row['lat'].'</coordinates>');
echo '</br>';
echo htmlentities('</Point>');
echo '</br>';
echo htmlentities('</Placemark>');
echo '</br>';
};
// And finish the document
echo htmlentities('</Document>');
echo '</br>';
echo htmlentities('</kml>');
?>
忘记查询!如何生成要在谷歌地图上读取的 KML/KMZ/XML 文件?
已经尝试过:
header('Content-type: text/xml');
header('Content-type: application/vnd.google-earth.kmz');