Gmap API

Save this file as index.php
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps AJAX + mySQL/PHP Example</title>
http://maps.google.com/maps/api/js?sensor=false

//

var customIcons = {
restaurant: {
icon: 'http://labs.google.com/ridefinder/images/mm_20_blue.png',
shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
},
bar: {
icon: 'http://labs.google.com/ridefinder/images/mm_20_red.png',
shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
}
};

function load() {
var map = new google.maps.Map(document.getElementById("map"),
{
center: new google.maps.LatLng(22.6343422, 88.3385809),
zoom: 13,
mapTypeId: 'roadmap'
}
);

var infoWindow = new google.maps.InfoWindow;

// Change this depending on the name of your PHP file
downloadUrl("phpsqlajax_genxml_1.php", function(data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i " + name + "
" + address;
var icon = customIcons[type] || {};
var marker = new google.maps.Marker({
map: map,
position: point,
icon: icon.icon,
shadow: icon.shadow
});
bindInfoWindow(marker, map, infoWindow, html);
}
});
}

function bindInfoWindow(marker, map, infoWindow, html) {
google.maps.event.addListener(marker, 'click', function() {
infoWindow.setContent(html);
infoWindow.open(map, marker);
});
}

function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;

request.onreadystatechange = function() {
if (request.readyState == 4) {
request.onreadystatechange = doNothing;
callback(request, request.status);
}
};

request.open('GET', url, true);
request.send(null);
}

function doNothing() {}

//]]>

</head>

<body onLoad="load()">

</body>
</html>

Create a new file as phpsqlajax_genxml_1.php
<?php
//require("phpsqlajax_dbinfo.php");

// get long lat data from google..
//http://maps.googleapis.com/maps/api/geocode/xml?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false
// PWD Rd, Bally Howrah, WB 711205

function parseToXML($htmlStr)
{
$xmlStr=str_replace('<','&lt;',$htmlStr);
$xmlStr=str_replace('>','&gt;',$xmlStr);
$xmlStr=str_replace('"','&quot;',$xmlStr);
$xmlStr=str_replace("'",''',$xmlStr);
$xmlStr=str_replace("&",'&amp;',$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 markers 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("Belur Math") . '" ';
echo 'address="' . parseToXML("Belur Math, Belur, Howrah, West Bengal") . '" ';
echo 'lat="22.6343422" ';
echo 'lng="88.3385809" ';
echo 'type="restaurant" ';
echo '/>';

echo '<marker ';
echo 'name="' . parseToXML("Bally Ghat") . '" ';
echo 'address="' . parseToXML("PWD Rd, Bally Howrah, WB 711205") . '" ';
echo 'lat="22.6527382" ';
echo 'lng="88.3414109" ';
echo 'type="bar" ';
echo '/>';

//}

// End XML file
echo '</markers>';

?>

Now run the index.php