title: ASP.NET MVC 3 Save lat and long from Google Map
body: <p>I have a Google Map on my View.</p>
  
  <p>I wish to save the long and lat of the marker that has just recently been added to the Map.
  My ViewModel has a Location object which contains a lat and long.</p>
  
  <p>Does anyone know how I can achieve this?</p>
  
  <p>The following is the code:</p>
  
  <pre><code>function addMarker(location, isdragable) {
      marker = new google.maps.Marker({
      position: location,
      map: _gmMap,
      icon: '../../Content/images/pin-red_32.png',
      draggable: isdragable
      });
  $('#mainPlaceHolder_hdnlatlong').val(location.lat() + ',' + location.lng());
  markersArray.push(marker);
  if (isdragable) {
      google.maps.event.addListener(marker, 'dragend', function () {
      showLocation(marker.getPosition().lat() + ',' + marker.getPosition().lng(), true);
      });
  }
  $('#spmsg').hide();
  }
  </code></pre>