0

I am using "http://maps.googleapis.com/maps/api/geocode/xml?address="+address+"&sensor=true" to get the latitude and longitude of a location. From this I am getting response like below:

<?xml version="1.0" encoding="UTF-8"?>
<GeocodeResponse>
 <status>OK</status>
 <result>
  <type>locality</type>
  <type>political</type>
  <formatted_address>Chicago, IL, USA</formatted_address>
  <address_component>
   <long_name>Chicago</long_name>
   <short_name>Chicago</short_name>
   <type>locality</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>Cook</long_name>
   <short_name>Cook</short_name>
   <type>administrative_area_level_2</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>Illinois</long_name>
   <short_name>IL</short_name>
   <type>administrative_area_level_1</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>United States</long_name>
   <short_name>US</short_name>
   <type>country</type>
   <type>political</type>
  </address_component>
  <geometry>
   <location>
    <lat>41.8781136</lat>
    <lng>-87.6297982</lng>
   </location>
   <location_type>APPROXIMATE</location_type>
   <viewport>
    <southwest>
     <lat>41.7450495</lat>
     <lng>-87.8859170</lng>
    </southwest>
    <northeast>
     <lat>42.0109012</lat>
     <lng>-87.3736794</lng>
    </northeast>
   </viewport>
   <bounds>
    <southwest>
     <lat>41.6443350</lat>
     <lng>-87.9402669</lng>
    </southwest>
    <northeast>
     <lat>42.0231310</lat>
     <lng>-87.5236609</lng>
    </northeast>
   </bounds>
  </geometry>
 </result>
</GeocodeResponse>

The response have so many lng and lat values for a location. So Which one I have to consider?

Rupesh Yadav
  • 12,096
  • 4
  • 53
  • 70
karthik k
  • 3,751
  • 15
  • 54
  • 68

1 Answers1

5

Take the lat, lng under the location tag -- this location is approximate as indicated by location_type

Sai
  • 3,819
  • 1
  • 25
  • 28
  • But with values under location tag are not giving the exact weather details when I compared. – karthik k Jun 16 '11 at 06:19
  • Where are you comparing the weather details against? The lat lon that it returns is pointing to a location in downtown chicago -- could it be that the address you are comparing against is slightly away? I am just guessing here -- so i could be wrong – Sai Jun 16 '11 at 14:20
  • You can also take a look at the question and responses at http://stackoverflow.com/questions/2780836/using-google-weather-api-with-lat-and-lon-how-to-format -- thought it might be related – Sai Jun 16 '11 at 14:22