简体   繁体   English

如何使用用户的位置来显示他们附近或半径范围内的信息?

[英]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.

相关问题 仅当用户在指定位置或半径内时,如何显示用户特定的文本? - How do I show the user a certain text only when he/she is within a specified location or radius? 如何计算经度和纬度坐标以创建围绕用户位置1英里半径? - How do I figure out longitude and latitude coordinates to create a 1 mile radius around a user's location? 如何让天气信息默认显示用户当前位置的天气? Openweather map - How can I make the weather information default to display the weather in the user's current location? Openweather map 如何有效地隐藏ClusterManager中不在圆半径范围内的每个标记/簇? - How do I effectively hide every marker/clusters in ClusterManager that is not within a Circle's radius? 在用户位置附近获取位置 - Getting locations near User's Location 想要靠近1KM范围内的位置信息 - Want near by location information within 1KM range 如何在地图上跟踪和显示用户的位置 - How to track and display user's location on a map 如何根据用户当前位置在Google地图上的事件和地点附近显示 - How to display near by events and venues on google map based on user current location 如何在用户位置附近显示兽医 - How to show vets near user location 过滤由于用户当前位置而导致的位置数据库的半径 - Filter a database of locations due to user's current location with radius
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM