my-openlayer 2.1.8 → 2.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/Point.d.ts +1 -0
- package/core/VueTemplatePoint.d.ts +1 -0
- package/core/VueTemplatePoint.js +16 -3
- package/package.json +1 -1
package/core/Point.d.ts
CHANGED
|
@@ -88,6 +88,7 @@ export default class Point {
|
|
|
88
88
|
stopEvent?: boolean;
|
|
89
89
|
}): {
|
|
90
90
|
setVisible: (visible: boolean) => void;
|
|
91
|
+
setOneVisibleByProp: (propName: string, propValue: any, visible: boolean) => void;
|
|
91
92
|
remove: () => void;
|
|
92
93
|
getPoints: () => VueTemplatePointInstance[];
|
|
93
94
|
};
|
|
@@ -25,6 +25,7 @@ export default class VueTemplatePoint {
|
|
|
25
25
|
stopEvent?: boolean;
|
|
26
26
|
}): {
|
|
27
27
|
setVisible: (visible: boolean) => void;
|
|
28
|
+
setOneVisibleByProp: (propName: string, propValue: any, visible: boolean) => void;
|
|
28
29
|
remove: () => void;
|
|
29
30
|
getPoints: () => VueTemplatePointInstance[];
|
|
30
31
|
};
|
package/core/VueTemplatePoint.js
CHANGED
|
@@ -96,10 +96,10 @@ export default class VueTemplatePoint {
|
|
|
96
96
|
lgtd: pointData.lgtd,
|
|
97
97
|
lttd: pointData.lttd,
|
|
98
98
|
props: {
|
|
99
|
-
pointData: {
|
|
99
|
+
pointData: isVue3 ? {
|
|
100
100
|
type: Object,
|
|
101
101
|
default: pointData
|
|
102
|
-
}
|
|
102
|
+
} : pointData
|
|
103
103
|
},
|
|
104
104
|
positioning: options?.positioning,
|
|
105
105
|
stopEvent: options?.stopEvent,
|
|
@@ -114,6 +114,14 @@ export default class VueTemplatePoint {
|
|
|
114
114
|
instance.setVisible(visible);
|
|
115
115
|
});
|
|
116
116
|
},
|
|
117
|
+
setOneVisibleByProp: (propName, propValue, visible) => {
|
|
118
|
+
instances.forEach((instance) => {
|
|
119
|
+
const pointData = isVue3 ? instance.options.props.pointData.default : instance.options.props.pointData;
|
|
120
|
+
if (pointData[propName] === propValue) {
|
|
121
|
+
instance.setVisible(visible);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
},
|
|
117
125
|
remove: () => {
|
|
118
126
|
instances.forEach((instance) => {
|
|
119
127
|
instance.remove();
|
|
@@ -256,6 +264,8 @@ class VueTemplatePointInstanceImpl {
|
|
|
256
264
|
if (!Vue) {
|
|
257
265
|
throw new Error('Vue is not available. Please ensure Vue is installed in your project.');
|
|
258
266
|
}
|
|
267
|
+
// 清空DOM内容,确保没有残留
|
|
268
|
+
this.dom.innerHTML = '';
|
|
259
269
|
try {
|
|
260
270
|
if (isVue3) {
|
|
261
271
|
// Vue 3
|
|
@@ -267,8 +277,11 @@ class VueTemplatePointInstanceImpl {
|
|
|
267
277
|
}
|
|
268
278
|
else {
|
|
269
279
|
// Vue 2
|
|
280
|
+
// 创建一个临时容器挂载 Vue,避免 this.dom 被替换
|
|
281
|
+
const mountPoint = document.createElement('div');
|
|
282
|
+
this.dom.appendChild(mountPoint);
|
|
270
283
|
this.app = new Vue({
|
|
271
|
-
el:
|
|
284
|
+
el: mountPoint,
|
|
272
285
|
render: (h) => h(Template, { props: props || {} })
|
|
273
286
|
});
|
|
274
287
|
}
|