如何使用 javascript 对经纬度点的显示进行排序或切换(基于邻近度)
我想获取经纬度点的列表,并根据它们的接近程度对它们的显示进行排序/切换。理想情况下,我想在客户端执行此操作。 例如,我经常看到根据当前地图的视图更新列表的地图。看起来,当您移动地图或更改地图的缩放时,它会对每个更改进行单独的查询并更新结果。在我看来,加载更大的值集,然后根据地图缩放切换可见性和顺序会更有效。我想知道是否有人有这样做的技术,或者是否有人曾经使用 javascript 尝试过这样做。
I want to take a list of lat lon points and sort / toggle their display based on their proximity. Ideally, I would like to do this on the client side.
For instance, I often see maps that update a list based on the view of the current map. It appears that as you move the map or change the zoom of the map, it makes a separate query on every change and updates the results. It seems to me much more efficient to load a larger set of values, and then toggle the visibility and order based on the map zoom. I'm wondering if anyone has a technique for doing this or if anyone has ever attempted this using javascript.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您加载了很多标记,那么为什么要隐藏它们而不是一直显示它们呢?至于缩放,您可以使用 标记聚类器。您建议的另一个解决方案需要您对标记进行空间查询(并且可能自己实现逻辑,因为我不知道有什么方法可以做到根据地图视口在客户端上使用 api)。
是的,这可能会更有效,但问题是您如何知道用户将探索哪些部分,以便您可以预取标记?
干杯
If you load a lot of markers than why hide them and not show them the whole time?As for the zoom you can use a marker clusterer.The other solution you are suggesting requires you to spatial query the markers(and probably implement the logic by yourself since i don't know any way that it can be done with the api) on the client according to the map viewport.
Yes it would probably be more efficient but the question is how would you know which portions the user will explore so you can prefetch the markers?
Cheers