我的网站上有一个谷歌地图,自12月初以来一直很好用。突然有一天晚上,当我进入站点时,地图默认打开。我关不上。我所有的谷歌地图都是这样的...但几个月来没有人碰过密码?是什么原因造成的?
Inspect elements in Firefox告诉我div是隐藏的,但它是相当可见的。
我的控制台显示没有错误。
我知道这是很宽泛的,但它如此奇怪的行为,不可能是由php文件中错误的击键引起的。
好吧。还是不行。很遗憾,很抱歉,我不能分享这个网站。但是,我已经将代码压缩到了最小值--可见性默认为可见性。哦,当我禁用谷歌代码时,一切正常。屏幕默认为正确的视图,点击图像就会正确打开面板--就在地图所在的位置是灰色的。
CSS...将mapproj div定义为隐藏。
#mapproj, #mappers, #mapbuildproj, #mapcurproj {
visibility:hidden;
background:#666;
text-align:left;
position:absolute;
width: calc(100% - 200px);
width: -o-calc(100% - 200px); /* opera */
width: -webkit-calc(100% - 200px); /* google, safari */
width: -moz-calc(100% - 200px);
height: calc(100% - 80px);
height: -o-calc(100% - 80px); /* opera */
height: -webkit-calc(100% - 80px); /* google, safari */
height: -moz-calc(100% - 80px);
overflow-y:auto;
left:200px;
top:40px;
color:black;
z-index:1;
}
HTML...调用仅设置变量comp的showprojmap()函数。
<img style="margin-left:5px;" class="icon" src="images/add.png" alt="some_text" title="Add a project" onclick="showprojmap(3)" height="15px" width="15px">
<div id="mapproj"></div>
Showprojmap函数...应将div设置为未设置类型时可见。
function showprojmap(comp, type) {
if (typeof type !=='undefined') {
var personallog = document.createElement('input');
var createproject = document.getElementById("createproject");
personallog.setAttribute("id","personalid");
personallog.setAttribute("name","personalid");
personallog.setAttribute("type","hidden");
personallog.setAttribute("value",comp)
createproject.appendChild(personallog);
document.getElementById('mappers').style.visibility = "visible";
} else {
var personallog = document.getElementById("personalid");
document.getElementById('mapproj').style.visibility = "visible";
if (personallog){
personallog.parentNode.removeChild(personallog);
}
}
document.getElementById('logsmapproject').style.visibility = "visible";
}
谷歌地图代码...自动将div设置为可见。
var mapproj;
function initializeproj() {
var mapOptions = {
center: { lat: -34.397, lng: 150.644},
zoom: 8
};
mapproj = new google.maps.Map(document.getElementById('mapproj'), {
zoom: 15,
center: { lat: 41.7636111, lng: -72.6855556}
});
var infowindow = new google.maps.InfoWindow();
}
google.maps.event.addDomListener(window, 'load', initializeproj);
而且,直到上周二晚上9:00-10:00左右才出现这种情况。由于我的计算机上没有打开文本编辑器,这已停止工作。
我最近遇到了一个类似的问题,突然间,弹出式地图停止关闭。
如果对您有帮助,我通过请求google maps JS api的最新版本(通过向请求查询字符串添加v=3.18)来解决这个问题。我仍然看到V3.19的问题。
http://maps.google.co.uk/maps/api/js?v=3.18&sensor=true&callback=loadMaps
我发现,如果你不显式地请求一个版本,你只是得到最新的实验版本。
希望这有帮助。