Since early December, the Google map on my site has been working perfectly. However, the other night, I noticed that the map now defaults to open when entering the site and cannot be closed. Strangely, all my Google maps are behaving this way even though no one has touched the code in months. What could have caused this sudden change?
Upon inspecting elements in Firefox, it shows that the div is hidden but is actually quite visible.
There are no errors showing up in my console.
Although this issue seems broad, the behavior is so unusual that it couldn't have been caused by a random keystroke in the PHP file.
Even after stripping down the code to the bare minimum, the issue persists. Unfortunately, I can't share the site at the moment. When I disable the Google code, everything works fine - the screen defaults to the correct view and clicking on the image opens the panels correctly. The area where the map should appear turns grey.
The CSS defines the mapproj div as hidden.
#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;
}
The HTML calls the showprojmap() function with only the variable comp set.
<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>
The Showprojmap function should set the div as visible as type is not set.
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";
}
The Google Map Code automatically sets the div as visible.
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);
This issue started unexpectedly last Tuesday around 9:00 - 10:00pm without any active text editors on my computer.