I am projecting a WMS layer on a map using OpenLayers and Geoserver. The next thing I want to do is to display info on any given feature in my WMS-layer in a pop up whenever a user clicks it.
This is all working fine, but my problem is that whenever I click outside the WMS layer, I get an empty pop up. However, I only want a pop up to appear when a user clicks an actual feature.
Does anyone know how to fix this?
Code:
info = new OpenLayers.Control.WMSGetFeatureInfo({
url: 'http://../geoserver/cite/wms', title: 'Vraag informatie op over een melding door erop te klikken',
queryVisible: true,
eventListeners: {
getfeatureinfo: function(event) {
deletePopup();
popup = new OpenLayers.Popup.FramedCloud( "chicken", map.getLonLatFromPixel(event.xy), null, event.text, null, true );
map.addPopup(popup); } } });
map.addControl(info); info.activate();