Google地图显示来自隐藏区域 [英] Google map display from a hidden area

查看:75
本文介绍了Google地图显示来自隐藏区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个谷歌地图,我想向用户展示一个谷歌地图,如果他们点击一个链接,即显示地图。



将地图放在隐藏的div中根本不起作用,所以我将隐藏地图-1000px放在绝对css值上。



这给了我更好的结果,但是当我用css把地图带回来的时候,它只显示了它。



http://screencast.com/t/MTMyOGZmNW



任何人都可以给我一个建议,告诉我隐藏地图在我进行表演后变得可见吗?



希望有人能提供建议。



谢谢

解决方案

您无需担心绝对位置和所有这一切。让div隐藏直到必要,然后显示它并调用 google.maps.event.trigger(map,'resize')(v3)或 map.checkResize()(v2)



注释中提到的其他场景:

确保您在调用 map.fitBounds() google.maps.event.trigger(map,'resize') c>或者你会得到意想不到的结果。


I really hope someone can advise on displaying a google map from a hidden div.

I have a google map which I want to show a user if they click on a link ie, Show Map.

Putting the map in a hidden div just does not work at all so I went with hiding the map -1000px on a position absolute css value.

This has given me much better results but when I use css to bring the map back in only have of it shows.

http://screencast.com/t/MTMyOGZmNW

Can anyone give me advise on the best way to have a hidden map become visible after I peform a show ?

Hope someone can advise.

Thanks

解决方案

You needn't bother with the absolute position and all that. Let the div be hidden until necessary, then show it and call google.maps.event.trigger(map, 'resize')(v3) or map.checkResize()(v2)

Additional scenario mentioned in comments:

Make sure you call google.maps.event.trigger(map, 'resize') BEFORE calling map.fitBounds() or you will get unexpected results.

这篇关于Google地图显示来自隐藏区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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