title: gmaps4rails - Drop a marker and update fields attribute in a form
body: <p>I'm trying to implement this, from the gem wiki <a href="https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Javascript-goodies" rel="nofollow">https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Javascript-goodies</a></p>
  
  <pre><code>&lt;% content_for :scripts do %&gt;
      &lt;script type="text/javascript" charset="utf-8"&gt;
          var markersArray = [];
          // On click, clear markers, place a new one, update coordinates in the form
          Gmaps.map.callback = function() {
              google.maps.event.addListener(Gmaps.map.map, 'click', function(event) {
                clearOverlays();
                placeMarker(event.latLng);
                updateFormLocation(event.latLng);
              });
          };
          // Update form attributes with given coordinates
          function updateFormLocation(latLng) {
              $('location_attributes_latitude').value = latLng.lat();
              $('location_attributes_longitude').value = latLng.lng();
              $('location_attributes_gmaps_zoom').value = Gmaps.map.map.getZoom();
          }
          // Add a marker with an open infowindow
          function placeMarker(latLng) {
              var marker = new google.maps.Marker({
                  position: latLng, 
                  map: Gmaps.map.map,
                  draggable: true
              });
              markersArray.push(marker);
              // Set and open infowindow
              var infowindow = new google.maps.InfoWindow({
                  content: '&lt;div class="popup"&gt;&lt;h2&gt;Awesome!&lt;/h2&gt;&lt;p&gt;Drag me and adjust the zoom level.&lt;/p&gt;'
              });
              infowindow.open(Gmaps.map.map,marker);
              // Listen to drag &amp; drop
              google.maps.event.addListener(marker, 'dragend', function() {
                  updateFormLocation(this.getPosition());
              });
          }
          // Removes the overlays from the map
          function clearOverlays() {
            if (markersArray) {
              for (var i = 0; i &lt; markersArray.length; i++ ) {
                markersArray[i].setMap(null);
              }
            }
            markersArray.length = 0;
          }
      &lt;/script&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>But with no luck...I'm guessing its more of an issue with the name/id of my field(s), pardon my javascript knowledge.</p>
  
  <p>I've changed the fields to update with the coordinates:</p>
  
  <pre><code>function updateFormLocation(latLng) {
    $('location[lat]').value = latLng.lat();
    ...
  }
  </code></pre>
  
  <p>But the field doesn't get updated:</p>
  
  <pre><code>= simple_form_for :location do |l|
    = l.input :lat
    ...
  </code></pre>
  
  <p>Am I missing something? Thanks!</p>