I'm bringing data from an external api with ajax, which gives me the longitude and latitude but when I apply it to google maps it does not read the data. This is the code of the ajax query
jQuery.ajax({
url: "https://quasar.e-htl.com.br/booking/detail",
type: 'POST',
headers: {"Authorization": "Bearer " + xmiCookie},
data: datos,
dataType: "json",
beforeSend: function () {
swal({
title: "Procesando..",
text: "Recibiendo los datos, espere por favor...",
icon: "success",
buttons: false,
closeOnClickOutside: false,
closeOnEsc: false
});
},
success: function ( json ) {
jQuery.map(json, function (val) {
var hlatitud = val.attributes.Hotel.HotelLatitude;
var hlongitud = val.attributes.Hotel.hotelLongitude;
});
},
error: function ( ) {
}
});
I have the google maps function at the end of the page in a script
function initMap() {
var uluru = {lat: hlatitud, lng: hlongitud};
var map = new google.maps.Map(document.getElementById('mapSingle'), {
zoom: 4,
center: uluru
});
var marker = new google.maps.Marker({
position: uluru,
map: map
});
}
and also the call to the function of google maps
<script async defer src="https://maps.googleapis.com/maps/api/js?key=API_KEY&callback=initMap"></script>