I'm using google maps API to get elevation value by LAT and LON but I'm getting always undefined objects.
My script is this:
<script type="application/javascript">
function findAltitude() {
var lat = document.getElementById('lat').value;
var lon = document.getElementById('lon').value;
var url = "https://maps.googleapis.com/maps/api/elevation/json?locations=11,11&key=<API_KEY>";
var json, data;
$.ajax({
dataType: "json",
url: url,
data: data,
success: function(data) {
alert(data.results.elevation);
}
});
}
</script>
and my JSON is this:
{"results" : [
{
"elevation" : 402.0888977050781,
"location" : {
"lat" : 11,
"lng" : 11
},
"resolution" : 152.7032318115234
}],"status" : "OK"}