Google Maps Details API不返回字段 [英] Google maps details API does not return fields

查看:75
本文介绍了Google Maps Details API不返回字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从 google maps place details api中检索信息

我叫这个网址:

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

地点ID来自地方搜索api,它是

可以正确显示几何,但其他字段不显示.

根据文档,它们都是有效的查询参数并且参数应以逗号分隔. 文档中有三种类型的字段,所有Basic类型的字段都有效,而其他两个ContactAtmosphere无效.

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

解决方案

商家(在Places API中)将在其条目中包含商家名称以及地址.地址的条目将不会.

PlaceId: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,

您要查找的字段.

概念提琴证明

I am trying to retrieve information from the google maps place detail api.

I am calling this 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

The place id comes from the Place Search api, it is the id of this place.

So I am requesting the following fields in the url: geometry, price level, rating, review, user_ratings_total, and my response is the following:

{
   "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"
}

Geometry is showing up all right, but the other fields are not.

According to the documentation, they are all valid query parameters and the parameters should be separated by a comma. There are three types of fields in the documentation, all Basic type fields are working, the other two Contact and Atmosphere are not.

What do I do to get all the field parameters in the response?

解决方案

A business (in the Places API) will have the business name in its entry, as well as the address. The entries for the addresses won't.

PlaceId: ChIJgQlGoRzcQUcRP8UPrtI8hcc Is the address: Budapest, Királyfürdő u. 4, 1027 Hungary

Not the business: BlackBelt Technology Kft. at the address: Budapest, Királyfürdő u. 4, 1027 Hungary

If I use the Place ID Finder

I get a PlaceId of ChIJUxteJqfeQUcRAXhmxC6DVn0,

Which has the fields you are looking for.

proof of concept fiddle

这篇关于Google Maps Details API不返回字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆