按纬度/经度排序列表

发布于 2024-10-30 21:25:55 字数 241 浏览 3 评论 0原文

所以,我的网站上有一个谷歌地图。我需要用户能够将地图居中某处,然后我希望在服务器端能够根据地图的可见部分对对象列表(每个对象都有纬度和经度属性)进行排序在前端。这有道理吗?想想 Yelp.com 根据用户可以放大/缩小的地图对餐馆进行排序的方式。

因此,首先列表将根据纬度/经度属性删除不在地图区域中的任何对象,然后根据最接近地图中心的对象对剩余对象进行排序。

为此,我必须从前端将什么传递到服务器,一旦它到达服务器,我将如何进行排序?

So, I have a google map on my website. I need the user to be able to center the map somewhere, and then I want on my server side, to be able to sort a list of objects (that each have a lat and long property), based on the visible portion of the map on the front end. Does this make sense? Think the way Yelp.com sorts restaurants based on the map users can zoom in/out of.

So first the list would get rid of any objects that aren't in the region of the map based on their lat/long properties, and then it would sort the remaining based on which ones are closest to the center of the map.

To do this, what would I have to pass to the server from the front end, and once it's on the server, how would I do this sorting?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦纸 2024-11-06 21:25:55

计算great_circle_distance,然后按最小数字排序。

calculate the great_circle_distance, then sort by the smallest number.

沦落红尘 2024-11-06 21:25:55

使用半正矢公式计算大圆距离:

http://en.wikipedia.org/wiki/Haversine_formula< /a>

然后排序,距离最短(=最近)在前。

Use the Haversine Formula to calculate the great circle distance:

http://en.wikipedia.org/wiki/Haversine_formula

Then sort, with the shortest distance (=closest) first.

杯别 2024-11-06 21:25:55

从它的声音来看,您可能希望将图块或您正在检索的任何内容存储在四叉树之类的东西中。然后你可以将坐标传递给服务器,服务器可以为你检索该孔径中可见的物体,对它们进行排序,然后将它们发送回来。

From the sound of it, you may want to store the tiles or whatever you are retrieving in something like a quadtree. Then you can pass the coordinates to the server, the server can retrieve the objects visible in that aperture for you, sort them, then send them back.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文