0

GeoExt info Popup is very easy to use but when one or more layer is missing or fails to load Avoiding Pink Tyles. The popup is not filled with the values. While I can see that request is sent to the server and response is there but popup is blank. Is there any way to handle this condition without building custom component?

OpenLayers.Util.onImageLoadErrorColor = 1;
            OpenLayers.Util.onImageLoadErrorColor = "transparent";  
            OpenLayers.Util.onImageLoadError = function(){
                 this.src = "/img/blank.gif";
            };

controls.push(new OpenLayers.Control.WMSGetFeatureInfo({              
                autoActivate: true,
                infoFormat: "application/vnd.ogc.gml",
                maxFeatures: 3,
                eventListeners: {
                    "getfeatureinfo": function(e) {                       
                        var items = [];
                        Ext.each(e.features, function(feature) {
                            items.push({
                                xtype: "propertygrid",
                                title: feature.fid,
                                source: feature.attributes
                            });
                        });

                        new GeoExt.Popup({
                            title: "Info",
                            width: 200,
                            height: 200,
                            layout: "accordion",
                            map: app.mapPanel,
                            location: e.xy,
                            maximizable: true,
                            collapsible: true,
                            items: items 
                        }).show();                      

                    }
                }
            }));
2
  • 1
    sample code please.
    – CaptDragon
    Mar 1, 2012 at 14:06
  • @CaptDragon Edited the question
    – kinkajou
    Mar 2, 2012 at 3:48

2 Answers 2

2

Try placing a condition to check to see if there are results first. if (e.features.length > 0){

like:

"getfeatureinfo": function(e) {  
    if (e.features.length > 0){ //<-- add this if statement
        var items = [];
        Ext.each(e.features, function(feature) {
        ...
        });

        new GeoExt.Popup({
        ...
        }).show();                      
    }
}  
0

I think the problem isn't with the popup but with the get feature info request. You need to control if the request is made right, if so show the popup and if there was any error not show the popup or show a message error.

1
  • the firebug doesn't show any error. There is get request for all layers including layer that is not loaded.
    – kinkajou
    Mar 2, 2012 at 3:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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