【问题标题】:google-places bug in firefox browser谷歌在Firefox浏览器中放置错误
【发布时间】:2019-08-22 10:16:05
【问题描述】:

我使用 google-places-autocomplete 填充字段地址(地址、城市、国家、邮政编码、纬度、经度).. 它在所有浏览器中都能正常工作,但并非每次在 firefox 浏览器中都能正常工作(它可能导致通过缓存火狐浏览器) 代码js:

        function initializeAutocomplete(id) {
                    var element = document.getElementById(id);
                    if (element) {
                        var autocomplete = new google.maps.places.Autocomplete(element, { types: ['geocode'], language : _mpop.current_lang });
                        if(id == "parent_personal_info_fullAddress" || id == "edit_babysitter_personal_info_fullAddress" ||
                            id == "address_bb" || id == "home_address" ){
                            google.maps.event.addListener(autocomplete, 'place_changed', onPlaceChangedEditUser);
                        }
                    }
                }


        function onPlaceChangedEditUser(){
        var place = this.getPlace();
        $('.postal_code').val('');
        for (var i in place.address_components) {
            var component = place.address_components[i];
            for (var j in component.types) {
                var type_element = $('.'+component.types[j]);
                if(component.types[j] == "country"){
                    $('#country').find('option').attr('selected', false);
                    $('#country').find('option[data-country="' + component.short_name + '"]').attr('selected', true);
                    $('#country_iso').val(component.short_name);
                    $('#country').change();
                    $('.country-short').val(component.short_name);


                }
                if (type_element) {
                    type_element.val(component.long_name);
                }
                if($("#latitude").length){
                    $("#latitude").val(place.geometry.location.lat());
                    $("#longitude").val(place.geometry.location.lng());

                }
                if($(".latitude").length){
                    $(".latitude").val(place.geometry.location.lat());
                    $(".longitude").val(place.geometry.location.lng());
                }


            }
        }
    }

$(document).ready(function () {
google.maps.event.addDomListener(window, 'load', function() {
    initializeAutocomplete('babysitter_search_address');
});
}

【问题讨论】:

    标签: javascript jquery google-maps autocomplete google-places-api


    【解决方案1】:

    如果您指的是地图图块有时无法加载,这是最近在 Google 问题跟踪器中报告的一个已知问题:

    https://issuetracker.google.com/issues/138267513

    它似乎已在 v68.0.2 中得到修复。如果由于某种原因您还不能更新,那么您可以通过关闭 Firefox 的缓存来解决此问题。

    查看其他 SO 线程:Embedded Google Maps tiles not loading in Firefox second page load until zoomed

    希望这可以澄清您的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-08
      • 2014-09-16
      • 1970-01-01
      • 2022-10-31
      • 1970-01-01
      • 2010-12-24
      • 2012-10-16
      • 1970-01-01
      相关资源
      最近更新 更多