mapbox 右键监听
rightMouseMenu(){
var rightMenu = new SFMap.RightMenuControl({
className: 'sfmap-ctrl-rightmenu-custom',
// 菜单内容
menuItems: [
{
id: '01',
content: '<span>添加事件单条</span>',
link_id:this.sw_id
},
{
id: '02',
content: '<span>添加事件多条</span>',
link_id:this.sw_id
},
],
});
window.map.addControl(rightMenu);
// 监听点击事件
window.map.on('rightmenu.show', function(data) {
console.log('菜单显示', rightMenu);
const features = window.map.queryRenderedFeatures(data.point, {
layers: ['SHAPE'],
})
console.log('features', features);
if(features&&features.length>0){
// this.sw_id=features[0].properties.sw_id
this.sw_id=features[0].properties.sw_id
}else{
this.sw_id=""
}
console.log('rightMenu', rightMenu);
});
window.map.on('rightmenu.update', function(data) {
console.log('菜单刷新', data);
});
window.map.on('rightmenu.hide', function() {
console.log('菜单隐藏');
});
window.map.on('rightmenu.click', (menuItem)=> {
console.log('菜单点击', menuItem);
console.log("sw_id",menuItem.target.sw_id)
console.log("this.sw_id",this.sw_id)
if( menuItem.target.sw_id){ this.$emit("rightMenuClick",[menuItem.target.sw_id])}else{
this.$message.info("未选中shape线")
}
// this.isAddEventOneOrMore=true;
// this.linkedIdArr=[menuItem.target.sw_id]
});
}
this.sw_id是需要的数据
如果有其他的数据,可以按照sw_id 的格式新增