【问题标题】:how to consider latitude and longitude of a location from googleapis如何从googleapis考虑位置的纬度和经度
【发布时间】:2011-09-16 02:20:52
【问题描述】:

我正在使用“http://maps.googleapis.com/maps/api/geocode/xml?address="+address+"&sensor=true" 来获取某个位置的纬度和经度。由此我得到如下回复:

<?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 和 lat 值。那么我必须考虑哪一个?

【问题讨论】:

    标签: google-maps google-maps-api-3 latitude-longitude weather-api google-weather-api


    【解决方案1】:

    取位置标签下的 lat, lng -- 这个位置是由 location_type 指示的近似位置

    【讨论】:

    • 但是当我比较时,位置标签下的值并没有给出确切的天气细节。
    • 你在哪里比较天气细节?它返回的 lat lon 指向芝加哥市中心的一个位置——你要比较的地址会不会有点远?我只是在这里猜测 - 所以我可能是错的
    • 你也可以看看stackoverflow.com/questions/2780836/…的问题和回复——认为可能是相关的
    猜你喜欢
    • 2011-07-06
    • 1970-01-01
    • 2012-11-08
    • 1970-01-01
    • 1970-01-01
    • 2017-11-10
    • 1970-01-01
    • 2018-11-26
    • 1970-01-01
    相关资源
    最近更新 更多