Google 映射详细信息 API 没有 return 字段

Google maps details API does not return fields

我正在尝试从 google maps place detail api.

中检索信息

我叫这个 url:

https://maps.googleapis.com/maps/api/place/details/json?key=my_api_key&place_id=ChIJgQlGoRzcQUcRP8UPrtI8hcc&fields=geometry,price_level,rating,review,user_ratings_total

地点id来自地点搜索api,是this个地点的id。

所以我在 url 中请求以下字段:geometry、price level、rating、review,user_ratings_total,我的回复如下:

{
   "html_attributions" : [],
   "result" : {
      "geometry" : {
         "location" : {
            "lat" : 47.510746,
            "lng" : 19.036858
         },
         "viewport" : {
            "northeast" : {
               "lat" : 47.51209583029149,
               "lng" : 19.0382836802915
            },
            "southwest" : {
               "lat" : 47.50939786970849,
               "lng" : 19.0355857197085
            }
         }
      }
   },
   "status" : "OK"
}

几何显示正常,但其他字段没有显示。

根据documentation,它们都是有效的查询参数,参数应该用逗号分隔。 文档中有三种类型的字段,所有 Basic 类型的字段都有效,另外两个 ContactAtmosphere 无效。

如何获取响应中的所有字段参数?

看来你打错了place_id。 place_id 您使用的 return 不是您 link 的业务。

使用 Place ID Finder for BlackBelt Technology Kft 给出 place_id 的:ChIJUxteJqfeQUcRAXhmxC6DVn0

在您的查询中使用 place_id return 正确的评分、评论和 user_ratings_total:

https://maps.googleapis.com/maps/api/place/details/json?key=[yourkey]&place_id=ChIJUxteJqfeQUcRAXhmxC6DVn0&fields=geometry,price_level,rating,review,user_ratings_total

returns:

{
   "html_attributions" : [],
   "result" : {
      "geometry" : {
         "location" : {
            "lat" : 47.510746,
            "lng" : 19.036858
         },
         "viewport" : {
            "northeast" : {
               "lat" : 47.51209583029149,
               "lng" : 19.0382836802915
            },
            "southwest" : {
               "lat" : 47.50939786970849,
               "lng" : 19.0355857197085
            }
         }
      },
      "rating" : 4.9,
      "reviews" : [
         {
            "author_name" : "Ferenc Magnucz",
            "author_url" : "https://www.google.com/maps/contrib/106293318482835037880/reviews",
            "language" : "hu",
            "profile_photo_url" : "https://lh6.ggpht.com/-iV81elgPTlY/AAAAAAAAAAI/AAAAAAAAAAA/UtxhI3d0Hc0/s128-c0x00000000-cc-rp-mo/photo.jpg",
            "rating" : 5,
            "relative_time_description" : "a year ago",
            "text" : "Profi fejlesztők.",
            "time" : 1523996058
         },
         {
            "author_name" : "Balázs Solti",
            "author_url" : "https://www.google.com/maps/contrib/106041701773835494953/reviews",
            "language" : "hu",
            "profile_photo_url" : "https://lh5.ggpht.com/-yE-3lI1u9vo/AAAAAAAAAAI/AAAAAAAAAAA/cXsW4d_QR3Q/s128-c0x00000000-cc-rp-mo-ba5/photo.jpg",
            "rating" : 5,
            "relative_time_description" : "a year ago",
            "text" : "Családias, kellemes iroda tele jó emberekkel",
            "time" : 1511865164
         },
         {
            "author_name" : "Norbert Csaba Herczeg",
            "author_url" : "https://www.google.com/maps/contrib/117379994807862656830/reviews",
            "profile_photo_url" : "https://lh3.ggpht.com/-i2x74XtvUJM/AAAAAAAAAAI/AAAAAAAAAAA/ko28SV_gxG4/s128-c0x00000000-cc-rp-mo/photo.jpg",
            "rating" : 5,
            "relative_time_description" : "a year ago",
            "text" : "",
            "time" : 1513607989
         },
         {
            "author_name" : "Tibor Dr. Szállási",
            "author_url" : "https://www.google.com/maps/contrib/107869538624149315782/reviews",
            "profile_photo_url" : "https://lh4.ggpht.com/-6_bNC24Uwfc/AAAAAAAAAAI/AAAAAAAAAAA/XCbaj4_6gak/s128-c0x00000000-cc-rp-mo-ba3/photo.jpg",
            "rating" : 5,
            "relative_time_description" : "a year ago",
            "text" : "",
            "time" : 1513852229
         },
         {
            "author_name" : "Tamas Molnar",
            "author_url" : "https://www.google.com/maps/contrib/106716196386208549131/reviews",
            "profile_photo_url" : "https://lh5.ggpht.com/-CbTBYAV3R2o/AAAAAAAAAAI/AAAAAAAAAAA/DeIEdrGy8gs/s128-c0x00000000-cc-rp-mo/photo.jpg",
            "rating" : 5,
            "relative_time_description" : "11 months ago",
            "text" : "",
            "time" : 1540533991
         }
      ],
      "user_ratings_total" : 35
   },
   "status" : "OK"
}

它不是 return 价格水平,大概是因为该业务不存在该数据(它似乎不是 restaurant/bar/cafe)

企业(在地点 API 中)将在其条目中包含企业名称以及地址。地址条目不会。

地点编号:ChIJgQlGoRzcQUcRP8UPrtI8hcc 是地址:Budapest, Királyfürdő u. 4, 1027 Hungary

不是商家:BlackBelt Technology Kft. at the address: Budapest, Királyfürdő u. 4, 1027 Hungary

如果我使用 Place ID Finder

我得到 ChIJUxteJqfeQUcRAXhmxC6DVn0

的 PlaceId

里面有你要找的字段。

proof of concept fiddle