Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

  • 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

share|improve this question
    
What does the console show in firebug or chrome? Does it contain any error? –  Devdatta Tengshe Feb 26 '13 at 1:46
1  
Additionally, have you confirmed that the proxy is working? –  Devdatta Tengshe Feb 26 '13 at 1:47
    
I am getting this error in console in chrome when I click on the feature : XMLHttpRequest cannot load file:///C:/cgi-bin/proxy.cgi?url=http%3A%2F%2Flocalhost%3A8080%2Fgeoserver%…D469‌​%26y%3D118%26height%3D273%26width%3D1304%26info_format%3Dtext%252Fhtml. Cross origin requests are only supported for HTTP. OpenLayers.js:1081 cXMLHttpRequest.send OpenLayers.js:1081 (anonymous function) OpenLayers.js:867 Uncaught Error: NETWORK_ERR: XMLHttpRequest Exception 101 OpenLayers.js:1081 cXMLHttpRequest.send OpenLayers.js:1081 (anonymous function) OpenLayers.js:867 –  Jeevan Patnaik Feb 26 '13 at 8:44
1  
You have installed WAMP and have placed your html file there. Why then are you accessing it using the file protocol? Access it using the http Prootocol. SOmething like localhost/featureinfo.html. (One more problem is is that if you have installed Wamp, your HTML/Javascript files should be in C:\Wamp\www and not C:\Wamp\bin\Apache\htdocs) –  Devdatta Tengshe Feb 26 '13 at 8:56
    
oh..thank you!! I will check it!! :) –  Jeevan Patnaik Feb 26 '13 at 8:57
show 2 more comments

1 Answer 1

up vote 1 down vote accepted
+50

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.

share|improve this answer
    
no..I did the first 2 steps. I dont know how to anything regarding the configuration of web-server..help!! –  Jeevan Patnaik Mar 2 '13 at 10:18
    
I changed the path to #!C:\Python25\python.exe -u and also my present ip address. but when I visit the proxy, it is showing internal service error. –  Jeevan Patnaik Mar 2 '13 at 10:38
1  
Look in your web server logs. You will get the detailed error there. –  Devdatta Tengshe Mar 2 '13 at 15:13
add comment

Your Answer

 
discard

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.