<!DOCTYPE html>
<html>
<body>
<h1>Un poco de HTML encima</h1>
<div id="mapaLSG" style="width:100%;height:600px;"></div>
<script>
function initMap() {
const myLatLng = { lat: 39.86364, lng: -3.6153887 }; // mapa centrado de España
var mapProp = {
zoom:6.55,
minZoom: 6.55, // para q no se haga grande cuando se click
center: myLatLng
};
var map = new google.maps.Map(document.getElementById("mapaLSG"),mapProp);
icon = {
url: 'http://maps.google.com/mapfiles/kml/pushpin/blue-pushpin.png',
scaledSize: new google.maps.Size(35, 35)
};
// recorrer el array asociativo
arrAux1.forEach(function(e) {
var marker = new google.maps.Marker({
position: { lat: e["lat"], lng: e["lng"] },
map: map,
icon: icon
});
marker.addListener('click', function() {
new google.maps.InfoWindow({
content: e['content']
}).open(map, marker);
});
});
}
var arrAux1 = [];
arrAux1.push({ lat: 40.965, lng: -5.66305, content: '<span>lo que sea 1</span>' });
arrAux1.push({ lat: 39.4762, lng: -6.37076, content: '<span>lo que sea 2</span>' });
arrAux1.push({ lat: 40.4163, lng: -3.6934, content: '<span>lo que sea 3</span>' });
</script>
<h1>Aqui debajo mas HTML</h1>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaxxxx&callback=initMap&libraries=&v=weekly"></script>
</body>
</html>
Google Maps: Generar varios iconos dentro del maps
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario