[OpenLayers-Users] Features Not Added to Vector Layer

Jerome A. Wendell jawendell at digitalmapping.com
Wed Mar 13 18:08:52 PDT 2013


I have a vector layer that is to contain features that are filtered from a
WMS layer.  The filter is working correctly and the correct feature can be
seen in Firebug in the response, but the feature is not added to the vector
layer.  Previously I had an issue where the coordinates were reversed.  That
problem has been solved, but now the feature is just not added to the layer.
The WMS layer is in EPSG:4326 and the map is in EPSG:900913.  Is there any
reason the feature would not be added based on the following code:

var filter = new OpenLayers.Filter.Comparison({

                                                type:
OpenLayers.Filter.Comparison.EQUAL_TO,

                                                property: 'myID',

                                                value: args['myID']

                                });

                                var myLayer = new
OpenLayers.Layer.Vector("Selected", {

                                                strategies: [new
OpenLayers.Strategy.Fixed()],

                                                protocol: new
OpenLayers.Protocol.WFS({

                                                                version:
"1.1.0",

                                                                url:
"http://myserver/geoserver/mydata/wfs",

                                                                featureType:
"myfeaturetype", //name of the geoserver layer

                                                                featureNS:
"mydata", //name of the geoserver store

 
geometryName: "the_geom",

                                                                filter:
filter

                                                }),

                                                displayInLayerSwitcher:
false,

                                                isBaseLayer: false,

                                                visibility: true,

                                                styleMap: new
OpenLayers.StyleMap({

                                                                "default":
new OpenLayers.Style({

 
stokeColor: "#FFFF00",

 
strokeOpacity: 0.5,

 
fillColor: "#FFFF00",

 
fillOpacity: 0.3

                                                                })

                                                }),

                                });

 
myLayer.events.register("beforefeatureadded", this, function(e) {

 
e.feature.geometry.transform(new
OpenLayers.Projection('EPSG:4326'),this.map.getProjectionObject());

 
myLayer.addFeatures(e.feature);

                                });

I guess the filter is actually a before feature added event, so could that
be part of the problem?  I have done a lot of searching on this issue, and
tried some variations that I found posted, but nothing has worked.

 

One scenario that I tried, the feature was added in the correct location,
but the request kept running until the browser crashed.  I did not post the
code for that.

 

Any suggestions are greatly appreciated.  I apologize if this post is very
similar to a previous post, but this is actually a different problem related
to the same operation.

 

Thanks.

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130313/e4a4d64e/attachment.html>


More information about the Users mailing list