如何更新谷歌地图,如果它的地图画布改变了它的尺寸? [英] How to update the google map if the map canvas of it changed its dimenstions?

查看:145
本文介绍了如何更新谷歌地图,如果它的地图画布改变了它的尺寸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个谷歌地图内部的div被改变,它的父div可以得到一个额外的类,它改变了它的尺寸。这种变化导致谷歌地图不被更新,它抵制了以前的尺寸。我怎样才能刷新谷歌地图?



我试着再次重新创建谷歌地图,但它似乎也保留了其他之前创建的谷歌地图。这有时会导致奇怪的行为(旧地图位于新的顶部)。可以发布谷歌地图吗?



感谢您的帮助! 解决方案

p>查看 google.maps.Map class 参考,我想你正在寻找 resize 事件:



lockquote>

开发者应该触发当div更改大小时,该事件在地图上:



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


I have a google map inside of a div which gets changed, its parent div can get an additional class which changes its dimensions. This changes causes the google map not to get updated, it resist in the previous dimensions. How can I refresh the google map?

I tried to recreate the google map again but it seems to keep the other previously created google maps there as well. This causes sometimes strange behavior (the old map is on the top of the new). Can a google map be released?

Thanks for your help!

解决方案

Check the google.maps.Map class reference, I think you're looking for the resize event:

Developers should trigger this event on the map when the div changes size:

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

这篇关于如何更新谷歌地图,如果它的地图画布改变了它的尺寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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