我正在制作一个简单的 web 应用程序,用户在其中输入 WOEID 并在地图上绘制位置。我目前正在使用 Google Maps API,据我所知它不支持 WOEID 绘图,所以我试图找到一种简单的方法来从 WOEID 获取 Lat/Lng 坐标。我知道雅虎的 PlaceFinder 应该可以工作,但它是为 Lat/Lng 到 WOEID 而设计的,而不是相反。
有没有从 WOEID 获取 Lat/Lng 的简单方法?
我正在制作一个简单的 web 应用程序,用户在其中输入 WOEID 并在地图上绘制位置。我目前正在使用 Google Maps API,据我所知它不支持 WOEID 绘图,所以我试图找到一种简单的方法来从 WOEID 获取 Lat/Lng 坐标。我知道雅虎的 PlaceFinder 应该可以工作,但它是为 Lat/Lng 到 WOEID 而设计的,而不是相反。
有没有从 WOEID 获取 Lat/Lng 的简单方法?
您可以直接从 Yahoo 获取 Lat/Long。
文档显示在 XML 响应中返回了 lat/long 。
<?xml version="1.0" encoding="UTF-8"?>
<place yahoo:uri="http://where.yahooapis.com/v1/place/2507854" xml:lang="en">
<woeid>2507854</woeid>
<placeTypeName code="7">Town</placeTypeName>
<name>Trenton</name>
<country type="Country" code="US">United States</country>
<admin1 type="State" code="NJ">New Jersey</admin1>
<admin2 type="County" code="">Mercer</admin2>
<admin3/>
<locality1>Trenton</locality1>
<locality2/>
<postal/>
<centroid>
<latitude>40.21777</latitude>
<longitude>-74.759361</longitude>
</centroid>
<boundingBox>
<southWest>
<latitude>40.183868</latitude>
<longitude>-74.819519</longitude>
</southWest>
<northEast>
<latitude>40.248291</latitude>
<longitude>-74.728798</longitude>
</northEast>
</boundingBox>
</place>
您感兴趣的可能是centroid
元素。