Skip to content

Commit 83d37c0

Browse files
committed
feat(map): 子图切换逻辑优化
1 parent 6702aed commit 83d37c0

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ export default {
9494
是否允许通过控制条切换子图,默认不允许。
9595
只有在`show-toolbar`为`true`、当前地图存在多个子图且没有通过`lock-sub-id`锁定子图时,才会展示左右切换按钮。
9696
97+
### auto-switch-sub-by-points
98+
99+
是否允许组件根据传入点位自动推断子图,默认允许。
100+
如果业务侧会临时隐藏、筛选或清空点位,但不希望当前子图因此改变,可以设为`false`。
101+
97102
## 事件
98103
99104
### map-move

src/components/Map.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ export default {
123123
type: Boolean,
124124
default: false,
125125
},
126+
autoSwitchSubByPoints: {
127+
type: Boolean,
128+
default: true,
129+
},
126130
},
127131
data: () => ({
128132
outerWidth: 0,
@@ -222,6 +226,7 @@ export default {
222226
if (!scales || this.subMaps.length <= 1) return 0;
223227
if (this.lockSubId != -1) return this.lockSubId;
224228
if (this.selectedSubId != null && scales[this.selectedSubId]) return this.selectedSubId;
229+
if (!this.autoSwitchSubByPoints) return 0;
225230
let _sub = 0;
226231
let _subScale = 0;
227232
for (let sub in scales) {
@@ -343,6 +348,7 @@ export default {
343348
};
344349
},
345350
isPointsInRect(rect) {
351+
if (!this.datas.length) return false;
346352
let points = this.datas.map((p) => {
347353
return {
348354
x: p.x,

0 commit comments

Comments
 (0)