在flutter中获取地方ID的地址

问题描述 投票:0回答:1

扑朔迷离

我正在做一个使用地方API和谷歌地图的项目,我希望用户在输入地方ID时能够得到一个地方地址。

我已经能够检索的地方ID使用geocode。

请问我如何使用地方ID获取地方地址?

android flutter dart google-places-api geocode
1个回答
0
投票

使用 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

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

© www.soinside.com 2019 - 2024. All rights reserved.