Response->Status->code;
if (strcmp($status, "200") == 0) {
$coordinates = $xml->Response->Placemark->Point->coordinates;
$coordinatesSplit = split(",", $coordinates);
$center_lat = $coordinatesSplit[1];
$center_lng = $coordinatesSplit[0];
// Search the rows in the markers table
$query = sprintf("SELECT address, name, lat, lng, ( 3959 * acos( cos( radians('%s') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians('%s') ) + sin( radians('%s') ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < '%s' ORDER BY distance LIMIT 0 , 20",
mysql_real_escape_string($center_lat),
mysql_real_escape_string($center_lng),
mysql_real_escape_string($center_lat),
mysql_real_escape_string($radius));
$result = mysql_query($query);
if (!$result) {
echo("Invalid query: " . mysql_error());
}
$urlString = array('http://maps.google.com/staticmap?markers=');
$markerString = array();
$htmlString = array();
// Iterate through the rows, adding XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
array_push($markerString, ($row['lat'] . ',' . $row['lng'] . ',red'));
array_push($htmlString, ($row['name'] . '
' . $row['address']));
}
array_push($urlString, (join('|', $markerString)));
array_push($urlString, '&size=400x300');
array_push($urlString, '&key=' . KEY);
echo '
';
echo '
';
echo join('
', $htmlString);
}
}
?>