<html lang="es">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<link href="css/styles.css" rel="stylesheet">
<script type="text/javascript">
function load() {
var map = new google.maps.Map(document.getElementById("map"), {
<!-- centro de la localidad -->
center: new google.maps.LatLng(variablelat,variablelon),
zoom: variablezoom,
mapTypeId: 'roadmap'
});
var infoWindow = new google.maps.InfoWindow;
downloadUrl("markers.php", function(data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (var i = 0; i < markers.length; i++) {
var point = new google.maps.LatLng(
parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
<!-- Dependiendo de la categoria / subcategoria carga un icono -->
var icon = '/iconosmapa/marker.png';
<!-- Fin iconos -->
var marker = new google.maps.Marker({
map: map,
position: point,
title: markers[i].getAttribute("nombre"),
icon: icon
});
<!-- AL hacer clic en el markador -->
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(markers[i].getAttribute("nombre"));
infowindow.open(map, marker);
}
})(marker, i));
}
});
}
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() {}
</script>
</head>
<body onload="load()">
<div id="map"></div>
</body>
</html>