最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

google maps - How to get number of parks of a specific county? - Stack Overflow

programmeradmin6浏览0评论

I'm working on a project where I need to find the number of parks (or Google Maps-designated “park” place types) within a given county. I’ve seen similar questions asked years ago, but the solutions seemed a bit outdated or insufficient. My current idea is to use the Google Places API to search for places with type park and count the number of unique place_ids returned. However, the challenge is that counties aren’t perfect squares, and I haven’t found a straightforward way to define a county’s polygon or bounding area using lat/lng coordinates. Has anyone dealt with something similar or have ideas on how to approach this? Appreciate any helps before I start investing money into this!

Many thanks!

I'm working on a project where I need to find the number of parks (or Google Maps-designated “park” place types) within a given county. I’ve seen similar questions asked years ago, but the solutions seemed a bit outdated or insufficient. My current idea is to use the Google Places API to search for places with type park and count the number of unique place_ids returned. However, the challenge is that counties aren’t perfect squares, and I haven’t found a straightforward way to define a county’s polygon or bounding area using lat/lng coordinates. Has anyone dealt with something similar or have ideas on how to approach this? Appreciate any helps before I start investing money into this!

Many thanks!

Share Improve this question edited Mar 25 at 15:03 miguev 4,92024 silver badges42 bronze badges asked Mar 22 at 19:54 Jerry ZhangJerry Zhang 513 bronze badges 1
  • Note the Places API won't work anymore, see my answer here: stackoverflow/questions/79516307/… – Starship Remembers Shadow Commented Mar 23 at 2:18
Add a comment  | 

1 Answer 1

Reset to default 1

There is a separate API for that: the [Places Aggregate API](https://developers.google/maps/documentation/places-aggregate/overview):

$ curl --location 'https://areainsights.googleapis/v1:computeInsights' \
--header 'X-Goog-Api-Key: YOUR_API_KEY_HERE' \
--header 'Content-Type: application/json' \
--data '{
   "insights":[
      "INSIGHT_COUNT"
   ],
   "filter":{
      "locationFilter":{
         "region":{
            "place":"places/ChIJlfCemC71pRIRkn_qeNc-yQc"
         }
      },
      "typeFilter":{
         "includedTypes":[
            "park"      
         ]
      } 
   }                     
}'                                   
{
  "count": "342"
}

Places API search methods are intended to be used only in areas much smaller than most countries, so that's not likely to work out well for you. Even with the Places Aggregate API, there is a limit to the size of [location_filter](https://developers.google/maps/documentation/places-aggregate/request-parameters?_gl=1*ced61l*_up*MQ..*_ga*ODQ3MTQyNzYxLjE3NDI5MTQ0ODA.*_ga_NRWSTWS78N*MTc0MjkxNDQ4MC4xLjEuMTc0MjkxNDg0NC4wLjAuMA..#location_filter) (2 trillion square meters) which means the bigger countries won't fit; e.g. Northern Territory and New South Wales fit in that limit, but Western Territory does not.

发布评论

评论列表(0)

  1. 暂无评论