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

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

问题描述

我有一个 'mapwrap' div 设置为 400px x 400px,在里面我有一个 Google 'map' 设置为 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.

有没有我可以调用的简单函数来使 Google 地图重新调整为更大尺寸的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 Maps JavaScript API v2 已于 2011 年弃用.它不再可用.

Google Maps JavaScript API v2 was deprecated in 2011. It is not available anymore.

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

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