我使用google-places-autocomplete填写字段地址(地址,城市,国家/地区,邮政编码,纬度,经度)..它在所有浏览器中均能正常工作,但并非每次都在Firefox浏览器中工作(这可能会导致通过缓存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');
});
}
答案 0 :(得分:0)
如果您指的是有时未加载的地图图块,则这是最近在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
希望这可以澄清您的问题。