如何在开放层中显示矢量的几个特征?

问题描述 投票:1回答:1

我正在构建一个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 = '&nbsp;';
        }   
    };

    olMap.on('click' , function(evt) {
        var pixel = evt.pixel;
        displayFeatureInfo(pixel);
    });
openlayers
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.