[GIS] GeoExt WMS GetFeatureInfo in proxy server. Problem – popup is empty in chrome and not responding in firefox

geoextgeoserveropenlayers-2PROXY

  • I have python2.7 and apache installed in my computer.
  • In proxy.cgi, I included in topline :

    #!/usr/bin/env python.exe -u;

  • I also added 'localhost:8080/geoserver' and 'localhost:80 in allowedhosts.
  • I moved the OpenLayers files to htdocs folder of apache.
  • I copied the cgi file to apche/cgi-bin.
  • Now, when I click on feature, popup appears but is empty.

Please help!! where my code went wrong?
Given below is my code:

    <script type="text/javascript" src="http://localhost:8080/recipes/resources/ext/ext-all.js"></script>
    <link rel="stylesheet" type="text/css" href="http://localhost:8080/recipes/resources/ext/resources/css/ext-all.css" />
    <link rel="stylesheet" type="text/css" href="http://localhost:8080/recipes/resources/ext/resources/css/xtheme-gray.css" />
    <link rel="stylesheet" href="http://localhost:8080/recipes/resources/openlayers/theme/default/style.css" type="text/css" />
    <link rel="stylesheet" href="http://localhost:8080/recipes/resources/app/theme/style.css" type="text/css" />
    <link rel="stylesheet" href="http://localhost:8080/recipes/resources/geoext/resources/css/gxtheme-gray.css" type="text/css" />
    <script src="http://localhost:8080/recipes/resources/openlayers/build/OpenLayers.js"></script>
    <script src="http://localhost:8080/recipes/resources/geoext/build/GeoExt.js"></script>
    <script>
        OpenLayers.ImgPath = "http://localhost:8080/recipes/resources/openlayers/img/";

        // the `panel` and `popup` variables are declared here for easy debugging
        var panel, popup;

        Ext.onReady(function() {
        OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";    
            // queryable WMS layer
            var zoning = new OpenLayers.Layer.WMS(
                "railroads",
                "http://localhost:8080/geoserver/usa/wms",
                {layers: "usa:states", format: "image/gif", transparent: "true"}
            );

            panel = new GeoExt.MapPanel({
                title: "MapPanel",
                renderTo: "map-id",
                height: 300,
                width: "100%",
                layers: [
                    new OpenLayers.Layer.WMS(
                        "Global Imagery",
                        "http://maps.opengeo.org/geowebcache/service/wms",
                        {layers: "openstreetmap", format: "image/png"}
                    ), 
                    zoning
                ],
                center: [-122.87, 42.34],
                zoom: 13
            });

            // create a control to get feature info from queryable layers
            var control = new OpenLayers.Control.WMSGetFeatureInfo({
                url: "http://localhost:8080/geoserver/usa/wms"
                title: 'Identify features by clicking',
                layers: [zoning],
            });
            panel.map.addControl(control);
            control.activate();

            // register a listener for the getfeatureinfo event on the control
            control.events.on({
                getfeatureinfo: function(event) {
                    // close existing popup
                    if (popup) {
                        popup.destroy();
                    }
                    popup = new GeoExt.Popup({
                        title: "Popup",
                        map: panel.map,
                        lonlat: panel.map.getLonLatFromPixel(event.xy),
                        width: 250,
                        autoScroll: true,
                        collapsible: true,
                        bodyStyle: {padding: 5},
                        html: event.text
                    });
                    popup.show();
                }
            });

        });

    </script>

enter image description here

After changing the path to wamp/www and still I am getting this new following error:

enter image description here

Best Answer

A 500 error indicates that the server is having problems. This tells me that the proxy is not configured properly.

To solve the issue, I would check the following:

  1. Are you on a Linux/Unix Machine? The path #!/usr/bin/env python.exe -u; is usually for linux systems. My proxy file on a windows machine has the following as the first line: #!C:/Python27/Python.exe -u

  2. You need to add the external IP/domain name in the allowedHosts. so it should not be localahost:8080 but 115.241.55.138:8080

  3. You need to check the logs of your web-server for any other errors.

  4. You need to confirm that the proxy is in fact working. If you are using the OpenLayers Proxy, just visit the proxy at http:\\115.241.55.138\cgi-bin\proxy.cgi and see if the OpenLayers Website comes up.