问题
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