javascript - 谷歌在Firefox浏览器中放置错误
问题描述
我使用 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');
});
}
解决方案
如果您指的是地图图块有时无法加载,这是最近在 Google 问题跟踪器中报告的一个已知问题:
https://issuetracker.google.com/issues/138267513
它似乎已在 v68.0.2 中修复。如果由于某种原因您还不能更新,那么您可以通过关闭 Firefox 的缓存来解决这个问题。
请参阅另一个 SO 线程:Embedded Google Maps tile not loading in Firefox second page load until zoomed
希望这能澄清你的问题。
推荐阅读
- python - Pandas 系列 - 如何使用字符串进行分组并以更好的方式执行值的平均值
- c - 使用 fgets() 利用 C 程序
- c# - 通过指向对象来获取对象名称 Unity Raycast
- reactjs - 如何在 ReactJS 中的 http://localhost:3000/ 和 TMDB api 之间启用 CORS?
- sql-server - 如何在sql server中检查特定用户的组
- abap - 将 KNKK 选择查询迁移到 S/4HANA?
- javascript - 尝试使用AngularJs关闭浏览器选项卡或窗口时如何进行服务调用
- c# - 无法从 AVAsset 获取缩略图
- php - 整数值忽略零并返回完整数字
- javascript - 如何使用javascript将base64彩色图像转换为灰度图像