迁移 Places API(旧版)响应

欧洲经济区 (EEA) 开发者

简介

地点详情(新版)、附近搜索(新版)和文本搜索(新版) API 的响应格式已从旧版 API 的格式发生变化。主要区别在于每个方法返回的 Place 对象的格式,如对响应 Place 对象的更改中所述。

此外,每个 API 的响应对象的顶级字段也发生了变化。请参阅:

对响应 Place 对象的更改

下表显示了“地点详情(新)”“附近搜索(新)”和“文本搜索(新)”响应中新 Place 对象与旧版 Place 对象相比的变化。

新的响应对象对字段名称使用驼峰命名法,包含新字段,并重命名了一些旧字段。

字段 Places API(旧版)对象 Places API(新版)对象 备注
地址组成部分 address_components addressComponents
地点微格式地址 adr_address adrFormatAddress
商家状态 business_status businessStatus
下周营业时间 current_opening_hours currentOpeningHours
编辑摘要 editorial_summary editorialSummary
设置了格式的地址 formatted_address formattedAddress
国内电话号码 formatted_phone_number nationalPhoneNumber
位置 geometry.location location
视口 geometry.viewport viewport
地点提供方信息 html_attributions attributions 旧版 API 中响应的顶级字段
图标网址 icon 已移除。请使用 iconMaskBaseUri 和 iconBackgroundColor。如需了解详情,请参阅地点图标。
图标背景颜色 icon_background_color iconBackgroundColor
图标遮罩网址 icon_mask_base_uri iconMaskBaseUri
国际电话号码 international_phone_number internationalPhoneNumber
文字地点名称 name displayName 文本地点名称现在可作为 displayName.text 访问,language 可作为 displayName.languageCode 访问
营业时间 opening_hours regularOpeningHours
照片 photos photos photos 的格式在新的 Place 对象中发生了变化。如需了解详情,请参阅照片参考信息变更。
地点 ID place_id id
Plus Code plus_code plusCode
价格水平 price_level priceLevel
评分 rating rating
评价 reviews reviews
从今天起下周的次要营业时间,包含例外情况和所有其他数据 secondary_opening_hours currentSecondaryOpeningHours
地点类型 types types
地点的 Google 地图网址 url googleMapsUri
房客评分数量 user_ratings_total userRatingCount
UTC 时差 utc_offset utcOffsetMinutes
地址的简短形式,包括街道名称和城镇 vicinity shortFormattedAddress
地点的网站 website websiteUri
轮椅无障碍设施信息 wheelchair_accessible_entrance accessibilityOptions wheelchair_accessible_entrance 现已降至 accessibilityOptions.wheelchairAccessibleEntrance
地点属性 takeout, delivery, dine_in, curbside_pickup, reservable, serves_breakfast, serves_lunch, serves_dinner, serves_beer, serves_wine, serves_brunch, serves_vegetarian_food takeout, delivery, dineIn, curbsidePickup, reservable, servesBreakfast, servesLunch, servesDinner, servesBeer, servesWine, servesBrunch, servesVegetarianFood
资源名称 name 字段,格式为 places/PLACE_ID 在旧版 API 中,name 字段包含作为文本字符串的地点名称。在新 API 中,该信息位于 displayName 中。
地点主要类型 primaryTypeName 新
以文本字符串形式放置主要类型 primaryTypeDisplayName 新
常规每周次要营业时间,包含例外情况和所有其他数据 regularSecondaryOpeningHours 新
该地点接受的支付方式 paymentOptions 新
地点停车选项 parkingOptions 新
与该地点相关的子目的地列表 subDestinations 新
加油站燃油选项的最新信息 fuelOptions 新
某个地点的电动汽车充电信息 evChargeOptions 新
地点属性 outdoorSeating, liveMusic, menuForChildren, servesCocktails, servesDessert, servesCoffee, goodForChildren, allowsDogs, restroom, goodForGroups, goodForWatchingSports 新

文本搜索响应变更

下表显示了文本搜索(旧版)的响应对象和文本搜索(新版)的响应对象的顶级字段的变化。对于新 API,响应中唯一的顶级字段是 places 数组。

字段 文本搜索(旧版) 文本搜索(新) 备注
地点属性 html_attributions 已移至每个地点的新 Place 对象中,作为 place.attributions
地点数组 旧版 Place 对象的 results 数组 新 Place 对象的 places 数组
请求的状态 status 已改为标准 HTTP 响应(HTTP 响应代码和消息)
所有错误消息 error_message 已改为标准 HTTP 响应(HTTP 响应代码和消息)
任何信息类消息 info_messages 已移除
页面令牌 next_page_token 已移除

“附近搜索”响应变更

下表显示了附近搜索(旧版)的响应对象和附近搜索(新版)的响应对象的顶级字段的变化。对于新 API,响应中唯一的顶级字段是 places 数组。

字段 附近搜索(旧版) 附近搜索(新) 备注
地点提供方信息 html_attributions 已移至每个地点的全新 Place 对象中,作为 place.attributions
地点数组 旧版 Place 对象的 results 数组 新 Place 对象的 places 数组
请求的状态 status 已改为标准 HTTP 响应(HTTP 响应代码和消息)
所有错误消息 error_message 已改为标准 HTTP 响应(HTTP 响应代码和消息)
任何信息类消息 info_messages 已移除
页面令牌 next_page_token 已移除

地点详情(新版)响应变更

下表显示了地点详情(旧版)的响应对象和地点详情(新版)的响应对象的顶级字段的变化。对于新 API,响应中唯一的顶级字段是 places 数组。

字段 地点详情(旧版) 地点详情(新版) 备注
地点提供方信息 html_attributions 已移至新的 Place 对象,作为 attributions
地点详情(新版) 包含旧版 Place 对象的 result 新的 Place 对象
请求的状态 status 已改为标准 HTTP 响应(HTTP 响应代码和消息)
任何信息类消息 info_messages 已改为标准 HTTP 响应(HTTP 响应代码和消息)