Location based on correct map center for Google Place Service Nearby Search results
<p>This code successfully takes a localStorage place id variable passed from an autocomplete field (can click "Map It" and enter a place in the pop up that appears, at roadtripsharing.com to test), and creates a marker, info window, and circle. I included a default location {lat: 39, lng: -105} in case users accessed the page directly without any localStorage use. However, even when I go from the home page and store something in local storage, the places that come up (in this case ATM machines) are all centered around Colorado Springs, USA, which is the {lat: 39, lng: -105}. </p>

<p>I believe at the point of declaring  </p>

<pre><code>var request = {
        location: mapit.getCenter(),
        radius: 5000,
        //  query: 'atm'
        types: ['atm']
      };
</code></pre>

<p>mapit.getCenter() should be results[0].geometry.location (the marker location based on the localStorage Place ID passed from the home page). How to make the Place Service Nearby Search result use this as the location instead of always {lat: 39, lng: -105}? </p>

<pre><code>function initMapIt() {    
  var mapit = new google.maps.Map(document.getElementById('mapitmap'), {
      center: {lat: 39, lng: -105},
      zoom: 11,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });  
  var rtscircle = new google.maps.Circle({
        radius:document.getElementById("rtsfader").value*1609.34, 
        strokeWeight: 2,
        strokeColor: "blue",
          strokeOpacity: 0.9,
        fillColor: "red",
        fillOpacity: 0.15,
          clickable: false,
        map: mapit
        });
  if (localStorage.placetopass !== null){
    var rtsgeocoder = new google.maps.Geocoder;
    var newplace = localStorage.getItem('placetopass');
    rtsgeocoder.geocode({'placeId': newplace}, function(results, status) {
    if (status === google.maps.GeocoderStatus.OK) {
      if (results[0]) {
        mapit.setZoom(11);
        mapit.setCenter(results[0].geometry.location);
        var rtsmarker = new google.maps.Marker({
          map: mapit,
          position: results[0].geometry.location
        });
        var rtsinfowindow = new google.maps.InfoWindow;
        rtsinfowindow.setContent(results[0].formatted_address+'&lt;p&gt;&lt;a href="http://roadtripsharing.com/rate-place"&gt;Rate this place?&lt;/a&gt;&lt;/p&gt;');
        rtsinfowindow.open(mapit, rtsmarker);
        rtsmarker.addListener('click', function() {
          rtsinfowindow.open(mapit, rtsmarker);
        });
        rtscircle.setCenter(results[0].geometry.location);
        jQuery("#rtsfader").change(function(){
          rtscircle.setRadius(document.getElementById("rtsfader").value*1609.34);
        });
      }                           
         else {
        rtscircle.setCenter({lat: 39, lng: -105});   
      }
    } else {
      rtscircle.setCenter({lat: 39, lng: -105});
    }
  });
  document.getElementById("rts-aahs").play();
  }
  var request = {
    location: mapit.getCenter(),
    radius: 5000,
    //  query: 'atm'
    types: ['atm']
  };
  var infowindow = new google.maps.InfoWindow();
  var service = new google.maps.places.PlacesService(mapit);
  service.nearbySearch(request, callback);

function callback(results, status) {
  if (status == google.maps.places.PlacesServiceStatus.OK) {
    for (var i = 0; i &lt; results.length; i++) {
      createMarker(results[i]);
      console.log(results[i]);
    }
  }
  else
      alert("Status not OK");
}

function createMarker(place) {
    // alert("createMarker function");
  var placeLoc = place.geometry.location;
  var marker = new google.maps.Marker({
    map: mapit,
    position:  place.geometry.location
  });
  console.log(marker);
  google.maps.event.addListener(marker, 'click', function() {
    infowindow.setContent(place.name);
    infowindow.open(mapit, this);
  });
}

}
</code></pre>