在Firefox浏览器上,如何使用传单运行来修复地图非常慢 [英] How to fix map using leaflet run is very slow on Firefox browser

查看:94
本文介绍了在Firefox浏览器上,如何使用传单运行来修复地图非常慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用leaflet创建地图,它在Chrome中运行良好,但在Fifefox中却无法运行.在Firefox中,地图运行非常缓慢. 这是我的演示. 如何解决.

I create a map using leaflet, it runs fine in Chrome but it not in Fifefox. In Firefox, the map run's very slow. This is my demo. How to fix it.

推荐答案

由于需要绘制多边形,因此浏览器速度变慢.根据几何图形的规模和复杂性,绘制整个美国(超过3000个)的县界可能会给浏览器资源造成很大的负担.通过注释insertCountyData方法,请参见性能提高.

The browser is slowed due to the amount of polygons that it is required to draw. Depending on the scale and complexity of the geometry, drawing county boundaries for the entire US (over 3000) can be quite taxing on browser resources. See the performance increase by commenting out the insertCountyData method.

 //  insertCountyData();

我建议实施另一种类型的策略,以减少浏览器需要呈现的数据量.下面我列出了一些策略,前两个策略用于减少一次渲染的县数量.

I would suggest implementing a different type of strategy that reduces the amount of data that the browser needs to render. Below I have listed a few strategies, the first two deal with reducing the amount of counties that are rendered at one time.

另一种选择是在用户单击时将县添加到特定状态.这样可以减少需要渲染的多边形总数.

Another option would be to add counties to a specific state when the user clicked on it. This would reduce the overall amount of polygons needed to be rendered.

使用 TileMill 呈现数据.请参阅之前已回答的StackOverflow问题,这实际上非常相似.

Render the data using TileMill. See this StackOverflow question previously answered, which is actually quite similar.

减少将GeoJSON转换为TopoJSON所加载的数据量.

我希望这会有所帮助.客户端渲染大量多边形可能会很麻烦,使用这些不同的策略可以帮助缓解性能问题.

I hope this helps. Client-side rendering of large amounts of polygons can be quite taxing and using these different strategies can help alleviate performance issues.

这篇关于在Firefox浏览器上,如何使用传单运行来修复地图非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆