Google Maps API v3,大量标记、聚类和性能

发布于 2024-10-19 13:46:12 字数 311 浏览 3 评论 0原文

我需要在 Google 地图上渲染大约 5000 个标记。我目前正在使用 API (v3),在速度较慢的机器上存在性能问题,尤其是在 IE 中。我已经完成了以下操作来帮助加快速度:

  1. 使用一个简单的标记类,该类扩展了 OverlayView 并为每个标记渲染单个 DIV 元素
  2. 实现了 MarkerClusterer 库以在不同级别对标记进行聚类
  3. 为 IE 渲染 GIF,而不是 alpha PNG

是否存在更快的聚类类?还有其他提示吗?我试图避免服务器端集群,除非这是挤压系统性能的唯一选择。

谢谢

I have about 5000 markers I need to render on Google Map. I'm currently using the API (v3) and there are performance issues on slower machines, especially in IE. I have done the following already to help speed things up:

  1. Used a simple marker class that extends OverlayView and renders a single DIV element per marker
  2. Implemented the MarkerClusterer library to cluster the markers at different levels
  3. Render GIFs for IE, instead of alpha PNGs

Are there faster clustering classes? Any other tips? I'm trying to avoid server-side clustering unless this is the only option left to squeeze performance out of the system.

Thanks

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

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

发布评论

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

评论(2

贩梦商人 2024-10-26 13:46:12

我使用了一种方法,将所有标记加载到页面上,然后监听地图以完成平移。

当地图完成平移后,我首先检查缩放级别 - 如果太高,我不会显示任何内容。如果它处于可接受的水平,我就会循环遍历我存储的标记,看看它们是否落入地图的边界框中。如果他们这样做了,他们就会被添加。然后,第二个循环将删除所有已移出视图的内容。

我用这种方法最多使用了大约 30,000 个标记,尽管我有它,所以你必须放大很远才能看到它们。在标记浓度较高的区域,速度显然会慢一些,但它是可用的。

I used a method that loads all the markers onto the page, and then listens for the map to finish panning.

When the map has finished panning, I first check the zoom level - if it's too high I don't display anything. If it's at an acceptable level, I then loop through the markers I have stored and see if they fall into the bounding box of the map. If they do, they get added. A second loop then removes any that have moved out of the view.

The highest number I've used is about 30,000 markers with this method, although I have it so you must be zoomed in quite far to see them. In areas of higher concentration of markers it's obviously a little slower but it's useable.

薄情伤 2024-10-26 13:46:12

上述解决方案适用于更多数量的标记。我们将它用于后端数百万个 GPS 点(包括多边形等)。唯一的问题是背后的一些逻辑,例如空间查询的正确缓存,或者仅在用户将地图移动超过 X 米时才获取新结果。要完成它需要做很多工作,但对于查看真正的高点数来说,没有什么比这更好的了。

标记簇通常在浏览器端工作,因此仍然需要一次加载所有点 - 这使得该方法不适用于大量数据。

您可以在 http://www.tixik.com/london-2354567.htm 实时(只需单击“计划旅行”并开始计划。只需尝试移动地图,放大或缩小,所有点都会在地图缩放/拖动时显示/隐藏。

The solution mentioned above works for much higher number of markers. We use it for millions of GPS points at backend (including polygons etc). The only problem is some logic behind like proper caching of spatial queries, or fetching new results only, if user moves a map for more than X meters. There is a lot of work to make it done, but for viewing real high number of points, there is nothing better.

Marker clusteres are usually working at browser side, so these is still need to load all points at once - and this makes this method unusable for large numbers.

You can check it out at http://www.tixik.com/london-2354567.htm live (just click ,,plan a trip " and start planning. Just try to move a map, zoom in or out and all points will show/hide on map zoom/drag.

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