I use OL3 together with geoserver to display one WMS layer. Then I use the GetFeatureInfo to display some of the data on button click. I want to prevent to show the popup when I click outside the layer's features (as shown in the attachment)
How can I do this in OL3? This is the part of the code, which takes care the getFeatureInfo:
map.on('singleclick', function (evt) {
var viewResolution = map.getView().getResolution();
var coord = evt.coordinate;
if (grid_layer.getVisible() && grid_layer.get('name') != 'Basemap') {
var url = grid_layer.getSource().getGetFeatureInfoUrl(coord, viewResolution, 'EPSG:3857', {
'INFO_FORMAT': 'text/html',
'FEATURE_COUNT': '1',
'propertyName': 'url'
});
if (url) {
overlay.setPosition(coord);
content.innerHTML = '<iframe src="' + url + '" style="border:0px #BD8D46 dotted;" scrolling="auto" frameborder="no" align="center"></iframe>';
}
}
});