Reputation: 289
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;
});
}
});
Upvotes: 2
Views: 1129
Reputation: 10976
You could request the data in another format (e.g. JSON) and process it in your own code to give exactly the format that you need.
Alternatively, you could create a FreeMarker template to customise the HTML output.
Upvotes: 1
Reputation: 17906
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'},
);
Upvotes: 2