Google 地方地址查找不起作用

Google Places Address Lookup not working

我在使用 Google 地图 API 时遇到问题,特别是地点库。这都是使用WordPress。

我在这里建立了一个注册表单:http://dabble.market/cms/sign-up/

我完全复制了我在本地主机中构建的内容。我将底部字段标记为:"Address which will be shown on the our map. Start typing & choose from the list." 使用地点库连接到 Google 地图 API。然后 运行 Google 的地址查找/自动完成就可以了。一旦地址自动完成 运行,它就会使用下面编写的 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);        
    });
});

}

好的 - 我已经弄明白了。

I removed the function initialize() {  ...  }

并将其替换为:

jQuery(document).ready(function($){  ...  });