【问题标题】:how to select all cities using google map api v3如何使用谷歌地图 api v3 选择所有城市
【发布时间】:2011-07-18 10:12:45
【问题描述】:

我认为一种可能的方法是:

service.search({
    types: ["city"],
    bounds: founded_bounds
}, function(places, status) {});
  1. 使用通常的Geocoder service 选择国家/州边界
  2. 制作place search request

available places types 中没有“城市”类型。如何获取所选国家/州的所有城市?

UPD 感谢 bweaver,地点 城市

但现在我遇到了另一个麻烦: 谷歌地图地方搜索工作真的很荒谬!我做了一点demo 来显示问题。我也会将它发布到 google api bugtracker。

*see console F12
Search for places in Hawaii (all types): 21
Search for places in Honolulu (all types): 22

这是不真实的。

【问题讨论】:

  • (administrative_area_level_1 == state) 和 (locality == city) 如果我没记错的话。

标签: javascript google-maps google-maps-api-3


【解决方案1】:

我找到了解决方案。它不属于 google map api,但它可以工作(formatted=true 是可选的)

  1. http://ws.geonames.org/countryInfoJSON?country=US&formatted=true 重要数据:“geonameId”:6252001
  2. 对于 geonameId 进行递归搜索(我认为深度 3-4 级就足够了)http://ws.geonames.org/childrenJSON?geonameId=6252001&style=full&maxRows=1000&formatted=true
  3. “fclName”参数过滤结果包含“city, vilage”子字符串

使用这个逻辑,我将为每个状态创建脚本生成的 json 文件。该脚本将作为每个月的 cron 作业进行

如果有人知道如何使用 google map api 完成此类任务 - 请发布!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多