私はGoogleからの2つのチュートリアルに従っています:
http://code.google.com/apis/maps/articles/phpsqlgeocode.html http://code.google.com/apis/maps/articles/phpsqlajax_v3.html#createmap
最初のチュートリアルは正しく機能しています。いくつかのデータベースアドレスをジオコーディングし、lat/lngの結果を保存しています。
2番目のチュートリアルで、結果を呼び出してマップを作成するのに少し問題があります。まず、これらは何千もの住所をジオコーディングして地図を作成するために従うべき正しいチュートリアルですか?
ページの一番下までチュートリアルを実行しましたが、いくつかのエラーがあります。最初のエラーは次のとおりです。
警告:ヘッダー情報を変更できません-/home/medicom/public_html/mapping/wp-の(/home/medicom/public_html/mapping/wp-content/themes/default/header.php:8で開始された出力)によって既に送信されたヘッダー134行目のcontent/themes / default / header.php
134行目は次のとおりです。
header("Content-type: text/xml");
// Start XML file, echo parent node
echo '<markers>';
// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
echo '<marker ';
echo 'name="' . parseToXML($row['name']) . '" ';
echo 'address="' . parseToXML($row['address']) . '" ';
echo 'lat="' . $row['lat'] . '" ';
echo 'lng="' . $row['lng'] . '" ';
echo 'type="' . $row['type'] . '" ';
echo '/>';
}
// End XML file
echo '</markers>';
どうすればこれを修正できますか?私が取り組んでいるページはこちらhttp://www.mediwales.com/mapping
アップデート:
これは、問題のあるコードのようです。
<?php
require("phpsqlgeocode_dbinfo.php");
function parseToXML($htmlStr)
{
$xmlStr=str_replace('<','<',$htmlStr);
$xmlStr=str_replace('>','>',$xmlStr);
$xmlStr=str_replace('"','"',$xmlStr);
$xmlStr=str_replace("'",''',$xmlStr);
$xmlStr=str_replace("&",'&',$xmlStr);
return $xmlStr;
}
// 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());
}
// Select all the rows in the markers table
$query = "SELECT * FROM _health WHERE 1";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
header("Content-type: text/xml");
// Start XML file, echo parent node
echo '<markers>';
// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
echo '<marker ';
echo 'name="' . parseToXML($row['name']) . '" ';
echo 'address="' . parseToXML($row['address']) . '" ';
echo 'lat="' . $row['lat'] . '" ';
echo 'lng="' . $row['lng'] . '" ';
echo 'type="' . $row['type'] . '" ';
echo '/>';
}
// End XML file
echo '</markers>';
?>
上記に代わるものはありheader()
ますか?