我正在构建一个Web地图,其中有些图层是从Geoserver导入的。我已经将它们转换为向量JSON。我想在HTML面板中在地图之外显示几何的所有特征。
我只可以使用.get方法使用的一个功能'obra_nro'来做到这一点。您可以在下面查看我正在使用的代码。
但是,我仍然找不到显示其余功能的方法。
谢谢您的任何建议。
var selectInteraction = new ol.interaction.Select({
hitTolerance:1 ///// Precision del puntero del mouse para seleccionar
});
olMap.getInteractions().extend([selectInteraction]);
var displayFeatureInfo = function(pixel) {
var features = [];
olMap.forEachFeatureAtPixel(pixel, function(feature, layer) {
features.push(feature);
});
var container = document.getElementById('description');
if (features.length > 0) {
var info = [];
for (var i = 0, ii = features.length; i < ii; ++i) {
info.push(features[i].get('obra_nro'));
}
container.innerHTML = info.join(', ') || '(unknown)';
} else {
container.innerHTML = ' ';
}
};
olMap.on('click' , function(evt) {
var pixel = evt.pixel;
displayFeatureInfo(pixel);
});