I have a layer in Geoserver, which I am showing on the HTML webpage using openlayers, but it has a lot of columns,
and I want to show the specific 1-2 columns of the table only " by passing the string of column name ", instead of whole table.
Is there any way possible?
map.on('singleclick', function (evt) {
document.getElementById('info').innerHTML = '';
var myviewResolution = myview.getResolution();
var url = india_dist_rainfall_layer_source.getFeatureInfoUrl(
evt.coordinate,
myviewResolution,
'EPSG:4326',
{'INFO_FORMAT': 'text/html', 'FEATURE_COUNT': '5'},
);
if (url) {
fetch(url)
.then(function (response) { return response.text(); })
.then(function (html) {
document.getElementById('info').innerHTML = html;
});
}
});
You can use the WMS vendor option propertyName
var url = india_dist_rainfall_layer_source.getFeatureInfoUrl(
evt.coordinate,
myviewResolution,
'EPSG:4326',
{'INFO_FORMAT': 'text/html',
'FEATURE_COUNT': '5',
'propertyName': 'forecastDate,rainfall'},
);