<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h2>MAPA DE VETERINARIAS</h2>
<div id="map" style="width:1200px;height:600px;background:yellow" ></div>
<script>
function myMap() {
$(document).ready(function() {
console.log("ready!");
var linea;
$.ajax({
type: "GET",
url: "http://d5d9c389.ngrok.io/Hipet/Veterinaria/Rest",
success:function(datos){
if(datos.status === false){
return false;
}
console.log(datos.message);
var detalle = datos.data;
if(detalle.length < 1){
return false;
}
for(var i=0; i < detalle.length; i++){
linea = [
detalle[i].vet_nombre,
detalle[i].vet_latitud,
detalle[i].vet_longitud
];
}
},
error: function(){}
});
});
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: new google.maps.LatLng(-12.048305914326424,-77.04588533323528),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < linea.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(linea[i][1], linea[i][2]),
map: map
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(linea[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB74ERecx-2XV-a4gm5UWDhrXRzeHPRVF4&callback=myMap"></script>
<!--
To use this code on your website, get a free API key from Google.
Read more at: https://www.w3schools.com/graphics/google_maps_basic.asp
-->
</body>
</html>