首页 / 浏览问题 / 其他 / 问题详情
点击事件出发后,如何获取对象信息?
8EXP 2020年07月06日
map.addLayer(point);

map.on('click',function(e){

})

如何从额中判断是否点击的是不是添加的point对象,如果是怎么获取point中的属性

1个回答

您好            var vectorSource = new ol.source.Vector({
                features: (new ol.format.GeoJSON()).readFeatures(serviceResult.result.features),
                wrapX: false
            });
            resultLayer = new ol.layer.Vector({
                source: vectorSource
            });
            map.addLayer(resultLayer);
            var iner=new ol.interaction.Select({
        condition: ol.events.condition.pointerMove,     // 唯一的不同之处,设置鼠标移到feature上就选取
        layers: [resultLayer]
        })
                // 添加一个用于选择Feature的交互方式
       map.addInteraction(iner);
 
      iner.on('select',(e)=>{
        console.log(e,'e')
    })
3,352EXP 2020年07月06日
...