0

我正在使用「http://maps.googleapis.com/maps/api/geocode/xml?address="+address+」& sensor = true「來獲取一個位置的經度和緯度。從這我得到的迴應如下:如何從googleapis中考慮緯度和經度的位置

<?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> 

響應有這麼多的lng和緯度值的位置。所以我必須考慮哪一個?

回答

5

就拿緯度,經度位置標籤下 - 這個位置是近似的LOCATION_TYPE

+0

但隨着我比較下位置的變量值不給確切的天氣信息指示。 – 2011-06-16 06:19:35

+0

你在哪裏比較天氣細節?它返回的經緯度指向芝加哥市中心的一個位置 - 是否可能是您比較的地址略微偏離?我只是在這裏猜測 - 所以我可能是錯的 – Sai 2011-06-16 14:20:54

+0

你也可以在http://stackoverflow.com/questions/2780836/using-google-weather-api-with-lat-and查看問題和迴應-lon-how-to-format - 認爲它可能是相關的 – Sai 2011-06-16 14:22:21