移动点的样式修改
data(){
return{
changeFeature:null,
map:null
}
},
initMap(){
const map = new Map({
target: 'mapDiv',
view: new View({
center: [, ],
zoom: 19,
// rotation: 100,
projection: '',
}),
controls: defaultControls({
zoom: false,
attribution: false,
rotate: false,
}),
});
this.map = map;
this.map.on('singleclick', this.mapClick);//点击事件
this.map.on('pointermove', this.mapMoveIn);//移入事件
},
mapMoveIn(evt){
if(this.changeFeature){
this.changeFeature.setStyle(new Style({
image: new Icon({
src: require('../../../assets/icons/xxx.png')
})
}))
}
const features = this.map.getFeaturesAtPixel(evt.pixel)
//判断移到点位上时,移到面或是线上不会触发
if(this.map.hasFeatureAtPixel(evt.pixel) && features[0].getGeometry() instanceof Point){
debugger
this.changeFeature = features[0]
features[0].setStyle(new Style({
image:new CircleStyle({
radius:20,
fill:new Fill({
color:'red'
})
})
}))
}else{
}
},