Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The reason is quite simple: the partial contains much javascript you can't load and execute this way. </p> <p>So you can't use RJS there.</p> <p>The proper way to do is UJS: get data with an AJAX call and render the result. In the following code, I use jQuery.</p> <p>In your view add:</p> <pre><code>//include google script &lt;script type="text/javascript" src='http://maps.google.com/maps/api/js?sensor=false&amp;libraries=geometry'&gt;&lt;/script&gt; //include gmaps4rails javascript &lt;%=javascript_include_tag 'gmaps4rails' %&gt; &lt;script type="text/javascript" charset="utf-8"&gt; //load map when button click (replace with what you want) $('#ajax_map').click(function(){ //you have to set a size to the div otherwise the map won't display, that's the purpose of these css classes $('#map_container').addClass('map_container'); $('#gmaps4rails_map').addClass('gmaps4rails_map'); //create the map object Gmaps4Rails.initialize(); //of course, replace these two with your dynamic data, you'd have to use some $.ajax jQuery method. Gmaps4Rails.direction_conf.origin = 'toulon, france'; Gmaps4Rails.direction_conf.destination = 'paris, france'; //read the js file, you can customize much more: https://github.com/apneadiving/Google-Maps-for-Rails/blob/master/public/javascripts/gmaps4rails.js Gmaps4Rails.create_direction(); }); &lt;/script&gt; &lt;div id="map_container"&gt; &lt;div id="gmaps4rails_map"&gt;&lt;/div&gt; &lt;/div&gt; &lt;button type="button" id="ajax_map"&gt;Ajax Map&lt;/button&gt; </code></pre> <p>Add the following class in your CSS:</p> <pre><code>#map-container { width: 800px; } #gmaps4rails_map { width: 800px; height: 400px; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload