title: How to get address from center (pan) Google Maps API?
body: <p>I'm building a google map where you get lat, long and address for a form. It gets your location through GPS and automatically center the map and gets the coordinates. Also if you pan the map you will get this data from the new center. </p>
  
  <p>I've seen a similar question <a href="https://stackoverflow.com/questions/12828044/how-to-get-the-formated-address-from-a-dragged-marker-in-google-version-maps">How to get the formatted address from a dragged marker in Google Version Maps</a> that gets you the address from a draggable marker. I wanna see if it's possible for the Reverse Geocoding Service to have it just from the center of the map whenever I pan it. </p>
  
  <p>Here is part of the code.</p>
  
  <pre><code>  google.maps.event.addListener(map, "center_changed", function() {
      var lat = map.getCenter().lat();
      var lng = map.getCenter().lng();
      $('#lat').val(lat);
      $('#lng').val(lng); 
    }); 
  
  ...
  
  &lt;body&gt;
  &lt;div id="map-canvas"&gt;&lt;/div&gt;
  
      &lt;input id="lat"/&gt;
      &lt;input id="lng"/&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>By now I can get the coordinates. Here you can see my map. <a href="http://output.jsbin.com/vopuhu" rel="nofollow noreferrer">http://output.jsbin.com/vopuhu</a> </p>
  
  <p>It's a similar map from the one that Uber uses to pick up customers.</p>
  
  <p>Thanks!</p>
  
  <p>Here is the Geolocation part also... </p>
  
  <pre><code>if(navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(position) {
    var pos = new google.maps.LatLng(position.coords.latitude,
                                     position.coords.longitude);
  document.getElementById('lat').value = position.coords.latitude;
  document.getElementById('lng').value = position.coords.longitude;
    var marker = new google.maps.Marker({
      map: map,
      position: pos,
      title: 'Ubicación GPS',
        icon:'https://storage.googleapis.com/ops_geojson/Flecker/Icons/GPS_Tiny01.png'
    });
  
    map.setCenter(pos);
  }, function() {
    handleNoGeolocation(true);
  });
  } else {
  
  handleNoGeolocation(false);
  }
  }
  
  function handleNoGeolocation(errorFlag) {
  if (errorFlag) {
  var content = 'Error: The Geolocation service failed.';
  } else {
  var content = 'Error: Your browser doesn\'t support geolocation.';
  }
  
  var options = {
  map: map,
  position: new google.maps.LatLng(19.043516, -98.198232),
  content: content,
  };
  
  var infowindow = new google.maps.InfoWindow(options);
  map.setCenter(options.position);
  
  }
  </code></pre>