[OpenLayers-Users] WFS GEtFeature layer not showing on map

Andreas Hocevar ahocevar at opengeo.org
Mon Apr 19 06:56:43 EDT 2010


Hi,

I don't get why you set up a vector layer and a wfs layer. Have a look at http://www.openlayers.org/dev/examples/getfeature-wfs.html, it seems to me that example does exactly what you want. Add your stylemap, maybe remove the hover event handler, and you should be good to go.

Regards,
Andreas.

On Apr 18, 2010, at 17:38 , sunny74 wrote:

> 
> Hi,
> 
> I am doing a GetFeature on a WFS layer atop a WMS layer.The WFS layer is for
> the purpose of doing GetFeature on that layer.
> 
> My code is as follows:
> 
> 
> OpenLayers.ProxyHost = "/proxy/?url=";
>              var lon = 73.25;
>              var lat = 20.35;
>              var zoom = 6;
>              map = new OpenLayers.Map('<%=map.ClientID%>');
> 
>              layer = new OpenLayers.Layer.WMS("OpenLayers WMS",
> "/Mapserver/mapserv.exe?map=c:/ms4w/apache/htdocs/Shape/newwr1rec.map", {
> layers: ["state", "RailwayStations"], transparent: false, format:
> "image/png" }, { isBaseLayer: true });
>              map.addLayer(layer);
> 
>              layer = new OpenLayers.Layer.WFS("MyWFS",
> 
> "/Mapserver/mapserv.exe?map=c:/ms4w/apache/htdocs/Shape/Rail_wfs.map",
>               { typename: "RailwayStations", maxfeatures: 10 },
>               { featureClass: OpenLayers.Feature.WFS });
> 
>               select = new OpenLayers.Layer.Vector("Selection", {
> styleMap:
>               new
> OpenLayers.Style(OpenLayers.Feature.Vector.style["select"])
>          });
>           map.addLayers([layer,select]);
>              map.addControl(new OpenLayers.Control.LayerSwitcher());
>              map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
> 
>              // make a GetFeature request
> //               map.events.register('click', map, function(e) {
> //                   var url =
> "http://localhost:81/cgi-bin/mapserv.exe?map=c:/ms4w/apache/htdocs/Shape/Rail_wfs.map&SERVICE=WFS&VERSION=1.0.0&REQUEST=GETfeature&typename=state";
> 
>              //               })
> 
>               control = new OpenLayers.Control.GetFeature({
>                  protocol: OpenLayers.Protocol.WFS({
>                      readFormat: new OpenLayers.Format.GeoJSON(),
>                      formatOptions: {
>                          outputFormat: "JSON"
>                      },
>                      url:
> "/Mapserver/mapserv.exe?map=c:/ms4w/apache/htdocs/Shape/Rail_wfs.map",
>                      featureType: "state",
>                      featurePrefix: 'ms',
>                      geometryName: 'the_geom',
>                      maxFeatures: 100
> 
>                  }),
>                  box:true,
>                  multipleKey: "shiftKey"
> 
>              });
>              control.events.register("featureselected", this, function(e)
> {
>                  alert(" in fselected");
>                  //select.addFeatures([e.feature]);
>                  document.getElementById('featuredetails').innerHTML +=
> "<br>"+ e.feature.attributes.STATE + "<br>"
>                  + e.feature.attributes.AREA;
>              });
>              map.addControl(control);
>              control.activate();
> 
> The problems are as follows:
> 
> 1) WFS layer is shown in layerSwitcher but not on the map.If I do a right
> click I get options like" save picture as" which comes for a WMS layer
> 
> 2) A box is drawn when I drag the mouse but the layer(select) for the
> purpose of GetFeature goes off as soon as I leave the mouse. How can I have
> the layer  be visible on the map with some color?
> 
> 3) The select layer code is from one of the examples given but I don't know
> from where the it is getting the stylemap.How can put a different stylemap?
> 
> 4) I want to have a circle instead of a box.What do I need to do?
> 
> 5)I want to have the filters within, Interesects and outside of the box?
> PLs send me the code for the filters?
> 
> Thanks for your attention & efforts.
> 
> 
> 
> 
> -- 
> View this message in context: http://n2.nabble.com/WFS-GEtFeature-layer-not-showing-on-map-tp4921150p4921150.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users

-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.




More information about the Users mailing list