Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/maps/src/tdtmap/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export default class TdtMapService extends BaseMapService<any> {
overlayPane.parentElement.appendChild(container);
container.id = 'tdt-L7';
const size = this.map.getSize();
container.style.position = 'relative'; // 修复天地图图层被覆盖的问题

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

建议将 position 设置为 absolute 而不是 relative

  1. 一致性:该类中的 addMarkerContainer 方法(第 42 行)也使用了 absolute 定位,保持一致性有助于代码维护。
  2. 布局稳定性:在地图容器中,使用 absolute 定位可以确保图层容器脱离文档流,避免对地图的其他子元素(如控件、比例尺等)产生潜在的布局挤压影响。
  3. 通用实践:对于需要通过 transform 进行精确定位的地图覆盖物容器,使用 absolute 是更通用的做法。
Suggested change
container.style.position = 'relative'; // 修复天地图图层被覆盖的问题
container.style.position = 'absolute'; // 修复天地图图层被覆盖的问题

container.style.zIndex = '200'; //置于上层
container.style.width = `${size.x}px`;
container.style.height = `${size.y}px`;
Expand Down
Loading