fix: 修复天地图图层被覆盖的问题 (#2852)#2856
Conversation
|
There was a problem hiding this comment.
Code Review
This pull request updates the TdtMapService in packages/maps/src/tdtmap/map.ts to set the CSS position of the layer container, aiming to resolve an issue where the layer was being obscured. The reviewer suggests using absolute positioning instead of relative to ensure consistency with existing methods like addMarkerContainer and to prevent potential layout interference with other map elements.
| overlayPane.parentElement.appendChild(container); | ||
| container.id = 'tdt-L7'; | ||
| const size = this.map.getSize(); | ||
| container.style.position = 'relative'; // 修复天地图图层被覆盖的问题 |
There was a problem hiding this comment.
建议将 position 设置为 absolute 而不是 relative。
- 一致性:该类中的
addMarkerContainer方法(第 42 行)也使用了absolute定位,保持一致性有助于代码维护。 - 布局稳定性:在地图容器中,使用
absolute定位可以确保图层容器脱离文档流,避免对地图的其他子元素(如控件、比例尺等)产生潜在的布局挤压影响。 - 通用实践:对于需要通过
transform进行精确定位的地图覆盖物容器,使用absolute是更通用的做法。
| container.style.position = 'relative'; // 修复天地图图层被覆盖的问题 | |
| container.style.position = 'absolute'; // 修复天地图图层被覆盖的问题 |
修复 Issue #2852: 天地图的组件被地图覆盖
问题原因
解决方案
测试
请验证天地图示例中 PointLayer 等图层能够正常显示在地图上方,不再被地图覆盖。
Reference: #2852
🤖 Generated with WeaveFox