I have done point layer overlay with OpenLayers. Whenever I click any point, it's showing me all the data of the table (PostgreSQL) in popup.

How to control amount of data in the popup?

All the columns are being displayed in popup. I just want location_name to be displayed in the popup. How to extract location_name from event.text?

Code is:

info = new OpenLayers.Control.WMSGetFeatureInfo({
    url: 'http://localhost:8080/geoserver/layername/wms',  // geoserver point layer 
    title: 'Identify features by clicking',
    queryVisible: true,
    eventListeners: {
        getfeatureinfo: function(event) {
            map.addPopup(new OpenLayers.Popup.FramedCloud(
  • Just change the output of the WMS GetFeatureInfo on GeoServer, or just request the properties you want in the GetFeatureInfo request – nmtoken Aug 10 '17 at 7:55

Instead of event.text just send whatever HTML you want to have displayed.

You can do this by calling a fuction with event.text as argument, and then parsing output and returning whatever you want.

Try looking at event.features and extracting info from there, and then constructing HTML string with that info. I thing then you should pass just event. Try looking at that object in Firebug or Chrome dev. tools.

  • That's too cumbersome process!! Any other way out? – xtras Apr 9 '13 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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