gmaps4rails change map id <p>I have a Rails 3.2.x app which I'm using <code>gmaps4rails 2.0.0.pre</code> (yes I know it's an old version). I'm using this to plot different vehicles (units) on a map in a gps view/controller. Now I'm trying to leverage <code>gmaps4rails</code> to display a map in a different view/controller to display a building (facility) location in the facility show view.</p> <p>On initial page load I display the facility's marker on a map in the proper location. However after a few moments the marker will disappear entirely. I know why this is happening but not how to fix it.</p> <p>I have the following <code>Coffeescript</code> which looks for an <code>ID</code> of <code>#map</code> and calls <code>/units</code> and <code>/gps</code> paths to update the GPS view/map in quasi-realtime.</p> <p><strong>gps.js.coffee</strong></p> <pre><code>$ -&gt; if $("#map").length &gt; 0 setInterval (-&gt; $.getScript "/units" # Get all current locations, find each marker in the map, and update it's position $.getJSON "/gps", (data) -&gt; $.each(data, (i, val) -&gt; marker = $.grep Gmaps.map.markers, (e) -&gt; e.id is val.id marker[0].setPosition(val.lat, val.lng) if marker[0]? ) ), 5000 $('.marker-link').on 'click', -&gt; id = $(this).data("marker-id") marker = $.grep Gmaps.map.markers, (e) -&gt; e.id is id marker[0].showInfowindow() if marker[0]? </code></pre> <p>So the problem is that the default <code>ID</code> for gmaps4rails maps is <code>#map</code>. I'm trying to figure out how to create a new map using the plugin with a different <code>ID</code> so that I can display a facility location and not call the coffeescript to refresh.</p> <p>Here's what my facility model/view/controller look like. Everything works but the marker disappears due to the coffee script calling <code>#map</code>. I don't want to lose this coffeescript functionality as it updates my gps show view with markers properly. I'd like to figure out a way to generate a gmaps4rails map and change the <code>ID</code>.</p> <p><strong>facility.rb</strong></p> <pre><code> acts_as_gmappable process_geocoding: false </code></pre> <p><strong>facilities_controller</strong></p> <pre><code>def show @facility = Facility.find(params[:id]) @marker = @facility.to_gmaps4rails do |facility, marker| #marker.infowindow render_to_string(partial: "unit_infowindow", locals: {unit: unit}) marker.json({id: facility.id}) end respond_to do |format| format.html # index.html.erb format.json { render json: @marker } end end </code></pre> <p><strong>facility show.html.erb</strong></p> <pre><code>&lt;div class="well"&gt; &lt;%= gmaps(markers: {data: @marker, options: {rich_marker: true, "auto_zoom" =&gt; false}}) %&gt; &lt;/div&gt; </code></pre> <p>Is there a way to generate a gmaps4rails map, and override the default <code>ID</code> of <code>#map</code> so I can keep the marker from disappearing and continue to use my coffeescript in my GPS view?</p> <p>If anyone has any suggestions, please let me know. I would greatly appreciate it.</p> <p>And if my question is confusing or needs more explanation, I will be happy to update it.</p>