传单标记:PNG 或 base64 图像?

Leaflet markers: PNG or base64 images?

在传单地图上显示大量标记(大约 100 个)的建议是什么?使用 PNG 图像或 base64 图像作为标记图标来显示标记更好吗?

我在传单文档中没有找到任何内容:

https://leafletjs.com/examples/custom-icons/

您想知道为 Leaflet Marker 图标使用外部图像文件与内联 base64 编码图像有什么区别。

使用单独的文件时,浏览器会优化以缓存数据。

当您的图像数据被内联时,它可能会阻止此类优化,我们可以看到浏览器性能下降。查看Leaflet issue #4968性能分析:

When loading a lot of markers (1000, in my case), the performance is noticably worse for base64 inlined images.

[...] for some reason the layer composition is delayed when using inlined images, which makes the whole load take roughly a second longer.

For casual use, this probably doesn't matter, but if you use a lot of markers, this might be relevant.

请注意,一旦您尝试显示超过几百个标记,您就应该考虑使用集群或单个 canvas-based 个标记/图标。