Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Marker 新增 overflowHIde 属性,支持控制超出屏幕时是否触发隐藏 #2592

Merged
merged 4 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/gentle-teachers-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@antv/l7-component': patch
---

feat: Marker 新增 overflowHIde 属性,支持控制超出屏幕时是否触发隐藏
Binary file modified __tests__/integration/snapshots/gallery_fujian.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __tests__/integration/snapshots/point_text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions packages/component/src/marker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default class Marker extends EventEmitter {
offsets: [0, 0],
color: '#5B8FF9',
draggable: false,
overflowHide: true,
};
}

Expand Down Expand Up @@ -348,9 +349,11 @@ export default class Marker extends EventEmitter {
pos.x = newPos.x;
}
}
// 不在当前可视区域内隐藏点
if (pos.x > containerWidth || pos.x < 0 || pos.y > containerHeight || pos.y < 0) {
element.style.display = 'none';
if (this.markerOption.overflowHide) {
// 不在当前可视区域内隐藏点
if (pos.x > containerWidth || pos.x < 0 || pos.y > containerHeight || pos.y < 0) {
element.style.display = 'none';
}
}

element.style.left = pos.x + offsets[0] + 'px';
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/services/component/IMarkerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface IMarkerOption {
color: string;
offsets: number[];
draggable: boolean;
overflowHide?: boolean;
extData?: any;
style?: CSSStyleDeclaration;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/maps/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export {
GaodeMapV2,
GoogleMap,
Map,
Mapbox,
MapLibre,
MapType,
Mapbox,
TMap,
TencentMap,
TMap,
};
1 change: 1 addition & 0 deletions site/docs/api/component/marker.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Marker
- element    `DOM|string`    自定义 marker DOM 节点,可以是 dom 实例,也可以是 dom id
- anchor     `string`  锚点位置   支持 center, top, top-left, top-right, bottom, bottom-left,bottom-right,left, right
- offsets    `Array`  偏移量  [ 0, 0 ] 分别表示 X, Y 的偏移量
- overflowHide   `boolean`  超出屏幕时是否隐藏 Marker,默认为 true
- draggable `boolean` 是否支持拖拽调整 Marker 位置
- extData 用户自定义属性,支持任意数据类型,存储 marker 属性信息

Expand Down
Loading