openlayers,实现点击图标,图标变大,再点击移动按钮,方可移动,移动的过程中点击其他图标不可变大。

阅读: 评论:0

openlayers,实现点击图标,图标变大,再点击移动按钮,方可移动,移动的过程中点击其他图标不可变大。

openlayers,实现点击图标,图标变大,再点击移动按钮,方可移动,移动的过程中点击其他图标不可变大。

初步思路:点击“图标变大”按钮,再去点击图标,等图标变大,再去点击“移动”按钮,如果移动结束,则给图标变大点击事件解绑。

代码如下:

//图标变大代码
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 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23