0
我遇到Googlemaps API的問題,特別是地方圖書館。這全是使用WordPress。谷歌地方的地址查找無法正常工作
我已經建立了一個註冊表格在這裏:http://dabble.market/cms/sign-up/
我複製正是我建我的本地主機。我有底部的字段標記爲:「地址將顯示在我們的地圖上,從列表中開始輸入&」。使用地方庫連接到Googlemaps API。然後它運行谷歌的地址查找/自動完成就可以了。一旦地址自動完成運行,它將使用下面寫的JS將完整的地址和經緯度座標送回給用戶。
現在我已經將它遷移到該網站的實時版本,地址查找功能不再有效。
任何幫助將非常感謝謝謝。
var address, latitude, longitude, addressString;
function initialize() {
google.maps.event.addDomListener(window, 'load', function() {
var options = {
componentRestrictions: {country: "nz"}
};
var input = document.getElementById('txtPlaces');
var places = new google.maps.places.Autocomplete(input, options);
google.maps.event.addListener(places, 'place_changed', function() {
var place = places.getPlace();
if (!place.geometry) {
jQuery('#error').css("display", "inherit");
return;
}
else{
jQuery('#error').css("display", "none");
}
address = place.formatted_address;
latitude = place.geometry.location.lat();
longitude = place.geometry.location.lng();
addressString = "Address: " + address + "\n" + "Latitude: " + latitude + "\n" + "Longitude: " + longitude;
jQuery('#geocoords-hidden').val(addressString);
jQuery('#addressContainer').css("display", "inherit");
jQuery('#addressInfo').text("Address: " + address);
jQuery('#addressInfo1').text("Latitude: " + latitude);
jQuery('#addressInfo2').text("Longitude: " + longitude);
});
});
}