Sys.WebForms.PageRequestManager.getInstance()导致Google Maps API出错

时间:2013-07-24 04:42:19

标签: javascript asp.net

我遇到了Sys.WebForms.PageRequestManager.getInstance()的问题。它导致我的页面出现脚本错误。我在我的页面中使用了Ajax。我正面临Google地图中的回发问题。

      function CallInitialiseInPost() {
        initialize();
       }

   var prm = window.Sys.WebForms.PageRequestManager.getInstance();
   prm.add_endRequest(CallInitialiseInPost);
    function initialize() {
        var input = document.getElementById('streetTxt');

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

        google.maps.event.addListener(autocomplete, 'place_changed', function() {
            var place = autocomplete.getPlace();                
            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;
                    if (addr.types[0] == 'locality') {
                        getCity = addr.long_name;
                        document.getElementById('cityTxt').value = getCity;
                    }
                    if (addr.types[0] == 'postal_code') {
                        getPostal = addr.long_name;
                        document.getElementById('postalTxt').value = getPostal;
                    }
                }

            }

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

0 个答案:

没有答案