初步思路:点击“图标变大”按钮,再去点击图标,等图标变大,再去点击“移动”按钮,如果移动结束,则给图标变大点击事件解绑。
代码如下:
//图标变大代码
selectMax(){const _this = thisconst selectClick = new Select()this.map.addInteraction(selectClick)this.closeSelectMaxOn = selectClickconst selectClickOn = ('select',function (e){:const features = Features().getArray()if (features.length>0){let feature = e.selected[0]if (Geometry().getType() !== 'LineString'){_this.currentSelectIcon = featureconst _src = _this.Id()].getImage().getSrc()refeature.setStyle(new Style({image: new Icon({src:_src,scale:0.6,})}))}else{//选中的是线,在此进行其他业务逻辑console.log('选中的不是图标,再次执行逻辑操作');}}})this.selectMaxUn = selectClickOn}
移动事件代码:
moveIcon(){if (this.currentSelectIcon !== null) {const moveIconScale = Id()console.log(moveIconScale);if (moveIconScale !== null){const modifyMove = new Modify({hitDetection:this.vector_Layer,source:this.vector_Source,});this.map.addInteraction(('modifystart', (e) => {const item = e.features.item(0)if (Id() === Id()) {const MoFeature = new Feature()MoFeature.Geometry().clone())MoFeature.GeometryName())MoFeature.Style())MoFeature.ol_uid = item.ol_uidthis.undoStack.push(MoFeature)}})('modifyend',this.closeSelectMax)}
//关闭点击图标变大事件closeSelectMax(){let selectMaxOn = this.closeSelectMaxOnlet closeSelect = this.selectMaxUnlet test = selectMaxOn.pe,closeSelect.listener)
按道理来说应该没有问题,不出意外的话,怕是要出意外了,现在点击图标变大按钮,再去点击图标,图标没有显示样式。卡住了,有没有大佬帮助一下。其他部分代码还是没有问题的,仅供参考。
本文发布于:2024-02-03 23:21:11,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170697411051526.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |