[英]How do I use a user's location to display information that is near them or in a radius within?
I'm building an app that has people request something, so a user should only receive requests that are near to them or within a certain radius.我正在构建一个让人们请求某些东西的应用程序,因此用户应该只接收靠近他们或在一定半径内的请求。 How do I achieve this on flutter?
如何在 flutter 上实现这一点?
You need to have real time data on coordinates of person/people who is fulfilling the request.您需要获得有关满足请求的人的坐标的实时数据。 And when a request is made by the user, fetch the user's current coordinates and based on that coordinate filter the coordinates of person/people fulfilling the request depending on the specifies radius
当用户提出请求时,获取用户的当前坐标,并根据该坐标过滤根据指定半径完成请求的人/人的坐标
There's a formula to calculate the distance between two coordinates有一个公式可以计算两个坐标之间的距离
Distance, d = 3963.0 * arccos[(sin(lat1) * sin(lat2)) + cos(lat1) * cos(lat2) * cos(long2 – long1)]
But to use the formula you need convert the latitude and longitude values from decimal degrees to radians.但是要使用该公式,您需要将纬度和经度值从十进制度转换为弧度。 For this divide the values of longitude and latitude of both the points by 180/pi.
为此,将两个点的经度和纬度值除以 180/pi。 The value of pi is 22/7.
pi 的值为 22/7。 The value of 180/pi is approximately 57.29577951.
180/pi 的值约为 57.29577951。 If we want to calculate the distance between two places in miles, use the value 3, 963, which is the radius of Earth.
如果我们想以英里为单位计算两地之间的距离,请使用值 3,963,即地球的半径。 If we want to calculate the distance between two places in kilometers, use the value 6, 378.8, which is the radius of Earth.
如果我们想以公里为单位计算两地之间的距离,请使用值 6,378.8,即地球的半径。 You'll get the approximate distance.
你会得到大概的距离。
OR或者
You can use api like google map, this is the link for more info您可以使用 api 像谷歌 map, 这是更多信息的链接
this is google map package link that you can use in the flutter app for the same purpose.这是google map package 链接,您可以在 flutter 应用程序中使用该链接用于相同目的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.