我似乎有同樣的問題。地圖工作正常,並返回幾何昨天,今天它只是空白,沒有經度/緯度和相同的錯誤。
他們似乎更新的API和一些破
編輯:
對我來說這是通過採取標記可以解決的座標,而不是試圖進行地址解析它的地址,然後取地址的座標。
我有這樣的代碼(合作15年10月12日):
function geocodePosition(pos)
{
geocoder = new google.maps.Geocoder();
geocoder.geocode
({
latLng: pos
},
function(results, status)
{
if (status == google.maps.GeocoderStatus.OK)
{
$("#address").val(results[0].formatted_address);
$("#id_location_0").val(results[0].geometry.location.J);
$("#id_location_1").val(results[0].geometry.location.M);
}
}
);
}
這一個停止工作,但能夠通過標記取座標來修復它。 Pos變量是marker.getPosition()在我的情況。
if (status == google.maps.GeocoderStatus.OK)
{
$("#address").val(results[0].formatted_address);
$("#id_location_0").val(marker.position.lat());
$("#id_location_1").val(marker.position.lng());
}
這似乎是報告 https://code.google.com/p/gmaps-api-issues/issues/detail?id=8734
你可以嘗試:
var service = new google.maps.places.Autocomplete(document.getElementById('search-btn'));
service.addListener('place_changed', function() {
var place = service.getPlace();
console.log(place.geometry.location.lat(), place.geometry.location.lng());
});
您的'search-btn'是一個按鈕? –
@MrNeo它是一個文本框:' –
我臨時發現了一個解決方案,變量我請求谷歌地理編碼API使用位置地址(lat,lng): '$ .getJSON(「https://maps.googleapis.com/maps/api/geocode/json?address=」+ place。 formatted_address +「&key = myKey」,函數(數據,雕像)var geomtry_arr = [data ['results'] [0] .geometry.location ['lat'],data ['results'] [0]。 ();});' –