如何在开放层 3 中获得要素层?
过去版本的开放图层在每个要素上都有一个图层属性。这使得将特定于图层的样式应用于功能或按图层组织功能变得容易。
开放层 3 缺少此属性。我正在使用ol.map.forEachFeatureAtPixel来获取悬停功能。
// Loop through all features a given pixel
var feature = map.forEachFeatureAtPixel(pixel, function(feature, layer) {
console.log(layer);
return feature; // just return the first feature
});