我使用的是openlayers 5.1.3,我不知道如何创建点击向量层特性的功能,得到我点击的特性,然后得到它的属性。我在跟踪
this
我找到的唯一相关的例子。
我有一个空的向量源,它在搜索之后获取GeoJSON数据
初始化映射和向量
this.vectorsource = new VectorSource({});
this.vectorlayer = new VectorLayer({
source: this.vectorsource
});
var selectClick = new Select({
condition: click
});
this.olmap.addInteraction(selectClick);
selectClick.on('select', function(e) {
console.log(e.target);
});
搜索之后
this.vectorsource.clear();
const fff = (new GeoJSON()).readFeatures(data.data);
this.vectorsource.addFeatures(fff);
selectClick
和
addInteraction
最接近我想要的。我不知道如何进行,我也不知道这是不是正确的方法组合,以获得我点击的特定功能,所以我可以得到它的属性。还有,奇怪的是我什么也没看到
getFeature
(非复数)矢量层的方法或功能。
我该怎么做?