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.

Possible Duplicate:
Problems with OpenLayers and WFS - proxy.cgi issues

hi friends i have a problem with simple openlayer web page. i have two layer, first one is wms layer and work perfectly on quantum gis and openlayers but second layer wfs(tasmania_road) work on quantum gis but dont work on openlayers. i simply show two layer which wfs tasmania_road on the wms earth . my code shown below, please help me, thanks

<html>
<head>
    <script type="text/javascript">
        var map;

        function init() {


            OpenLayers.ProxyHost = "proxy.cgi?url=";
            map = new OpenLayers.Map('rcp1_map');
            var wms = new OpenLayers.Layer.WMS(
                    "OpenLayers WMS", "http://vmap0.tiles.osgeo.org/wms/vmap0",
                    { layers: 'basic' }
                ); 

            var layer = new OpenLayers.Layer.Vector("WFS", {
                strategies: [new OpenLayers.Strategy.BBOX()],
                protocol: new OpenLayers.Protocol.WFS({
                    url: "http://demo.opengeo.org/geoserver/wfs",
                    featureType: "tasmania_roads",
                    featureNS: "http://www.openplans.org/topp"
                })
            });

            map.addLayer(wms);
            map.addLayers([wms, layer]);
            map.setCenter(new OpenLayers.LonLat(146.7, -41.8), 6);
        }
    </script>
</head>
<body onload="init()">
    <div id="rcp1_map" style="width: 100%; height: 100%;">
    </div>
</body>
</html>
share|improve this question

marked as duplicate by Devdatta Tengshe, Aragon, whuber Feb 2 '13 at 17:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer 1

Your code is working fine for me, once I do the following two:

  1. Use the full OpenLayers.js file.
  2. Use a properly configured proxy.

Have you done this on your side?

My Code is as follows:

<script type="text/javascript">
    var map;

    function init() {

        var bounds = new OpenLayers.Bounds(
                145.19754, -43.423512,
                148.27298000000002, -40.852802
            );
            var options = {
                controls: [new OpenLayers.Control.Navigation()],
                maxExtent: bounds,
                maxResolution: 0.0120134375000001,
                projection: "EPSG:4326",
                units: 'degrees'
            };

        OpenLayers.ProxyHost = "/cgi-bin/proxy_Open.cgi?url=";
        map = new OpenLayers.Map('rcp1_map', options);
        var wms = new OpenLayers.Layer.WMS(
                "OpenLayers WMS", "http://vmap0.tiles.osgeo.org/wms/vmap0",
                { layers: 'basic' }
            ); 

        var layer = new OpenLayers.Layer.Vector("WFS", {
            strategies: [new OpenLayers.Strategy.BBOX()],
            protocol: new OpenLayers.Protocol.WFS({
                url:  "http://demo.opengeo.org/geoserver/wfs",
                featureType: "tasmania_roads",
                featureNS: "http://www.openplans.org/topp"
            })
        });

        map.addLayers([wms, layer]);
        map.setCenter(new OpenLayers.LonLat(146.7, -41.8), 2);
    }
</script>

share|improve this answer
    
thanks i use postgresql for database which install on the server and i install geoserver on my computer and i develop my application with visual studio 2012 web forms i do my proxyhost : OpenLayers.ProxyHost = "/Proxy.aspx?url="; but still wms layer work perfetcly but wfs layer dont display –  JavaMAN Jan 31 '13 at 11:53
    
@CanAlperOzturk You first need to make sure that the proxy.cgi works. Without it you will not be able to access the WFS service. –  Devdatta Tengshe Jan 31 '13 at 13:52
    
how can i sure about proxy.cgi file. i find example mentby.com/Group/openlayers-users/… wfs problem because of proxy. i dont know how to configure this proxy –  JavaMAN Feb 1 '13 at 8:33
    
@CanAlperOzturk Please look at this Answer: gis.stackexchange.com/a/2528/442 –  Devdatta Tengshe Feb 1 '13 at 10:21

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