我的代码在 Google Chrome 和 IE 中有效,但在 Firefox 12 中无效。有人知道我如何使它在 Firefox 12 中有效吗?
代码:
...
/* START FULLSCREEN BUTTON */
// Globals
var map_size = 'small';
var map_position= 'inherit';
var map_top = 0;
var map_left = 0;
var map_width = 0;
var map_height = 0;
var map_zIndex = 0;
...
// when button clicked
if(map_size == 'small') {
map_size = 'large';
map_position= $('div.map').css('position');
map_top = $('div.map').css('top');
map_left = $('div.map').css('left');
map_width = $('div.map').css('width');
map_height = $('div.map').css('height');
map_zIndex = $('div.map').css('z-index');
$('#fullscreen').attr('src','/assets/images/restore.png');
$('#enlarge').html('Shrink Map');
controlUI.title = 'Click to make map smaller';
$('div.map').css('position', "fixed");
$('div.map').css('top', "10%");
$('div.map').css('left', "10%");
$('div.map').css('width', "80%");
$('div.map').css('height', "80%");
$('div.map').css('z-index', 10000);
google.maps.event.trigger(map,'resize');
map.panToBounds(bounds);
map.fitBounds(bounds);
} else {
map_size = 'small';
$('div.map').css('position', map_position);
$('div.map').css('top', map_top);
$('div.map').css('left', map_left);
$('div.map').css('width', map_width);
$('div.map').css('height', map_height);
$('div.map').css('z-index', map_zIndex);
$('#fullscreen').attr('src','/assets/images/fullscreen.png');
$('#enlarge').html('Enlarge Map');
controlUI.title = 'Click to make map bigger';
google.maps.event.trigger(map,'resize');
map.panToBounds(bounds);
map.fitBounds(bounds);
}
}
...
这是一个现场示例http://www.helloflight.com/flight/dlh410.cfm
更新- 请注意,现场示例使用下面的 setTimeout 解决方案,因此在 Firefox 12 中有效,但没有 setTimeout 解决方案在 Firefox 12 中不起作用
如您所见,它在最新版本的 Safari、Google Chrome 和 IE 中都可以使用,但是在 Firefox 中,当地图 div 放大时,地图瓦片仍然是原始 div 尺寸的大小,并且不会扩展到填充新的 div 尺寸。