title: How do I add an addPolylines feature to gmaps4rails?
body: <p>I'm working with the <a href="https://rubygems.org/gems/gmaps4rails" rel="nofollow">gmaps4rails</a> gem (version 1.5.6), and I want to add the ability to add more Polylines to a map rather than replacing the Polylines that are already there. On github, this code is viewable <a href="https://github.com/apneadiving/Google-Maps-for-Rails/tree/1.x" rel="nofollow">here</a>.</p>
  
  <p>This feature already exists for <a href="https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Javascript-goodies#markers" rel="nofollow">Markers</a>:
  <code>Gmaps.map.replaceMarkers(your_markers_json_array);</code> <code>Gmaps.map.addMarkers(your_markers_json_array);</code>.</p>
  
  <p>The Markers feature seems to be laid out in two places:</p>
  
  <p>1) In <a href="https://github.com/apneadiving/Google-Maps-for-Rails/blob/1.x/public/javascripts/gmaps4rails/gmaps4rails.base.js#L342" rel="nofollow">gmaps4rails.base.js</a> as:</p>
  
  <pre><code>Gmaps4Rails.prototype.addMarkers = function(new_markers) {
    this.markers = this.markers.concat(new_markers);
    this.create_markers();
    return this.adjustMapToBounds();
  };
  </code></pre>
  
  <p>2) In <a href="https://github.com/apneadiving/Google-Maps-for-Rails/blob/1.x/app/assets/javascripts/gmaps4rails/gmaps4rails.base.js.coffee#L314" rel="nofollow">gmaps4rails.base.js.coffee</a> as:</p>
  
  <pre><code>  #add new markers to on an existing map
    addMarkers : (new_markers, adjustBounds = true) -&gt;
      #update the list of markers to take into account
      @markers = @markers.concat(new_markers)
      #put markers on the map
      @create_markers()
      @adjustMapToBounds() if adjustBounds
  </code></pre>
  
  <p>I figured I could work with the <code>replacePolylines</code> code in to make my own <code>addPolylines</code> call:</p>
  
  <p>1) In <a href="https://github.com/apneadiving/Google-Maps-for-Rails/blob/1.x/public/javascripts/gmaps4rails/gmaps4rails.base.js#L393" rel="nofollow">gmaps4rails.base.js</a> near the <code>replacePolylines</code> code as:</p>
  
  <pre><code>Gmaps4Rails.prototype.addPolylines = function(new_polylines) {
    this.polylines = this.polylines.concat(new_polylines);
    this.create_polylines();
    return this.adjustMapToBounds();
  };
  </code></pre>
  
  <p>2) In <a href="https://github.com/apneadiving/Google-Maps-for-Rails/blob/1.x/app/assets/javascripts/gmaps4rails/gmaps4rails.base.js.coffee#L387" rel="nofollow">gmaps4rails.base.js.coffee</a> near the <code>replacePolylines</code> code as:</p>
  
  <pre><code> #add new polylines to on an existing map
    addPolylines : (new_polylines) -&gt;
      #update the list of polylines to take into account
      @polylines = @polylines.concat(new_polylines)
      #put polylines on the map
      @create_polylines()
      #.... and adjust map boundaries
      @adjustMapToBounds()
  </code></pre>
  
  <p>I've made these changes to the gem that's already added to my Rails project, and I've restarted my Rails server. I call it the same way I call <code>replacePolylines</code>, with <code>Gmaps.map.addPolylines(your_polylines_json_array);</code>. It produces an error in the console: <code>Uncaught TypeError: Object #&lt;Gmaps4RailsGoogle&gt; has no method 'addPolylines'</code>.</p>
  
  <p>There doesn't seem to be anywhere else in the gmaps4rails project where I have to do anything for my <code>addPolylines</code> call, but I'm obviously not doing something right. Can anyone explain what I need to do to get this to work, based on this information?</p>