google-places bug in firefox browser

岁酱吖の 提交于 2019-12-03 00:05:14

问题


I use google-places-autocomplete for fill fields address (address ,city,country,postal code, latittude , longitude) .. it work well in all browsers but it doesen't work everytime in firefox browser (it may caused by the cache firefox browser) code 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');
});
}

回答1:


If you're referring to the map tiles not loading sometimes, this is a known issue that was recently reported in Google's Issue Tracker:

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

It appears to have been fixed in v68.0.2. If for some reason you cannot update yet then you can work around this issue by turning off Firefox's cache.

See this other SO thread: Embedded Google Maps tiles not loading in Firefox second page load until zoomed

Hope this clarifies your question.



来源:https://stackoverflow.com/questions/57607043/google-places-bug-in-firefox-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!