在加载Google地图后,如何使用JavaScript调整Google地图大小? [英] How do I resize a Google Map with JavaScript after it has loaded?

查看:98
本文介绍了在加载Google地图后,如何使用JavaScript调整Google地图大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个'mapwrap'div设置为400px x 400px,里面,我有一个Google'地图'设置为100%x 100%。所以地图加载在400 x 400px,然后用JavaScript我调整大小的'mapwrap'到100%x 100%的屏幕 - 谷歌地图调整到整个屏幕,我预计,但瓷砖开始消失在右边缘之前

I have a 'mapwrap' div set to 400px x 400px and inside that I have a Google 'map' set to 100% x 100%. So the map loads at 400 x 400px, then with JavaScript I resize the 'mapwrap' to 100% x 100% of the screen - the google map resizes to the whole screen as I expected but tiles start disappearing before the right hand edge of the page.

有一个简单的函数,我可以调用导致谷歌地图重新调整到更大的尺寸'mapwrap'div?

Is there a simple function I can call to cause the Google map to re-adjust to the larger size 'mapwrap' div?

推荐答案

如果您使用的是Google Maps v2,请调用 checkResize()在调整大小后的容器。 链接

If you're using Google Maps v2, call checkResize() on your map after resizing the container. link

这篇关于在加载Google地图后,如何使用JavaScript调整Google地图大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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