title: Google Map API to detect user location
body: <p>I am learning about jquery mobile. I came across a sample code which uses the following google maps api</p>
  
  <pre><code>http://maps.google.com/maps/api/js?sensor=false
  </code></pre>
  
  <p>And the code is to detect the current location of the user</p>
  
  <pre><code>function getPosition(position) {
          var lat = position.coords.latitude;
          var lng = position.coords.longitude;
  
          var latlng = new google.maps.LatLng(lat, lng);
          var geocoder = new google.maps.Geocoder();
  
          if (geocoder) {
            geocoder.geocode({'latLng': latlng}, function(results, status) {
              if (status == google.maps.GeocoderStatus.OK) {
                if (results[1]) {
              //window.alert(results[1].address_components[0].long_name);
              var locationVal = results[1].address_components[0].long_name;
              var stateVal = results[1].address_components[1].short_name;
  
              var location = document.getElementById('location');
  
              location.value = locationVal;
  
                }
              }
            });
          }
            }
            if (navigator.geolocation) {
          navigator.geolocation.getCurrentPosition(getPosition); 
            }
  </code></pre>
  
  <p>In the above code, in the results array, there is an address_components array. How to determine the properties of the results object and then again the properties of the address_component?</p>