Rendering google map using gmaps4rails through Ajax

浪子不回头ぞ 提交于 2019-12-11 06:09:14

问题


I want to render the map only on demand(to minimize the loading time), means some link like 'Show Map' should render the map in a specified div. what should i do?


回答1:


Simply use the 'to_gmaps4rails' method described here: https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Methods

Basically, do:

<%=raw assets_hash.to_gmaps4rails(true) %>

This will render only the js necessary to display your assets.

So include gmaps4rails.js and .css (if necessary), and the div to host the map.



来源:https://stackoverflow.com/questions/5611113/rendering-google-map-using-gmaps4rails-through-ajax

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