I'm working with Google API trying to plot multiple points on a map. I can't find really good documentation on how I need to do this so I'm sort of winging it at this point. Obviously what I have is not working. The map is displaying and centered where I want it, it's just not plotting the points. Have a look and see if it makes sense what I'm trying to do.
JS for map display and XML:
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(<?=$lat?>, <?=$long?>), 13);
map.setUIToDefault();
GDownloadUrl("maps_get_coords.php", function(data, responseCode) {
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
map.addOverlay(new GMarker(point));
}
});
}
}
maps_get_coords.php
<?php
header ("Content-Type:text/xml");
$xml_output = "<?xml version=\"1.0\"?>\n";
$xml_output .= "<markers>\n";
$getcoords=mysql_query("select lat, long from users where age <> '' and approved = '1' and id <> '1' and lat <> '' and long <> '' ");
while($r=mysql_query($getcoords)){
$xml_output .= '<marker lat="'.$r['lat'].'" lng="'.$r['long'].'"/>'; }
$xml_output .='</markers>';
echo $xml_output ;
?>
Am I screwing up my php or will it never work this way no matter how I code it? Is there an easier way to go about this ??