如何从扑中的坐标获取位置名称? [英] How to get location name from coordinates in flutter?

查看:74
本文介绍了如何从扑中的坐标获取位置名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个可以获取用户位置并使用GPS显示地点名称的按钮。

I wanted a button that can get the location of the user and display the place name using GPS.

我尝试了地图视图,但只能获得经度和纬度。

I tried map_view but it only can get latitude and longitude.

推荐答案

使用 geocoder 插件
,它会为您提供 findAddressesFromCoordinates


导入'package:geocoder / geocoder.dart';

import 'package:geocoder/geocoder.dart';

示例;

final coordinates = new Coordinates(1.10, 45.50);
addresses = await Geocoder.local.findAddressesFromCoordinates(coordinates);
first = addresses.first;
print("${first.featureName} : ${first.addressLine}");

注意:
您也可以使用地理定位插件可获取很多有用的信息,例如检索最近的已知位置

NOTE: you can also use geolocation plugin to get a lot of useful information like Retrieving last known location

这篇关于如何从扑中的坐标获取位置名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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