Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Any help with this would be appreciated. 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 popup 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 popup. However, I only want a popup to appear when a user clicks an actual feature.

Does anyone know how to fix this? Thnx in advance!

share|improve this question
can you share your code to see what is wrong with it? – Aragon Jan 22 '13 at 11:24
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(); – Michiel Jan 22 '13 at 11:27

fixed it already!

I added this to my code (the stuff in bold):

...event) {deletePopup(); if (event.text.indexOf("") != -1) { popup = new OpenLayers...

(And an extra } after map.addPopup(popup); obviously.

share|improve this answer

Maybe is more intuitive to ask:

if (event.features.length != 0)

If you don't touch a feature, OpenLayers will set this parameter to 0, because the GeoServer response is "empty".

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.