title: extract city from reverse geocode
body: <p>I am struggling with finding the city name from latitude and longitude.</p>
  
  <p>I am parsing latitude and longitude from a json callback from flickr.
  Now, I am trying to reverse geocode the latitude and longitude to determine if the pictures are in Los Angeles. I am trying to make a count of the pictures are that are in Los Angeles and the pictures that are not in Los Angeles. </p>
  
  <p>When I load my code into the browser, nothing happens. I am not getting any errors from firebug. I tested the json parse for the latitude and longitude in a separate html file, so I know that part is working. I was able to display the latitude and longitude for each picture. What I am struggling with is the reverse geocoding.</p>
  
  <p>thank you for any help! :)</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Flickr Pie Chart&lt;/title&gt;
  &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"&gt;
  &lt;script src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false"&gt;&lt;/script&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;script type="text/javascript"
    src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB3eu10Q0JajjUWTEQd_ENYDT64u3ZM7KA&amp;sensor=false"&gt;
  &lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  var latitude;
  var longitude;
  var geocoder;
  var city;
  var cityName = "Los Angeles";
  var inLosAngeles;
  var notLosAngeles;
  var map;
  var infowindow = new google.maps.InfoWindow();
  var marker;
  var latlng;
  var inside = 0;
  var outside = 0;
  $(document).ready(function() {
      function extractFromAdress(components, type) {
          for (var i = 0; i &lt; components.length; i++)
          for (var j = 0; j &lt; components[i].types.length; j++)
          if (components[i].types[j] == type) return components[i].long_name;
          return "";
      }
      var url = 'http://api.flickr.com/services/rest/?&amp;method=flickr.photos.search&amp;api_key=14bfe578621f2dfe5c58086de5c79ab9&amp;tags=losangeles&amp;has_geo=1&amp;extras=geo,tags&amp;format=json&amp;nojsoncallback=1';
      $.getJSON(url, function(data) {
          //loop through the results with the following function
          $.each(data.photos.photo, function(i, item) {
              latitude = item.latitude;
              longitude = item.longitude;
              geocoder = new google.maps.Geocoder();
              latlng = new google.maps.LatLng(latitude, longitude);
  
              function codeLatLng() {
                  var input = document.getElementById('latlng').value;
                  var latlngStr = input.split(',', 2);
                  var lat = parseFloat(latlngStr[0]);
                  var lng = parseFloat(latlngStr[1]);
                  var latlng = new google.maps.LatLng(lat, lng);
                  geocoder.geocode({
                      'latLng': latlng
                  }, function(results, status) {
                      if (status == google.maps.GeocoderStatus.OK) {
                      if(results[0]){
  
                          var town = extractFromAdress(results[0].address_components, "locality");
                          if (town == cityName) {
                              inside += 1;
                          } else {
                              outside += 1;
                          }
                      }
                      }
                  });
              }
          });
          inLosAngeles = inside;
          notLosAngeles = outside;
          $('#results').append('inLosAngeles' + inLosAngeles + '' + 'notLosAngeles' + notLosAngeles);
      });
  });
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;div id = "results"&gt;&lt;/div&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>