|
@@ -64,28 +64,39 @@ class SamplePointLayer {
|
|
|
|
|
|
this.addMapSingerClick(map.map);
|
|
this.addMapSingerClick(map.map);
|
|
|
|
|
|
|
|
+ // 对比
|
|
this.isCompare = false
|
|
this.isCompare = false
|
|
|
|
+ this.comparePointArr = []
|
|
eventBus.off("compareTree")
|
|
eventBus.off("compareTree")
|
|
eventBus.on("compareTree", (val) => {
|
|
eventBus.on("compareTree", (val) => {
|
|
that.isCompare = val
|
|
that.isCompare = val
|
|
|
|
+ if (val === false) {
|
|
|
|
+ that.comparePointArr.map(fs => {
|
|
|
|
+ fs.set("activeCompare", false)
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ eventBus.off("closeCompare")
|
|
|
|
+ eventBus.on("closeCompare", () => {
|
|
|
|
+ that.comparePointArr.map(fs => {
|
|
|
|
+ fs.set("activeCompare", false)
|
|
|
|
+ });
|
|
})
|
|
})
|
|
|
|
|
|
-
|
|
|
|
- eventBus.off("resetCompare", () => {})
|
|
|
|
- eventBus.on("resetCompare", (data) => {
|
|
|
|
- console.log('dddd reset', data);
|
|
|
|
- // data[0].set("activeCompare", true);
|
|
|
|
- })
|
|
|
|
- // eventBus.on("closeCompare", () => {
|
|
|
|
-
|
|
|
|
- // })
|
|
|
|
|
|
+ // 果园档案
|
|
|
|
+ eventBus.off("change:mapPoint")
|
|
|
|
+ eventBus.on("change:mapPoint", (name) => {
|
|
|
|
+ console.log('name', name);
|
|
|
|
+ })
|
|
|
|
+ that.blueRegionLayer = null
|
|
}
|
|
}
|
|
getIconStyle(feature){
|
|
getIconStyle(feature){
|
|
|
|
+ const activeCompare = feature.get('activeCompare')
|
|
let style = new Style({
|
|
let style = new Style({
|
|
image: new Icon({
|
|
image: new Icon({
|
|
- src: feature.get('activeCompare') ? require('@/assets/images/map/active-icon-small.png') : feature.get('icon'),
|
|
|
|
|
|
+ src: activeCompare ? require('@/assets/images/map/active-icon-small.png') : feature.get('icon'),
|
|
// src: require(`@/assets/images/map/${feature.get('iconName')}-icon.png`),
|
|
// src: require(`@/assets/images/map/${feature.get('iconName')}-icon.png`),
|
|
- scale:feature.get('scale'),
|
|
|
|
|
|
+ scale: activeCompare ? 0.5 : feature.get('scale'),
|
|
})
|
|
})
|
|
});
|
|
});
|
|
return style
|
|
return style
|
|
@@ -133,6 +144,33 @@ class SamplePointLayer {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+toggleFilePoint(arr) {
|
|
|
|
+ let that = this
|
|
|
|
+ // 清除旧的 blueRegionLayer 图层
|
|
|
|
+ that.clearCluster()
|
|
|
|
+ if (that.blueRegionLayer) {
|
|
|
|
+ that.blueRegionLayer.source.clear();
|
|
|
|
+ }
|
|
|
|
+ if(arr&&arr.length>0){
|
|
|
|
+ let features = []
|
|
|
|
+ for(let item of arr){
|
|
|
|
+ item.iconName='defalut'
|
|
|
|
+ that.getIcon(item)
|
|
|
|
+ let point = newPoint(item);
|
|
|
|
+ features.push(point)
|
|
|
|
+ // console.log('item.dyImg',item.dyImg);
|
|
|
|
+ }
|
|
|
|
+ const source = new VectorSource({
|
|
|
|
+ features: features,
|
|
|
|
+ });
|
|
|
|
+ that.clusterSource.setSource(source)
|
|
|
|
+ setTimeout(()=>{
|
|
|
|
+ that.mapRef.fit(that.clusterSource.source.getExtent(), {padding:[100,100,100,100]})
|
|
|
|
+ },100)
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
addMapSingerClick(kmap){
|
|
addMapSingerClick(kmap){
|
|
let that = this
|
|
let that = this
|
|
kmap.on("singleclick", (evt) => {
|
|
kmap.on("singleclick", (evt) => {
|
|
@@ -144,7 +182,10 @@ class SamplePointLayer {
|
|
that.curPoint.set("iconName", "defalut");
|
|
that.curPoint.set("iconName", "defalut");
|
|
}
|
|
}
|
|
const featureArr = feature.get("features")
|
|
const featureArr = feature.get("features")
|
|
- const fs = featureArr[0]
|
|
|
|
|
|
+ let fs = featureArr[0]
|
|
|
|
+ for(let item of featureArr){
|
|
|
|
+ fs = fs.get('status') > item.get('status') ? fs : item
|
|
|
|
+ }
|
|
that.curPoint = fs
|
|
that.curPoint = fs
|
|
if(that.isUpdatePoint){
|
|
if(that.isUpdatePoint){
|
|
fs.set("iconName", "active");
|
|
fs.set("iconName", "active");
|
|
@@ -153,9 +194,21 @@ class SamplePointLayer {
|
|
if (!that.isCompare) {
|
|
if (!that.isCompare) {
|
|
eventBus.emit("click:point",{farmId:fs.get("farmId"),sampleId:fs.get("sampleId"), data: fs.getProperties()})
|
|
eventBus.emit("click:point",{farmId:fs.get("farmId"),sampleId:fs.get("sampleId"), data: fs.getProperties()})
|
|
} else {
|
|
} else {
|
|
- fs.set("activeCompare", true);
|
|
|
|
- fs.set("icon", require('@/assets/images/map/active-icon-small.png'));
|
|
|
|
- eventBus.emit("clickToCompare:point",{farmId:fs.get("farmId"),sampleId:fs.get("sampleId"), data: fs.getProperties()})
|
|
|
|
|
|
+ // fs.set("iconName", "active")
|
|
|
|
+ fs.set("activeCompare", fs.get("activeCompare") ? false : true);
|
|
|
|
+ if (fs.get("activeCompare")) {
|
|
|
|
+ that.comparePointArr.push(fs)
|
|
|
|
+ } else {
|
|
|
|
+ that.comparePointArr = that.comparePointArr.filter(item => item.get("id") !== fs.get("id"))
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (that.comparePointArr.length > 2) {
|
|
|
|
+ that.comparePointArr[0].set("activeCompare", false);
|
|
|
|
+ that.comparePointArr.shift();
|
|
|
|
+ }
|
|
|
|
+ console.log('that.comparePointArr', that.comparePointArr);
|
|
|
|
+ // fs.set("icon", require('@/assets/images/map/active-icon-small.png'));
|
|
|
|
+ eventBus.emit("clickToCompare:point",that.comparePointArr)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (layer instanceof VectorLayer && layer.get("name") === "yellow-block") {
|
|
if (layer instanceof VectorLayer && layer.get("name") === "yellow-block") {
|
|
@@ -185,8 +238,10 @@ class SamplePointLayer {
|
|
|
|
|
|
resetPoint(){
|
|
resetPoint(){
|
|
this.isUpdatePoint = null
|
|
this.isUpdatePoint = null
|
|
|
|
+ console.log('this.curPoint', this.curPoint);
|
|
if(this.curPoint){
|
|
if(this.curPoint){
|
|
- this.curPoint.set("iconName", "defalut");
|
|
|
|
|
|
+ // this.curPoint.set("iconName", "defalut");
|
|
|
|
+ this.curPoint.set("activeCompare", false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -237,12 +292,6 @@ class SamplePointLayer {
|
|
this.treeClusterLayer.layer.getSource().getSource().clear()
|
|
this.treeClusterLayer.layer.getSource().getSource().clear()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- // 对比树
|
|
|
|
- toggleCompareTree() {
|
|
|
|
- let that = this
|
|
|
|
- that.isCompare = true
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
export default SamplePointLayer;
|
|
export default SamplePointLayer;
|