I'm trying to calculate the distance between these two points but I can not! I would like to find out what the problem is.
On the console, a 404 error occurs:
distancia.html:14 Uncaught ReferenceError: google is not defined at distancia.html:14 (anonymous) @ distancia.html:14
What is this line here:
var nyc = new google.maps.LatLng(40.715, -74.002);
Here's the whole code:
<!DOCTYPE html>
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<button onclick="myFunction()">Try it</button>
<script>
var nyc = new google.maps.LatLng(40.715, -74.002);
var london = new google.maps.LatLng(51.506, -0.119);
var distance = google.maps.geometry.spherical.computeDistanceBetween(nyc, london);
function myFunction() {
alert(distance);
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyD9A0ThwdhnBC2wLskwCmpWV5aFP1A05pU&libraries=geometry"
async defer></script>
</body>
</html>