[英]How to highlight the selected feature in open layers 3
Right now i am using this code to zoom to the feature selected by drop down list from geojson database.现在我正在使用此代码缩放到由 geojson 数据库中的下拉列表选择的功能。 now i want to highlight my selected feature.现在我想突出显示我选择的功能。
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());
}
});
}
Please anyone can help me out with this will be greatly appreciated.请任何人都可以帮助我解决这个问题,我们将不胜感激。 Thank you谢谢
If you want to highlight a feature, one way is to create a stroke-style with an other color like this如果要突出显示某个特征,一种方法是使用其他颜色创建笔触样式,如下所示
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.