【问题标题】:Get an address for place ID in flutter在颤动中获取地点ID的地址
【发布时间】:2020-04-30 16:44:13
【问题描述】:

我是 Flutter 的新手

我正在开发一个使用 Places API 和 Google 地图的项目。 我希望用户在输入地点 ID 时能够获得地点地址。

我已经能够使用地理编码检索地点 ID。

请问如何使用地点 ID 获取地点地址

【问题讨论】:

  • 你用的是什么包,可以分享一下链接吗?
  • 地理定位器和 google search_map_places
  • 我只想在颤抖中做here这里所做的事情

标签: android flutter dart google-places-api geocode


【解决方案1】:

使用google_maps_webservice包:

final geocoding = GoogleMapsGeocoding(
      apiKey: '...........');

final response = await geocoding.searchByPlaceId('ChIJd8BlQ2BZwokRAFUEcm_qrcA');

final result =  response.results[0].formattedAddress;
// Result will be: 277 Bedford Ave, Brooklyn, NY 11211, USA

记得从开发者控制台启用该服务。

【讨论】:

  • 我很高兴它有所帮助。能否请您帮我一个忙,并将此问题标记为已回答。
【解决方案2】:

您可以从官方文档中阅读有关 Place ID 的所有信息: https://developers.google.com/maps/documentation/places/web-service/place-id

只需发出 GET 请求:

https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJrTLr-GyuEmsRBfy61i59si0&key=YOUR_API_KEY

【讨论】:

  • 这是一个很好的解决方案。
  • 谢谢,@SaifulIslam
猜你喜欢
  • 2020-10-05
  • 1970-01-01
  • 1970-01-01
  • 2012-05-09
  • 1970-01-01
  • 1970-01-01
  • 2014-08-30
  • 2021-11-25
  • 2022-01-23
相关资源
最近更新 更多