我想使用HTML 5地理位置获取经度和纬度,然后使用Google Maps API获取经度/纬度的国家代码。谁能告诉我在哪里,我在我的代码去错了,我现在得到了JavaScript错误“this.lat不是一个函数”在main.js:从谷歌地图和HTML 5获取国家代码地理位置
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
<script src="http://maps.google.com/maps?file=api&v=2&key=drnhdhddfhgfghfg" type="text/javascript"></script>
<script type="text/javascript">
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude;
var latlng = new google.maps.LatLng(lat, lng);
$.post('http://maps.googleapis.com/maps/api/geocode/json', { latlng: latlng, sensor: false }, function (results) {
alert(results);
});
});
}
else {
alert("Geolocation services are not supported by your browser.");
}
</script>
</head>
<body>
</body>
</html>
可能[Google Maps Jquery:如何从Google Places API获取国家/地区代码]的副本(http://stackoverflow.com/questions/33887081/google-maps-jquery-how-to-get-the-country-code-from -google-places-api) – geocodezip