GeoBridge

Leaflet 2.0 Beta 发布:更小、更快、更好用的地图库

GIS 前沿3 阅读原文发布 2026/11/3编译收录 2026/11/4

Leaflet 2.0 的开发已进行了一段时间,如今终于迎来了首个 Beta 版本。与之前的 Alpha 版相比,Beta 版在多个方面实现了重大飞跃,包括打包体积、类型支持、性能表现和可访问性等。 最引人注目的改进是 Leaflet 现在完全支持 tree-shaking。这意味着开发者只打包实际用到的代码,一个包含瓦片图层的地图经 gzip 压缩后仅 25.6 kB,相比之前的 38 kB 大幅减小。同时,Leaflet 自带 TypeScript 类型定义,无需额外安装 @types/leaflet,并且代码库基于纯 ES 类构建,更加现代和清晰。 默认标记图标现在可以在任何打包工具下开箱即用,不再需要手动配置图标路径。此外,标记图标还支持颜色和旋转设置,为开发者提供了更多灵活性。 在交互体验上,平移、缩放和渲染都更加平滑和快速。键盘和屏幕阅读器支持也得到了显著改善,使得地图对辅助技术的兼容性更好。

Beta 版还修复了 40 多个 bug,其中包括著名的瓦片间缝隙问题(seams between tiles),这一长期困扰开发者的渲染瑕疵终于得到解决。 Leaflet 一直以其小巧、可靠的特点受到开发者青睐,每当用例合适时,它总是值得回访的选择。无论最终正式版还需多久,看到它一步步走向完善,都令人倍感欣慰。 想要了解完整的更新细节和技术说明,请点击原文链接查看。

编译自 Lat Long Blog,原文链接

原文摘要

The Leaflet 2.0 Beta Just Got Released

Link: github.com Leaflet 2.0 has been in the making for a little while now. Leaflet’s maintainers just released the first beta, detailing some of the major changes and improvements that have been added since the alpha: The first beta of Leaflet 2.0, and a big step up from the alpha. Leaflet is now fully tree-shakeable (a map with a tile layer is 25.6 kB gzipped, down from 38 kB), ships its own TypeScript types, and is built from plain ES classes. The default marker icon now works out of the box with any bundler and can be colored and rotated. Panning, zooming and rendering are smoother and faster, keyboard and screen reader support is much better, and over 40 bugs are fixed, including the infamous seams between tiles. Leaflet has been one of those small, very reliable libraries that I keep going back to whenever the use cases allows it. However long the final release takes, it’s great to see it coming together.