Google会将其留在某个位置或半径

时间:2017-04-15 21:23:29

标签: python google-places-api

有人可以解释我如何找到法国巴黎的所有赌场(位置是纬度和经度),如果半径太大,可以不使用可以到巴黎以外的半径吗?换句话说,我怎样才能留在巴黎的境内? :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

1 个答案:

答案 0 :(得分:0)

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

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

  • 打开Goog​​le地图。

  • 创建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

    }

或(第二种方式)

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

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

query = keyword + in + city Name

使用纬度经度获取城市名称

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