[OpenLayers-Users] RE: Cannot see Vector Layer With WFS Protocol? - proxy required

McGee, David DMcGee at richmond.ca
Fri Oct 14 12:14:58 EDT 2011


Hi List:
 
Why was my vector layer not visible? Javascript cannot access data from
multiple domains. Many thanks to Roald de Wit for a response to my post
(below). Server-side work-around is in the link from Roald's response. 
 
David McGee
GIS Analyst (Geospatial)
Law & Community Safety Department
City of Richmond
6911 No. 3 Road
Richmond, BC
 
 
Hi,

You are requesting data from a domain that is different from yours.
You'll need to use a proxy script.
There is some more info about this requirement in the OpenLayers FAQ:
http://trac.osgeo.org/openlayers/wiki/FrequentlyAskedQuestions#ProxyHost
<http://trac.osgeo.org/openlayers/wiki/FrequentlyAskedQuestions#ProxyHos
t> 

Regards, Roald

 
 From: McGee, David 
Sent: October 12, 2011 05:11 PM
To: 'openlayers-users at lists.osgeo.org'
Subject: Cannot see Geoserver Vector Layer With WFS Protocol


Hi List,
 
I'm very new to OpenLayers, and would greatly appreciate help with what
I'm doing wrong.  I cannot get vector layers sourced from Geoserver to
display using the WFS Protocol. Please see the example below.
 
Thanks in advance,
 
David McGee
 
<!DOCTYPE html>
<html>
  <head>
     <title>WFS Visibility</title>
  <link rel="stylesheet"
href="http://www.openlayers.org/dev/examples/style.css" type="text/css">
  <script src="http://www.openlayers.org/dev/OpenLayers.js"></script>
  <script type="text/javascript">
        function init(){
            var map = new OpenLayers.Map( 'map' );
            var base = new OpenLayers.Layer.WMS( "WMS base",
                "http://vmap0.tiles.osgeo.org/wms/vmap0",
                    {
         layers: "basic",
      transparent: "true",
      format: "image/png"
     },
     {isBaseLayer: true, visibility: true}
    );
    var poi_wfs = new OpenLayers.Layer.Vector("poi WFS", {
        strategies: [new OpenLayers.Strategy.BBOX()],
     protocol: new OpenLayers.Protocol.WFS ({
         url: "http://demo.opengeo.org/geoserver/wfs",
      featureType: "poi",
      featureNS: "http://www.census.gov",
      srsName: "EPSG:4326",
      version: "1.1.0"
      })
    });    
   map.addLayers([base,poi_wfs]);
   map.addControl(new OpenLayers.Control.LayerSwitcher());
            map.zoomToMaxExtent();
        }  
  </script>
  </head>
  <body onload="init()">
     <div id="map" class="smallmap"></div>
  </body>
</html>
 
 
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20111014/f4df4885/attachment.html


More information about the Users mailing list