title: Javascript Scope & Geocode
body: <p>I've been searching here all day for help with what is likely, just a basic noob javascript mistake.</p>
  
  <p>I'm trying to get the lat/long from an address using google's geocoder glass.  However, I can't seem to assign it to a global or even derive it from the object's property (which I would prefer).  Basically all I need at this point to to just get the location from the geocoder and everything else should fall in place.  See code:</p>
  
  <pre><code>&lt;script src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=true&amp;libraries=places"&gt;&lt;/script&gt;
  
  &lt;script&gt;
      var geocoder = new google.maps.Geocoder();
      var ListingAddress = '1600 Pennsylvania Ave NW  Washington, DC 20500';
      var map;
      var infowindow;
  
      //var ListingLoc = new google.maps.LatLng(-33.8665433, 151.1956316);
      var ListingLatLong;
      var ListingLoc;
  
      function initialize() {
  
  
  
          geocoder.geocode({
                  address: ListingAddress
                  },
                  function(results){
                      ListingLatLong = results[0].geometry.location;
                      ListingLoc = new google.maps.LatLng(ListingLatLong);
                  });
  
          map = new google.maps.Map(document.getElementById('map_canvas'), {
              mapTypeId: google.maps.MapTypeId.ROADMAP,
              center: ListingLoc,
              zoom: 15
          });
  
          var request = {
              location: ListingLoc,
              radius: 500,
              types: ['school']
          };
          infowindow = new google.maps.InfoWindow();
          var service = new google.maps.places.PlacesService(map);
          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]);
              }
          }
      }
  
      function createMarker(place) {
          var placeLoc = place.geometry.location;
          var marker = new google.maps.Marker({
              map: map,
              position: place.geometry.location
          });
  
          google.maps.event.addListener(marker, 'click', function() {
              infowindow.setContent(place.name);
              infowindow.open(map, this);
          });
      }
      google.maps.event.addDomListener(window, 'load', initialize);
  &lt;/script&gt;
  </code></pre>
  
  <p>AND the markup</p>
  
  <pre><code>&lt;div id="map_canvas" style="width:600px;height:400px;border:none;"&gt;&lt;/div&gt;
  </code></pre>