繁体   English   中英

如何在打开的图层中突出显示所选要素 3

[英]How to highlight the selected feature in open layers 3

现在我正在使用此代码缩放到由 geojson 数据库中的下拉列表选择的功能。 现在我想突出显示我选择的功能。

function Zoomto(filter, SearchResultsLayer) {
var schoolname = $('#ddldistrict').val();
//// alert(districtname);
var filter = "schoolname='" + schoolname + "'";
$.ajax({
    url: owsURL,
    type: 'GET',
    contentType: 'application/json',
    dataType: 'jsonp',
    jsonpCallback: "parseResponse",
    data: {
        typeName: layerName,
        outputFormat: "text/javascript",
        service: "WFS",
        version: "1.1.0",
        request: "GetFeature",
        CQL_FILTER: filter

    },
    success: function (response) {

        var SearchResultsLayer = new ol.layer.Vector({
        });

        SearchResultsLayer.setSource(null);

        var searchresultssource = new ol.source.Vector({
            features: (new ol.format.GeoJSON()).readFeatures(response, {
                featureProjection: "EPSG:3857"
            })
        });

        SearchResultsLayer.setSource(searchresultssource);
        map.getView().fit(SearchResultsLayer.getSource().getExtent(), map.getSize());

    }
    });
}

请任何人都可以帮助我解决这个问题,我们将不胜感激。 谢谢

如果要突出显示某个特征,一种方法是使用其他颜色创建笔触样式,如下所示

var style= new ol.style.Style({
             stroke: new ol.style.Stroke({
                 color: 'rgbColor',
                 width: 2,
             }),
             fill : new ol.style.Fill({
                 color: 'rbgbColor',
             })
         });
feature.setStyle(newStyles);
map.render();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM