Reputation: 11
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?
Upvotes: 1
Views: 1168
Reputation: 115541
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.
Upvotes: 1