Hi list,
I try to select a feature from a wfs layer but it didn´t work.
var select = new OpenLayers.Layer.Vector("Selection", {
styleMap: new
OpenLayers.StyleMap({strokeColor: "blue",
strokeWidth: 5 , strokeOpacity: 0.5, fillOpacity: 0.4}),
displayInLayerSwitcher: true, visibility: true});
var wfs2 = new OpenLayers.Layer.Vector("WFS_",
{ styleMap: styleMap,
strategies: [new OpenLayers.Strategy.Fixed()],
projection: destproj,
protocol: new OpenLayers.Protocol.WFS({
url: "http://myserver:81/geoserver/wfs",
featureNS: http://mycomp.org,
featureType: "mylayer",
geometryName: "SHAPE",
srsName: "EPSG:4326",
version: "1.1.0"
}),
projection: new OpenLayers.Projection("EPSG:4326")
});
var selectFeature = new OpenLayers.Control.SelectFeature(wfs2,{box:true});
//map.addControl(selectFeature);
selectFeature.events.register("featureselected", this, function(e){
select.addFeatures([e.feature]); });
selectFeature.events.register("featureunselected", this,
function(e){select.removeFeatures([e.feature]);});
map.addControl(selectFeature);
I can cover my feature with a box but then nothing happens. At firebug I can
see that my code never reach "select.addFeatures([e.feature]);".
If I use:selectControl = new OpenLayers.Control.GetFeature({
protocol: OpenLayers.Protocol.WFS({
url: "http://myserver:81/geoserver/wfs?service=wfs",
featureNS: "http://mycomp.org",
featureType: "mylayer",
geometryName: "SHAPE",
srsName: "EPSG:4326",
version: "1.0.0",
}),
box: true,
multipleKey: "shiftKey",
toggleKey: "ctrlKey"
}, {projection: new OpenLayers.Projection("EPSG:4326")}
);
selectControl.events.register("featureselected", this, function(e){
//select.addFeatures(Proj4js.transform(sourceproj,destproj,[e.feature.geometry]));
//Proj4js.reportError =
function(msg){alert(msg);}//[e.feature.transform(sourceproj,destproj)]);
select.addFeatures([e.feature])
});
selectControl.events.register("featureunselected", this,
function(e){select.removeFeatures([e.feature]);});
map.addControl(selectControl);
I get a response at firebug (but feature has different projection). If I want
to transform my response then I get a message saying "Latitude failed to
converge".
Features are multipolygon if that does matter.
What did I wrong?
Thanks for any hint.
best regards
Sarah
_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users