首先,我使用google map api将地址转换为经度和纬度。我可以将其转换并显示出来。但是,我无法将经纬度设置为隐藏字段,以便我可以使用它来处理......我做了什么错了?谷歌地图api javascript获取经度和纬度?
我可以得到警报
但是......我不能让我设置隐藏字段的值,它表明...
下面是我的代码...
<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function sayHello() {
// get input address
var address = document.getElementById('inputAddress').value;
var latitude;
var longitude;
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
latitude = results[0].geometry.location.lat();
longitude = results[0].geometry.location.lng();
// find hidden field
document.getElementById("myLatitudes").value = latitude;
document.getElementById("myLongitudes").value = longitude;
alert("ShopLatitudes: " + latitude + ", ShopLongitudes: " + longitude);
}
else
{
alert("Geocoder failed due to: " + status);
}
});
}
</script>
什么问题?你在哪里打电话?怎么了? – SLaks 2014-09-28 15:13:37
即使设置了隐藏字段,我仍然无法获取经纬度... – 2014-09-28 15:23:49