Gmaps4rails : map not showing when loaded dynamically

别说谁变了你拦得住时间么 提交于 2019-12-11 05:08:31

问题


When I display a map using Gmaps4rails through a Jquery call ($('#id').load(/xyz)), the map is not shown (a blank area is shown instead).

This page : https://groups.google.com/group/Google-Maps-API/browse_thread/thread/02710b15f3d76ec2/67413d33e7fd0e74?hl=en suggests calling map.reloadMap once the page has been loaded, however I don't know the id of the element that should be called. The gmaps4rails documentation only mentions the id of the div containing the map and reading the source didn't help.

How can this be solved ?


回答1:


Fyi, I've updated the source code. I especially commented the js file.

The map itself is stored in the following js variable:

Gmaps4Rails.map

But glad you found a solution to your problem ;)




回答2:


Solution : load the empty map in the main frame of the page, and update it dynamically with Gmaps4Rails.replace_markers(json).



来源:https://stackoverflow.com/questions/5340055/gmaps4rails-map-not-showing-when-loaded-dynamically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!