[Bug] Map is distorted when reuseMaps is true

未关闭
#2,578 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
react, typescript
领域
frontend, web-dev

调研方向

从链接的 CodeSandbox 复现开始,使用 [email protected] 和 Map library 3.18.0;添加所需的 Mapbox token,并在平移和缩放后按照 reuseMaps 的 unmount/remount 路径操作。比较 remount 前后的地图渲染,然后验证重复切换不再使地图变形或阻止图块加载。

由索引模型根据 Issue 内容生成。

描述

bug
Description

The map renders correctly on the initial load (see Image 1). However, the map becomes distorted or fails to load tiles properly (see Image 2) when the component is unmounted and remounted while the reuseMaps property is enabled. It appears as though the map container dimensions or tile coordinates are not being recalculated correctly upon re-insertion into the DOM.

The issue can be reproduced here (the mapbox token need to add): https://codesandbox.io/p/sandbox/reactjs-playground-forked-n5nfrk

Image Image
Expected Behavior

The map must work well even after remount with reuseMap as true

Steps to Reproduce
  • Load the map and perform pan (drag) and zoom actions.
  • Click the "Toggle Map" button to unmount the component.
  • Click the "Toggle Map" button again to remount the component.
  • Observe the distorted map. (Note: If it doesn't happen immediately, repeat the steps 2-3 times, ensuring you interact with the map between toggles).

The issue can be reproduced here (the mapbox token need to add): https://codesandbox.io/p/sandbox/reactjs-playground-forked-n5nfrk

Environment
Logs

No response

主要语言
TypeScript
星标
8.5k
派生
1.3k
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

visgl/react-map-gl 的其他 Issue

查看 visgl/react-map-gl 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。