У меня есть требование. Когда пользователь нажимает кнопку (после указания адреса улицы), широта и долгота должны отображаться в окне предупреждения. Я пытаюсь использовать этот код, но он не работает.
<html>
<head>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
$("#btn").click(function()
{
var geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'address': 'miami, us'}, function(results, status)
{
if (status == google.maps.GeocoderStatus.OK)
{
alert("location : " + results[0].geometry.location.lat() + " " +results[0].geometry.location.lng());
}
else
{
alert("Something got wrong " + status);
}
});
});
</script>
</head>
<body>
<input id="btn" type="button" value="search for miami coordinates" />
</body>
</html>