ArcGIS API for JavaScript 4.x 加载大量数据会卡顿

背景

 有个项目,本来数据量就几千条点位数据,现在搞到了一万多条,据说后期要五六万条,加载图标要40s以上,并且放大缩小的操作会导致(部分/全部)图标消失,这正常人都受不了。

环境

 Win10

Chrome

ArcGIS API for JavaScript 4.18   Mapview  FeatureLayer

ArcGIS Server 10.4.1

问题

 在背景中有交代过,另外图标还有残缺的情况

尝试过程

 在网上搜了好久,有说可以开启WebGL,但后来看别的地方说4.x(具体从哪个版本开始已经记不清)默认就是WebGL。

还有一种方法就是用canvas:一种大数据渲染方法,看文章说加载百万级的都没问题。

 这块资料很少,能做的就是这个。

解决方案

 FeatureLayer是用arcgis server发布的,所以才慢。经过查找用GeoJsonLayer会快好多(Best/fastest way to display very large datasets in the ArcGIS JS API?)。

 我看到里面的一个人的评论说可以用PostGIS来实现区域加载,这个后续可以尝试。

I know this is an old post, but just adding my comments here in case it helps someone.  I often work with large GeoJSON datasets with Esri's JS API.  The very first thing I do is try to reduce the size of my GeoJSON file.  The easiest way to do this is normally by reducing the number of vertices in the features.  There are various ways to do this using Esri software.  If you don't have Esri software, you can use mapshaper.  This can reduce a 100MB GeoJSON file down to only 1MB without losing too much feature definition.  If the file is still not small enough, then you can decrease the precision of the coordinates, e.g. 12.34522153234 becomes 12.3.  This may make no difference to the how the data looks but can easily halve the file size.  To decrease the precision, I use Python, although this could be done easily via JavaScript if needed.  The other option that I looked at when my data was too big was using Postgres and only requesting the data in the current map extent (how normal ArcGIS Server map services work).  This worked fine.

翻译:

  我知道这是一篇旧帖子,但只是在此处添加我的评论,以防它对某人有所帮助。我经常使用 Esri 的 JS API 处理大型 GeoJSON 数据集。我做的第一件事就是尝试减小我的 GeoJSON 文件的大小。最简单的方法通常是减少要素中的顶点数。使用 Esri 软件可以通过多种方式完成此操作。如果您没有 Esri 软件,则可以使用 mapshaper。这可以将 100MB 的 GeoJSON 文件减少到仅 1MB,而不会丢失太多的功能定义。如果文件仍然不够小,那么您可以降低座标的精度,例如12.34522153234 变成 12.3。这可能对数据的外观没有影响,但可以轻松地将文件大小减半。为了降低精度,我使用 Python,尽管如果需要,这可以通过 JavaScript 轻松完成。当我的数据太大时,我查看的另一个选项是使用 Postgres 并且只请求当前地图范围内的数据(ArcGIS Server 地图服务的正常工作方式)。这工作得很好。

参考网址

要素图层性能提升

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章