Google Maps JavaScript API - 显示邮政编码而非美国

时间:2015-04-11 18:57:33

标签: javascript asp.net google-maps

如何在同一文本框中显示包含zipcode的地址?例如:123 main st,Atlanta,GA 30305。 这就是我所拥有的:                     // how to get google places autocomplete to work if the textbox is initially hidden and should be shown only after a postback

     var prm = Sys.WebForms.PageRequestManager.getInstance();
     prm.add_initializeRequest(InitializeRequest);
     prm.add_endRequest(EndRequest);
     function InitializeRequest(sender, args) {
     }
     // fires after the partial update of UpdatePanel
     function EndRequest(sender, args) {
         initialize();
     }
    function initialize() {
        var defaultBounds = new google.maps.LatLngBounds(
            new google.maps.LatLng(33.847037, -84.393539));
        var origin_input = document.getElementById('saddr');
        var options = {
            bounds: defaultBounds,
            types: ['address'],//Addresses only
            componentRestrictions: { country: 'us' }};
        var autocomplete_origin = new google.maps.places.Autocomplete(origin_input, options);
    }
    google.maps.event.addDomListener(window, 'load', initialize);
    function updateAddressField()
    {
        var addrs = document.getElementById('saddr').value;
        document.getElementById('hdnAddress').value = addrs;
    }
</script>

1 个答案:

答案 0 :(得分:0)

嗯,我不知道你在谈论什么样的文本框,但是如果你想通过自动完成获得邮政编码,请回答:

Link