<?php
header("Content-type: text/xml");
require("markersLogin.php");
function parseToXML($htmlStr)
{
$xmlStr=str_replace('<','<',$htmlStr);
$xmlStr=str_replace('>','>',$xmlStr);
$xmlStr=str_replace('"','"',$xmlStr);
$xmlStr=str_replace("&",'&',$xmlStr);
$xmlStr=str_replace(" ' ",'’',$xmlStr); I tried adding this
line to replace any apostrophes but that didn't work. Kinda lost. I
HATE APOSTOPHE'S!
return $xmlStr;
}
// Get parameters from URL
$center_lat = $_GET["lat"];
$center_lng = $_GET["lng"];
$radius = $_GET["radius"];
// Opens a connection to a mySQL server
$connection=mysql_connect($remote,$username,$password);
if (!$connection) {
die('Not connected : ' . mysql_error());
}
mysql_select_db("geocourses") or die(mysql_error());
// Select all the rows in the markers table
$query = sprintf("SELECT address, name, lat, lng, ( 6377 *
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 , 30",
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) {
die('Invalid query: ' . mysql_error());
}
// Start XML file, echo parent node
echo "<markers>\n";
// 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 'distance="' . $row['distance'] . '" ';
echo "/>\n";
}
// End XML file
echo "</markers>\n";
--
You received this message because you are subscribed to the Google Groups
"Google Maps API V2" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-api?hl=en.