【问题标题】:Google places to stay within a certain location or radius谷歌在特定位置或半径范围内的住宿地点
【发布时间】:2017-04-15 21:23:28
【问题描述】:

有人可以解释我如何在不使用半径过大的情况下找到法国巴黎的所有赌场(位置在纬度和经度上)吗?换句话说,我怎样才能留在巴黎境内? :D

from googleplaces import GooglePlaces, lang, types, Place

API_KEY = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ12345'
google_places = GooglePlaces(API_KEY)

query_result = google_places.nearby_search(
        location='48.866667, 2.333333', keyword='casino',
        radius=10000)

for place in query_result.places:
    try:
    # Returned places from a query are place summaries.
        print place.name
        print place.geo_location
        print place.place_id

【问题讨论】:

标签: python google-places-api


【解决方案1】:

Google 放置附近搜索最大 50,000 米(31 英里)。如果您尝试输入超过 50,000,则无法正常工作。

还有另一种方法可以找到一个城市中的所有赌场。

  • 打开谷歌地图。

  • 创建10-12个或更多点的纬度、经度值来触发请求。

  • 然后使用循环查找这些点内的所有位置。

  • 如果您想要更合适的结果,请为您的请求增加第一个触发点。

- 这只是我在 php 中创建的一个逻辑。

$triggerPoints = array("lat1,long1", "lat2,long2", "lat3,long3",....);

    foreeach(triggerPoints as $tP){
       $requestUrl = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=$tP&radius=[YOUR_RADIUS_VALUE]&type=[YOUR_TYPE]&name=panera&key=[YOUR_KEY_HERE";
       $results = file_get_contents($requestUrl);
       //Do what you want with response JSON data

    }

OR(第二种方式)

还有另一种方法可以找到一个城市中的所有赌场。谷歌提供文本搜索请求

https://maps.googleapis.com/maps/api/place/textsearch/json?query=Casino+in+Reno,NV,89501,USA&key={API_KEY}

查询 = 关键字 + in + 城市名称

使用经纬度获取城市名称

http://maps.googleapis.com/maps/api/geocode/json?latlng=39.52963,-119.81380&sensor=true

有关如何使用经纬度获取城市名称的更多信息

https://developers.google.com/maps/documentation/geocoding/start?csw=1#ReverseGeocoding

有关如何使用文本搜索请求的更多信息

https://developers.google.com/places/web-service/search

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    • 1970-01-01
    • 2015-11-17
    • 2015-08-26
    • 1970-01-01
    • 2021-08-04
    • 1970-01-01
    相关资源
    最近更新 更多