1

我正在使用谷歌地图为 asp 文本框使用自动完成功能。当我单击按钮或选择下拉列表项 [回发] 时发生错误

未指定的错误。行:20 字符:207 代码:0 URI:maps.gstatic.com/cat_js/intl/en_us/mapfiles/api-3/13/8/...

在正常负载下它工作正常。

function CallInitialiseInPost() {                      
  initialize();
}

var prm = window.Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(CallInitialiseInPost);

function initialize() {
                var input = document.getElementById('<%=txtStreetAddress.ClientID%>');

                var autocomplete = new google.maps.places.Autocomplete(input);

                google.maps.event.addListener(autocomplete, 'place_changed', function() {
                    var place = autocomplete.getPlace();
                    var hiddenCity = document.getElementById('<%=cityHidden.ClientID%>');
                    var hiddenPostal = document.getElementById('<%=postalHidden.ClientID%>');
                    var hiddenstreetSelected = document.getElementById('<%=streetSelectedHidden.ClientID%>');
                    if (place.address_components) {
                        for (var i = 0; i < place.address_components.length; i++) {
                            var addr = place.address_components[i];
                            var getCity;
                            var getPostal;
                            var getStreet;
                            hiddenstreetSelected.value = "streetselected";
                            if (addr.types[0] == 'locality') {
                                getCity = addr.long_name;
                                hiddenCity.value = "cityfilled";
                                document.getElementById('<%=txtCity.ClientID%>').value = getCity;
                            }
                            if (addr.types[0] == 'postal_code') {
                                getPostal = addr.long_name;
                                hiddenPostal.value = "postalfilled";
                                if (getPostal.length < 6) {
                                    alert("The complete postal code could not be resolved by Google Maps, please ask the patient for their postal code, and manually enter this into the Postal Code field.");
                                }
                                else {
                                    document.getElementById('<%=txtPostal.ClientID%>').value = getPostal;
                                }
                            }
                            if (addr.types[0] != 'postal_code') {
                                document.getElementById('<%=txtPostal.ClientID%>').value = "";
                            }
                            if (hiddenCity.value == "" && addr.types[0] != 'locality') {
                                document.getElementById('<%=txtCity.ClientID%>').value = "";
                            }
                        }
                        if (hiddenPostal.value == "") {
                            alert("The complete postal code could not be resolved by Google Maps, please ask the patient for their postal code, and manually enter this into the Postal Code field.");
                        }
                        hiddenCity.value = "";
                        hiddenPostal.value = "";
                        input.style.color = "Black";
                        document.getElementById('<%=txtSuite.ClientID%>').select();
                        document.getElementById('<%=txtSuite.ClientID%>').focus();
                        setTimeout(SaveStreet, 10);
                        setTimeout(clickOnTabButton, 10);
                    }


                });
            }
            google.maps.event.addDomListener(window, 'load', initialize);  
4

0 回答 0