按纬度/经度排序列表
所以,我的网站上有一个谷歌地图。我需要用户能够将地图居中某处,然后我希望在服务器端能够根据地图的可见部分对对象列表(每个对象都有纬度和经度属性)进行排序在前端。这有道理吗?想想 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
计算great_circle_distance,然后按最小数字排序。
calculate the great_circle_distance, then sort by the smallest number.
使用半正矢公式计算大圆距离:
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.
从它的声音来看,您可能希望将图块或您正在检索的任何内容存储在四叉树之类的东西中。然后你可以将坐标传递给服务器,服务器可以为你检索该孔径中可见的物体,对它们进行排序,然后将它们发送回来。
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.