Display google map using gmaps4rails via Ajax

I want to display the map only on demand (in order to minimize load time), means that any link, for example, "Show map", should display the map in the specified div. what should I do?

+1
source share
1 answer

Just 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 only displays the js needed to display your assets.

So, enable gmaps4rails.js and .css (if necessary), and the div to place the map.

+1
source

All Articles