Google Maps API - 调整大小会生成空白空白 [英] Google Maps API - Resizing generates blank white space

查看:140
本文介绍了Google Maps API - 调整大小会生成空白空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究它看起来像一个非常简单的功能,它引起了一些头痛。

I'm working on what it looked to be like a very simple feature which is causing a little bit of a headache.

我使用GIS,我们将其与Google地图集成。其中一位客户要求能够打开一个单独的弹出窗口,只显示地图。打开窗口不是问题,但是当我试图扩大包含地图的IFrame的宽度时,为了适应窗口大小,实际的地图图像保持相同的大小,并且剩余的空白填充剩余的空间空间。

I work with a GIS and we integrate it with Google Maps. One of the clients requested to be able to open a separate pop up window showing only the map. Opening the window wasn't a problem, but as I try to expand the width of the IFrame which contains the map, in order to fit the window size, the actual map image stays with the same size, and a white space fills the remaining space.

我想知道是否必须将新宽度值传递给某个预渲染函数或类似的东西...我已经尝试过使用checkResize()但这证明不起作用。

I wonder if I have to pass the new width value to some pre-rendering function or something like that... I've already tried using checkResize() but this proved not to work.

我用来获取地图IFrame的函数如下:

The function I'm using to darw the map IFrame goes below:

DrawMapIFrame()
{
   var str = '<iframe id="mapIFrame" name="mapIFrame" width="97%" height="' + parent.mapFrameHeight + '" src="' + $_URL_FleetMonitiorMapIFrame + '?UserID=' + parent.$_UserID + '&Encoding=' + parent.$_Encoding + '&id=' + _id +  '" frameborder="0" scrolling="No"></iframe>';
    document.getElementById("mapIFramePlace").innerHTML = str;
}


推荐答案

您需要展开div创建地图前需要的大小 ,或者您需要使用

Either you need to expand the div to the size you want before creating the map, or you need to use

google.maps.event.trigger(map, 'resize') 

使API知道容器已经改变。

to make the API aware that the size of the container has changed.

这篇关于Google Maps API - 调整大小会生成空白空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆