Google Map Won't Display Points - Xml Is Null
I'm developing a website that will read the lat and lng from the MySQL database that I've created to show them on Google Maps. I'm using this Google example as a reference. The tab
Solution 1:
var infoWindow = new google.maps.InfoWindow;
should be
var infoWindow = new google.maps.InfoWindow();
Also here you pass through 'users' (the array of objects in the 'users' node), but surely you want to pass through just 'user', i.e. the marker you've just created?
bindInfoWindow(users, map, infoWindow, html);
Solution 2:
So I figured it out. After Duncan's answer the reason which placemarks did not work was that I had not placed
header("Content-type: text/xml");
in genxml.php. What a noob, huh? I'm placing Duncan's answer as correct because without it I wouldn't have figured out the problem. Below is the updated genxml.php. Thanks!
<?phpinclude("database.php");
functionparseToXML($htmlStr)
{
$xmlStr=str_replace('<','<',$htmlStr);
$xmlStr=str_replace('>','>',$xmlStr);
$xmlStr=str_replace('"','"',$xmlStr);
$xmlStr=str_replace("'",''',$xmlStr);
$xmlStr=str_replace("&",'&',$xmlStr);
return$xmlStr;
}
// Select all the rows in the users table$query = "SELECT * FROM users";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
header("Content-type: text/xml");
// Start XML file, echo parent nodeecho'<users>';
// Iterate through the rows, printing XML nodes for eachwhile ($row = mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODEecho'<user ';
echo'name="' . parseToXML($row['name']) . '" ';
echo'address="' . parseToXML($row['address']) . '" ';
echo'lat="' . $row['lat'] . '" ';
echo'lng="' . $row['lng'] . '" ';
echo'/>';
}
// End XML fileecho'</users>';
?>
Post a Comment for "Google Map Won't Display Points - Xml Is Null"