@vis.gl/react-maplibre 中的 DEFAULT_SETTINGS.maxBounds 具有 360°的经度范围,通过 _updateSettings 回退函数触发 maplibre-gl-js#6148 程序崩溃
作者: 4nrry创建于 2026年5月13日更新于 2026年5月13日
这里提交,因为
visgl/react-maplibre已被归档,并指向此单库。问题出现在发布的@vis.gl/[email protected]中(也可通过[email protected]的/maplibre项访问)。
概要
DEFAULT_SETTINGS.maxBounds 硬编码为 [-180, -85.051129, 180, 85.051129],其经度范围为 精确为 360°。当 _updateSettings 回退到此默认值(当 maxBounds 键只存在于 nextProps 或 currProps 中之一时)时,它会在底层 maplibre 实例上调用 map.setMaxBounds([-180, -85.05, 180, 85.051129])。由于经度范围覆盖了整个世界,上游问题 maplibre/maplibre-gl-js#6148 就会触发:投影矩阵变成奇异且不可逆的,抛出:
TypeError: Cannot read properties of null (reading '0')(Firefox:can't access property 0, i is null)
堆栈信息
内容来源: visgl/react-map-gl