【发布时间】:2015-04-11 18:57:33
【问题描述】:
如何在同一个文本框中显示包含邮政编码的地址?例如: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>
【问题讨论】:
标签: javascript asp.net google-maps