function load() {
downloadUrl("phpsqlajax_genxml.php", function(data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
var i = 0;
var name = markers[i].getAttribute("name");
var address = markers[i].getAttribute("address");
var type = markers[i].getAttribute("type");
var html = "<b>" + name + "</b> <br/>" + address;
var geocoder = new google.maps.Geocoder();
geocoder.geocode( {'address': address}, function(results, status) {
var coords = results[0].geometry.location;
var latlng = new google.maps.LatLng( coords.lat(), coords.lng() );
var map = new google.maps.Map(document.getElementById("map"), {
center: latlng,
zoom: 16,
mapTypeId: 'roadmap'
});
var infoWindow = new google.maps.InfoWindow;
var marker = new google.maps.Marker({
map: map,
position: latlng,
});
bindInfoWindow(marker, map, infoWindow, html);
});
});
}
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() {}
<!DOCTYPE html >
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>TEST</title>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="map.js"></script>
<style>
html, body { height: 100%; }
#map { height: 450px; width: 100%; }
</style>
</head>
<body onload="load()">
<div id="map"></div>
</body>
</html>
Спасибо за время и внимание!