设置当window.onresize事件发生在#map_canvas样式属性:
window.onresize = function(event) {
var style = document.getElementById('map_canvas').style;
style.width = '100%';
style.height = '100%';
style.position = 'absolute';
style.top = '42px';
style.left = '0';
style.right = '0';
style.bottom = '0';
style.z-index = '0';
style.overflow = 'hidden';
google.maps.event.trigger(map, 'resize');
map.setZoom(map.getZoom());
}
这个jQuery当量考虑到顶部
window.onresize = function(event) {
var el = $("#map_canvas");
el.css("position", "absolute");
el.css("top", "42px");
el.css("left", "0px");
el.css("right", "0px");
el.css("bottom", "0px");
el.css("width", "100%");
el.css("height", $("body").height() - 42);
el.css("overflow", "hidden");
google.maps.event.trigger(Maps.map, 'resize');
Maps.map.setZoom(Maps.map.getZoom());
}
的42PX
您几乎可以肯定需要在地图上触发google.maps.Map调整大小事件。 – geocodezip
补充,谢谢。 – ram1
此外,它没有考虑到顶部的酒吧。即使是42像素,它也不适合页面。它会下移。但在其他方面完美 – FabianCook