Popular Threads From Users:
List Statistics
- Total Threads: 1594
- Total Posts: 2743
Phrases Used to Find This Thread
|
# 1

20-04-2010 01:43 PM
|
|
|
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
|
# 2

20-04-2010 01:57 PM
|
|
|
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
Hi Sarah,
Have you tried to put your wfs2 layer on top of your layers (as the last
one added to the map) ? Only the top-most layer can have its features
selected, unless you add all the vector layers to the SelectFeature control.
Also, you could use only one layer (wfs2) for feature selection instead
of two. It seems kinda odd to copy features from one layer to an other
for the purpose of "selection". Check the first example about that
matter (the other is just to let you know of the cool 'highlight'
feature you might be interested into ):
http://www.openlayers.org/dev/examples/select-feature.html
http://www.openlayers.org/dev/examples/highlight-feature.html
Best regards,
Alexandre
Sarah Schuessler wrote:
> 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
>
>
> ------------------------------------------------------------------------
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
|
# 3

20-04-2010 03:10 PM
|
|
|
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
Hi Sarah,
Have you tried to put your wfs2 layer on top of your layers (as the last
one added to the map) ? Only the top-most layer can have its features
selected, unless you add all the vector layers to the SelectFeature control.
Also, you could use only one layer (wfs2) for feature selection instead
of two. It seems kinda odd to copy features from one layer to an other
for the purpose of "selection". Check the first example about that
matter (the other is just to let you know of the cool 'highlight'
feature you might be interested into ):
http://www.openlayers.org/dev/examples/select-feature.html
http://www.openlayers.org/dev/examples/highlight-feature.html
Best regards,
Alexandre
Sarah Schuessler wrote:
> 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
>
>
> ------------------------------------------------------------------------
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Alexandre,
thanks for examples.
I went ahead with wfs-getfeature example selecting from a WFS.fromWMSLayer layer (changed this to simple wfs layer because I haven´t got a wms layer at my map right now)- but I get only a response at firebug not at my map because of different projection.
I have a viewport loading my layers:
xtype: "gx_mappanel",
map: map,
layers: [...,wfs2],
...
If I use map.addLayers(wfs2) after defining my layer my map is empty (no layers were loaded).
You said:
"unless you add all the vector layers to the SelectFeature control.
Also, you could use only one layer (wfs2) for feature selection instead
of two."
Can I use only one vector layer or more than one?
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
|
# 4

20-04-2010 03:31 PM
|
|
|
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
Hi Sarah,
Have you tried to put your wfs2 layer on top of your layers (as the last
one added to the map) ? Only the top-most layer can have its features
selected, unless you add all the vector layers to the SelectFeature control.
Also, you could use only one layer (wfs2) for feature selection instead
of two. It seems kinda odd to copy features from one layer to an other
for the purpose of "selection". Check the first example about that
matter (the other is just to let you know of the cool 'highlight'
feature you might be interested into ):
http://www.openlayers.org/dev/examples/select-feature.html
http://www.openlayers.org/dev/examples/highlight-feature.html
Best regards,
Alexandre
Sarah Schuessler wrote:
> 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
>
>
> ------------------------------------------------------------------------
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Alexandre,
thanks for examples.
I went ahead with wfs-getfeature example selecting from a WFS.fromWMSLayer layer (changed this to simple wfs layer because I haven´t got a wms layer at my map right now)- but I get only a response at firebug not at my map because of different projection.
I have a viewport loading my layers:
xtype: "gx_mappanel",
map: map,
layers: [...,wfs2],
...
If I use map.addLayers(wfs2) after defining my layer my map is empty (no layers were loaded).
You said:
"unless you add all the vector layers to the SelectFeature control.
Also, you could use only one layer (wfs2) for feature selection instead
of two."
Can I use only one vector layer or more than one?
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Sarah,
Sarah Schuessler wrote:
> If I use map.addLayers(wfs2) after defining my layer my map is empty
> (no layers were loaded).
>
> You said:
> "unless you add all the vector layers to the SelectFeature control.
>
> Also, you could use only one layer (wfs2) for feature selection instead
> of two."
> Can I use only one vector layer or more than one?
If you have multiple layers of different types, let's say a 'city'
layer, a 'road' layer and a 'water' layer (all of them vector) and you
want to be able to select features from any of these layers, you can
define an array of layers to the SelectFeature control and you'll be
able to select any feature from any layer.
What you're currently doing is having a 'water' layer (I don't know what
is the type, but let's assume they are 'water' polygons) to display your
features and an other 'water' layer (that is empty) for feature
selection. Having 2 layers for just the purpose of selection seems odd
so that is why I proposed you should only have one.
Do you want your features to be always Vector of do you want to
'highlight' them only from drawing a box on the map ?
Also, do you have control on the feature server ? I mean, are you able
to add the missing projection on server-side ? That could resolve that
issue.
Kind regards,
--
Alexandre Dubé
Mapgears
www.mapgears.com
_______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
|
# 5

20-04-2010 04:30 PM
|
|
|
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
Hi Sarah,
Have you tried to put your wfs2 layer on top of your layers (as the last
one added to the map) ? Only the top-most layer can have its features
selected, unless you add all the vector layers to the SelectFeature control.
Also, you could use only one layer (wfs2) for feature selection instead
of two. It seems kinda odd to copy features from one layer to an other
for the purpose of "selection". Check the first example about that
matter (the other is just to let you know of the cool 'highlight'
feature you might be interested into ):
http://www.openlayers.org/dev/examples/select-feature.html
http://www.openlayers.org/dev/examples/highlight-feature.html
Best regards,
Alexandre
Sarah Schuessler wrote:
> 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
>
>
> ------------------------------------------------------------------------
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Alexandre,
thanks for examples.
I went ahead with wfs-getfeature example selecting from a WFS.fromWMSLayer layer (changed this to simple wfs layer because I haven´t got a wms layer at my map right now)- but I get only a response at firebug not at my map because of different projection.
I have a viewport loading my layers:
xtype: "gx_mappanel",
map: map,
layers: [...,wfs2],
...
If I use map.addLayers(wfs2) after defining my layer my map is empty (no layers were loaded).
You said:
"unless you add all the vector layers to the SelectFeature control.
Also, you could use only one layer (wfs2) for feature selection instead
of two."
Can I use only one vector layer or more than one?
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Sarah,
Sarah Schuessler wrote:
> If I use map.addLayers(wfs2) after defining my layer my map is empty
> (no layers were loaded).
>
> You said:
> "unless you add all the vector layers to the SelectFeature control.
>
> Also, you could use only one layer (wfs2) for feature selection instead
> of two."
> Can I use only one vector layer or more than one?
If you have multiple layers of different types, let's say a 'city'
layer, a 'road' layer and a 'water' layer (all of them vector) and you
want to be able to select features from any of these layers, you can
define an array of layers to the SelectFeature control and you'll be
able to select any feature from any layer.
What you're currently doing is having a 'water' layer (I don't know what
is the type, but let's assume they are 'water' polygons) to display your
features and an other 'water' layer (that is empty) for feature
selection. Having 2 layers for just the purpose of selection seems odd
so that is why I proposed you should only have one.
Do you want your features to be always Vector of do you want to
'highlight' them only from drawing a box on the map ?
Also, do you have control on the feature server ? I mean, are you able
to add the missing projection on server-side ? That could resolve that
issue.
Kind regards,
--
Alexandre Dubé
Mapgears
www.mapgears.com
_______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Alexandre,
I think I mixed it all up.
I have included my event to my wfs2 layer and added feature to an empty vectorlayer (select):
wfs2.events.on({'featureselected': function(feature){
select.addFeatures([feature.feature]);},
'featureunselected': function(feature){..}
});
It worked.
If I use version 1.1.0 at GeFeature request (for server side reprojection) for my other kind of selection I get exception like: encode failed for value..(I think because of srs/epsg code, projection issue). I tried to change epsg code and some other things at geoserver but problem still remain.
I asked about this issue at geoserver list some time ago but could not solved it yet.
Thanks.
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
|
# 6

26-04-2010 02:43 PM
|
|
|
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
Hi Sarah,
Have you tried to put your wfs2 layer on top of your layers (as the last
one added to the map) ? Only the top-most layer can have its features
selected, unless you add all the vector layers to the SelectFeature control.
Also, you could use only one layer (wfs2) for feature selection instead
of two. It seems kinda odd to copy features from one layer to an other
for the purpose of "selection". Check the first example about that
matter (the other is just to let you know of the cool 'highlight'
feature you might be interested into ):
http://www.openlayers.org/dev/examples/select-feature.html
http://www.openlayers.org/dev/examples/highlight-feature.html
Best regards,
Alexandre
Sarah Schuessler wrote:
> 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
>
>
> ------------------------------------------------------------------------
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Alexandre,
thanks for examples.
I went ahead with wfs-getfeature example selecting from a WFS.fromWMSLayer layer (changed this to simple wfs layer because I haven´t got a wms layer at my map right now)- but I get only a response at firebug not at my map because of different projection.
I have a viewport loading my layers:
xtype: "gx_mappanel",
map: map,
layers: [...,wfs2],
...
If I use map.addLayers(wfs2) after defining my layer my map is empty (no layers were loaded).
You said:
"unless you add all the vector layers to the SelectFeature control.
Also, you could use only one layer (wfs2) for feature selection instead
of two."
Can I use only one vector layer or more than one?
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Sarah,
Sarah Schuessler wrote:
> If I use map.addLayers(wfs2) after defining my layer my map is empty
> (no layers were loaded).
>
> You said:
> "unless you add all the vector layers to the SelectFeature control.
>
> Also, you could use only one layer (wfs2) for feature selection instead
> of two."
> Can I use only one vector layer or more than one?
If you have multiple layers of different types, let's say a 'city'
layer, a 'road' layer and a 'water' layer (all of them vector) and you
want to be able to select features from any of these layers, you can
define an array of layers to the SelectFeature control and you'll be
able to select any feature from any layer.
What you're currently doing is having a 'water' layer (I don't know what
is the type, but let's assume they are 'water' polygons) to display your
features and an other 'water' layer (that is empty) for feature
selection. Having 2 layers for just the purpose of selection seems odd
so that is why I proposed you should only have one.
Do you want your features to be always Vector of do you want to
'highlight' them only from drawing a box on the map ?
Also, do you have control on the feature server ? I mean, are you able
to add the missing projection on server-side ? That could resolve that
issue.
Kind regards,
--
Alexandre Dubé
Mapgears
www.mapgears.com
_______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Alexandre,
I think I mixed it all up.
I have included my event to my wfs2 layer and added feature to an empty vectorlayer (select):
wfs2.events.on({'featureselected': function(feature){
select.addFeatures([feature.feature]);},
'featureunselected': function(feature){..}
});
It worked.
If I use version 1.1.0 at GeFeature request (for server side reprojection) for my other kind of selection I get exception like: encode failed for value..(I think because of srs/epsg code, projection issue). I tried to change epsg code and some other things at geoserver but problem still remain.
I asked about this issue at geoserver list some time ago but could not solved it yet.
Thanks.
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Sarah,
I am trying to achieve the same thing that you did.I want to select a
portion within a wfs layer and view that selection in a different style.
I hope this is your requirement.
I find that you have taken a vector layer and a wfs layer and finally a
selectfeature
with a Control.SelectFeature.
Now I didn't understand your logic. Why it didn't work initially?
How it worked fine finally?
It would be great if you could explain your situation?
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/control-SelectFeature-tp4930933p4962622.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
|
# 7

26-04-2010 03:18 PM
|
|
|
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
Hi Sarah,
Have you tried to put your wfs2 layer on top of your layers (as the last
one added to the map) ? Only the top-most layer can have its features
selected, unless you add all the vector layers to the SelectFeature control.
Also, you could use only one layer (wfs2) for feature selection instead
of two. It seems kinda odd to copy features from one layer to an other
for the purpose of "selection". Check the first example about that
matter (the other is just to let you know of the cool 'highlight'
feature you might be interested into ):
http://www.openlayers.org/dev/examples/select-feature.html
http://www.openlayers.org/dev/examples/highlight-feature.html
Best regards,
Alexandre
Sarah Schuessler wrote:
> 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
>
>
> ------------------------------------------------------------------------
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Alexandre,
thanks for examples.
I went ahead with wfs-getfeature example selecting from a WFS.fromWMSLayer layer (changed this to simple wfs layer because I haven´t got a wms layer at my map right now)- but I get only a response at firebug not at my map because of different projection.
I have a viewport loading my layers:
xtype: "gx_mappanel",
map: map,
layers: [...,wfs2],
...
If I use map.addLayers(wfs2) after defining my layer my map is empty (no layers were loaded).
You said:
"unless you add all the vector layers to the SelectFeature control.
Also, you could use only one layer (wfs2) for feature selection instead
of two."
Can I use only one vector layer or more than one?
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Sarah,
Sarah Schuessler wrote:
> If I use map.addLayers(wfs2) after defining my layer my map is empty
> (no layers were loaded).
>
> You said:
> "unless you add all the vector layers to the SelectFeature control.
>
> Also, you could use only one layer (wfs2) for feature selection instead
> of two."
> Can I use only one vector layer or more than one?
If you have multiple layers of different types, let's say a 'city'
layer, a 'road' layer and a 'water' layer (all of them vector) and you
want to be able to select features from any of these layers, you can
define an array of layers to the SelectFeature control and you'll be
able to select any feature from any layer.
What you're currently doing is having a 'water' layer (I don't know what
is the type, but let's assume they are 'water' polygons) to display your
features and an other 'water' layer (that is empty) for feature
selection. Having 2 layers for just the purpose of selection seems odd
so that is why I proposed you should only have one.
Do you want your features to be always Vector of do you want to
'highlight' them only from drawing a box on the map ?
Also, do you have control on the feature server ? I mean, are you able
to add the missing projection on server-side ? That could resolve that
issue.
Kind regards,
--
Alexandre Dubé
Mapgears
www.mapgears.com
_______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Alexandre,
I think I mixed it all up.
I have included my event to my wfs2 layer and added feature to an empty vectorlayer (select):
wfs2.events.on({'featureselected': function(feature){
select.addFeatures([feature.feature]);},
'featureunselected': function(feature){..}
});
It worked.
If I use version 1.1.0 at GeFeature request (for server side reprojection) for my other kind of selection I get exception like: encode failed for value..(I think because of srs/epsg code, projection issue). I tried to change epsg code and some other things at geoserver but problem still remain.
I asked about this issue at geoserver list some time ago but could not solved it yet.
Thanks.
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Sarah,
I am trying to achieve the same thing that you did.I want to select a
portion within a wfs layer and view that selection in a different style.
I hope this is your requirement.
I find that you have taken a vector layer and a wfs layer and finally a
selectfeature
with a Control.SelectFeature.
Now I didn't understand your logic. Why it didn't work initially?
How it worked fine finally?
It would be great if you could explain your situation?
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/control-SelectFeature-tp4930933p4962622.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi,
I want to do the same like here: http://dev.openlayers.org/releases/OpenLayers-2.9/examples/getfeature-wfs.html and get information about selected feature(s) back.
I think that it didn`t work because of problems with geoserver wfs version (reproject) and/or params. I don`t know exactly (modified my code a few times;-)) (I`ve noticed that url at the control has to be same like the wfs/wms layer too)
So I still have problems with unselect (see other post).
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
|
# 8

02-05-2010 02:22 PM
|
|
|
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
Hi Sarah,
Have you tried to put your wfs2 layer on top of your layers (as the last
one added to the map) ? Only the top-most layer can have its features
selected, unless you add all the vector layers to the SelectFeature control.
Also, you could use only one layer (wfs2) for feature selection instead
of two. It seems kinda odd to copy features from one layer to an other
for the purpose of "selection". Check the first example about that
matter (the other is just to let you know of the cool 'highlight'
feature you might be interested into ):
http://www.openlayers.org/dev/examples/select-feature.html
http://www.openlayers.org/dev/examples/highlight-feature.html
Best regards,
Alexandre
Sarah Schuessler wrote:
> 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
>
>
> ------------------------------------------------------------------------
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Alexandre,
thanks for examples.
I went ahead with wfs-getfeature example selecting from a WFS.fromWMSLayer layer (changed this to simple wfs layer because I haven´t got a wms layer at my map right now)- but I get only a response at firebug not at my map because of different projection.
I have a viewport loading my layers:
xtype: "gx_mappanel",
map: map,
layers: [...,wfs2],
...
If I use map.addLayers(wfs2) after defining my layer my map is empty (no layers were loaded).
You said:
"unless you add all the vector layers to the SelectFeature control.
Also, you could use only one layer (wfs2) for feature selection instead
of two."
Can I use only one vector layer or more than one?
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Sarah,
Sarah Schuessler wrote:
> If I use map.addLayers(wfs2) after defining my layer my map is empty
> (no layers were loaded).
>
> You said:
> "unless you add all the vector layers to the SelectFeature control.
>
> Also, you could use only one layer (wfs2) for feature selection instead
> of two."
> Can I use only one vector layer or more than one?
If you have multiple layers of different types, let's say a 'city'
layer, a 'road' layer and a 'water' layer (all of them vector) and you
want to be able to select features from any of these layers, you can
define an array of layers to the SelectFeature control and you'll be
able to select any feature from any layer.
What you're currently doing is having a 'water' layer (I don't know what
is the type, but let's assume they are 'water' polygons) to display your
features and an other 'water' layer (that is empty) for feature
selection. Having 2 layers for just the purpose of selection seems odd
so that is why I proposed you should only have one.
Do you want your features to be always Vector of do you want to
'highlight' them only from drawing a box on the map ?
Also, do you have control on the feature server ? I mean, are you able
to add the missing projection on server-side ? That could resolve that
issue.
Kind regards,
--
Alexandre Dubé
Mapgears
www.mapgears.com
_______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Alexandre,
I think I mixed it all up.
I have included my event to my wfs2 layer and added feature to an empty vectorlayer (select):
wfs2.events.on({'featureselected': function(feature){
select.addFeatures([feature.feature]);},
'featureunselected': function(feature){..}
});
It worked.
If I use version 1.1.0 at GeFeature request (for server side reprojection) for my other kind of selection I get exception like: encode failed for value..(I think because of srs/epsg code, projection issue). I tried to change epsg code and some other things at geoserver but problem still remain.
I asked about this issue at geoserver list some time ago but could not solved it yet.
Thanks.
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Sarah,
I am trying to achieve the same thing that you did.I want to select a
portion within a wfs layer and view that selection in a different style.
I hope this is your requirement.
I find that you have taken a vector layer and a wfs layer and finally a
selectfeature
with a Control.SelectFeature.
Now I didn't understand your logic. Why it didn't work initially?
How it worked fine finally?
It would be great if you could explain your situation?
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/control-SelectFeature-tp4930933p4962622.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi,
I want to do the same like here: http://dev.openlayers.org/releases/OpenLayers-2.9/examples/getfeature-wfs.html and get information about selected feature(s) back.
I think that it didn`t work because of problems with geoserver wfs version (reproject) and/or params. I don`t know exactly (modified my code a few times;-)) (I`ve noticed that url at the control has to be same like the wfs/wms layer too)
So I still have problems with unselect (see other post).
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Sarah,
Have you been able to make the selection work with a layer over the region
of selection?
I need to get that working desperately.
My code is not that Good.
It works in one machine but doesn't work in other.
Can you give me better code?
WFS.FromWMSLayer does not work in my case, I 'm using Mapserver.
The guy called Bart told me that he has code to make circle work instead of
box but didn't give the code since then.
Pl tell me how you got the selection layer working.
Thanks for your reply.
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/control-SelectFeature-tp4930933p4992935.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
|
# 9

02-05-2010 06:53 PM
|
|
|
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
Hi Sarah,
Have you tried to put your wfs2 layer on top of your layers (as the last
one added to the map) ? Only the top-most layer can have its features
selected, unless you add all the vector layers to the SelectFeature control.
Also, you could use only one layer (wfs2) for feature selection instead
of two. It seems kinda odd to copy features from one layer to an other
for the purpose of "selection". Check the first example about that
matter (the other is just to let you know of the cool 'highlight'
feature you might be interested into ):
http://www.openlayers.org/dev/examples/select-feature.html
http://www.openlayers.org/dev/examples/highlight-feature.html
Best regards,
Alexandre
Sarah Schuessler wrote:
> 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
>
>
> ------------------------------------------------------------------------
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Alexandre,
thanks for examples.
I went ahead with wfs-getfeature example selecting from a WFS.fromWMSLayer layer (changed this to simple wfs layer because I haven´t got a wms layer at my map right now)- but I get only a response at firebug not at my map because of different projection.
I have a viewport loading my layers:
xtype: "gx_mappanel",
map: map,
layers: [...,wfs2],
...
If I use map.addLayers(wfs2) after defining my layer my map is empty (no layers were loaded).
You said:
"unless you add all the vector layers to the SelectFeature control.
Also, you could use only one layer (wfs2) for feature selection instead
of two."
Can I use only one vector layer or more than one?
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Sarah,
Sarah Schuessler wrote:
> If I use map.addLayers(wfs2) after defining my layer my map is empty
> (no layers were loaded).
>
> You said:
> "unless you add all the vector layers to the SelectFeature control.
>
> Also, you could use only one layer (wfs2) for feature selection instead
> of two."
> Can I use only one vector layer or more than one?
If you have multiple layers of different types, let's say a 'city'
layer, a 'road' layer and a 'water' layer (all of them vector) and you
want to be able to select features from any of these layers, you can
define an array of layers to the SelectFeature control and you'll be
able to select any feature from any layer.
What you're currently doing is having a 'water' layer (I don't know what
is the type, but let's assume they are 'water' polygons) to display your
features and an other 'water' layer (that is empty) for feature
selection. Having 2 layers for just the purpose of selection seems odd
so that is why I proposed you should only have one.
Do you want your features to be always Vector of do you want to
'highlight' them only from drawing a box on the map ?
Also, do you have control on the feature server ? I mean, are you able
to add the missing projection on server-side ? That could resolve that
issue.
Kind regards,
--
Alexandre Dubé
Mapgears
www.mapgears.com
_______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Alexandre,
I think I mixed it all up.
I have included my event to my wfs2 layer and added feature to an empty vectorlayer (select):
wfs2.events.on({'featureselected': function(feature){
select.addFeatures([feature.feature]);},
'featureunselected': function(feature){..}
});
It worked.
If I use version 1.1.0 at GeFeature request (for server side reprojection) for my other kind of selection I get exception like: encode failed for value..(I think because of srs/epsg code, projection issue). I tried to change epsg code and some other things at geoserver but problem still remain.
I asked about this issue at geoserver list some time ago but could not solved it yet.
Thanks.
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Sarah,
I am trying to achieve the same thing that you did.I want to select a
portion within a wfs layer and view that selection in a different style.
I hope this is your requirement.
I find that you have taken a vector layer and a wfs layer and finally a
selectfeature
with a Control.SelectFeature.
Now I didn't understand your logic. Why it didn't work initially?
How it worked fine finally?
It would be great if you could explain your situation?
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/control-SelectFeature-tp4930933p4962622.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi,
I want to do the same like here: http://dev.openlayers.org/releases/OpenLayers-2.9/examples/getfeature-wfs.html and get information about selected feature(s) back.
I think that it didn`t work because of problems with geoserver wfs version (reproject) and/or params. I don`t know exactly (modified my code a few times;-)) (I`ve noticed that url at the control has to be same like the wfs/wms layer too)
So I still have problems with unselect (see other post).
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Sarah,
Have you been able to make the selection work with a layer over the region
of selection?
I need to get that working desperately.
My code is not that Good.
It works in one machine but doesn't work in other.
Can you give me better code?
WFS.FromWMSLayer does not work in my case, I 'm using Mapserver.
The guy called Bart told me that he has code to make circle work instead of
box but didn't give the code since then.
Pl tell me how you got the selection layer working.
Thanks for your reply.
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/control-SelectFeature-tp4930933p4992935.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Okay, the basic code for circle selection in the GetFeature control is here:
http://trac.openlayers.org/ticket/2609
Please give it a try.
Best regards,
Bart
On Apr 27, 2010, at 10:20 AM, wrote:
> I've got some code lying around to do circle selection with the GetFeature
> control. If anybody is interested I can open up a ticket with a patch.
>
> Some handlers have a persist option which indicate whether or not the
> drawn geometry should persist (not be cleared after drawing), however the
> box Handler (used by the GetFeature Control in box mode) does not have it
> currently.
>
> Circle uses the RegularPolygon handler, and that one can persist if you want.
>
> Best regards,
> Bart
>
>> Hi,
>>
>> I think you cannot use a circle instead of a box. But you can change your
>> code to do a GeFeature-request with a filter, so you can request your
>> features around a circle area.
>> To question 1: I had same occurrence with the fast disappearing box- but I
>> think that has to do with event and style for wfs layer (see my other
>> post).
>>
>> Hope that helped a little bit.
>>
>> best regards
>> Sarah
>>
>>
>>
>>
>> ________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
|
# 10

21-09-2010 07:05 PM
|
|
|
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
Hi Sarah,
Have you tried to put your wfs2 layer on top of your layers (as the last
one added to the map) ? Only the top-most layer can have its features
selected, unless you add all the vector layers to the SelectFeature control.
Also, you could use only one layer (wfs2) for feature selection instead
of two. It seems kinda odd to copy features from one layer to an other
for the purpose of "selection". Check the first example about that
matter (the other is just to let you know of the cool 'highlight'
feature you might be interested into ):
http://www.openlayers.org/dev/examples/select-feature.html
http://www.openlayers.org/dev/examples/highlight-feature.html
Best regards,
Alexandre
Sarah Schuessler wrote:
> 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
>
>
> ------------------------------------------------------------------------
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Alexandre,
thanks for examples.
I went ahead with wfs-getfeature example selecting from a WFS.fromWMSLayer layer (changed this to simple wfs layer because I haven´t got a wms layer at my map right now)- but I get only a response at firebug not at my map because of different projection.
I have a viewport loading my layers:
xtype: "gx_mappanel",
map: map,
layers: [...,wfs2],
...
If I use map.addLayers(wfs2) after defining my layer my map is empty (no layers were loaded).
You said:
"unless you add all the vector layers to the SelectFeature control.
Also, you could use only one layer (wfs2) for feature selection instead
of two."
Can I use only one vector layer or more than one?
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Sarah,
Sarah Schuessler wrote:
> If I use map.addLayers(wfs2) after defining my layer my map is empty
> (no layers were loaded).
>
> You said:
> "unless you add all the vector layers to the SelectFeature control.
>
> Also, you could use only one layer (wfs2) for feature selection instead
> of two."
> Can I use only one vector layer or more than one?
If you have multiple layers of different types, let's say a 'city'
layer, a 'road' layer and a 'water' layer (all of them vector) and you
want to be able to select features from any of these layers, you can
define an array of layers to the SelectFeature control and you'll be
able to select any feature from any layer.
What you're currently doing is having a 'water' layer (I don't know what
is the type, but let's assume they are 'water' polygons) to display your
features and an other 'water' layer (that is empty) for feature
selection. Having 2 layers for just the purpose of selection seems odd
so that is why I proposed you should only have one.
Do you want your features to be always Vector of do you want to
'highlight' them only from drawing a box on the map ?
Also, do you have control on the feature server ? I mean, are you able
to add the missing projection on server-side ? That could resolve that
issue.
Kind regards,
--
Alexandre Dubé
Mapgears
www.mapgears.com
_______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Alexandre,
I think I mixed it all up.
I have included my event to my wfs2 layer and added feature to an empty vectorlayer (select):
wfs2.events.on({'featureselected': function(feature){
select.addFeatures([feature.feature]);},
'featureunselected': function(feature){..}
});
It worked.
If I use version 1.1.0 at GeFeature request (for server side reprojection) for my other kind of selection I get exception like: encode failed for value..(I think because of srs/epsg code, projection issue). I tried to change epsg code and some other things at geoserver but problem still remain.
I asked about this issue at geoserver list some time ago but could not solved it yet.
Thanks.
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Sarah,
I am trying to achieve the same thing that you did.I want to select a
portion within a wfs layer and view that selection in a different style.
I hope this is your requirement.
I find that you have taken a vector layer and a wfs layer and finally a
selectfeature
with a Control.SelectFeature.
Now I didn't understand your logic. Why it didn't work initially?
How it worked fine finally?
It would be great if you could explain your situation?
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/control-SelectFeature-tp4930933p4962622.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi,
I want to do the same like here: http://dev.openlayers.org/releases/OpenLayers-2.9/examples/getfeature-wfs.html and get information about selected feature(s) back.
I think that it didn`t work because of problems with geoserver wfs version (reproject) and/or params. I don`t know exactly (modified my code a few times;-)) (I`ve noticed that url at the control has to be same like the wfs/wms layer too)
So I still have problems with unselect (see other post).
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Sarah,
Have you been able to make the selection work with a layer over the region
of selection?
I need to get that working desperately.
My code is not that Good.
It works in one machine but doesn't work in other.
Can you give me better code?
WFS.FromWMSLayer does not work in my case, I 'm using Mapserver.
The guy called Bart told me that he has code to make circle work instead of
box but didn't give the code since then.
Pl tell me how you got the selection layer working.
Thanks for your reply.
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/control-SelectFeature-tp4930933p4992935.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Okay, the basic code for circle selection in the GetFeature control is here:
http://trac.openlayers.org/ticket/2609
Please give it a try.
Best regards,
Bart
On Apr 27, 2010, at 10:20 AM, wrote:
> I've got some code lying around to do circle selection with the GetFeature
> control. If anybody is interested I can open up a ticket with a patch.
>
> Some handlers have a persist option which indicate whether or not the
> drawn geometry should persist (not be cleared after drawing), however the
> box Handler (used by the GetFeature Control in box mode) does not have it
> currently.
>
> Circle uses the RegularPolygon handler, and that one can persist if you want.
>
> Best regards,
> Bart
>
>> Hi,
>>
>> I think you cannot use a circle instead of a box. But you can change your
>> code to do a GeFeature-request with a filter, so you can request your
>> features around a circle area.
>> To question 1: I had same occurrence with the fast disappearing box- but I
>> think that has to do with event and style for wfs layer (see my other
>> post).
>>
>> Hope that helped a little bit.
>>
>> best regards
>> Sarah
>>
>>
>>
>>
>> ________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi everyone,
I have SelectFeature Control which has multiple layers (3 actually).
Do any of know if it is possible to know from what layer does the
selectedFeature comes from ?
Thanks !
Ricardo
|
# 11

21-09-2010 07:22 PM
|
|
|
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
Hi Sarah,
Have you tried to put your wfs2 layer on top of your layers (as the last
one added to the map) ? Only the top-most layer can have its features
selected, unless you add all the vector layers to the SelectFeature control.
Also, you could use only one layer (wfs2) for feature selection instead
of two. It seems kinda odd to copy features from one layer to an other
for the purpose of "selection". Check the first example about that
matter (the other is just to let you know of the cool 'highlight'
feature you might be interested into ):
http://www.openlayers.org/dev/examples/select-feature.html
http://www.openlayers.org/dev/examples/highlight-feature.html
Best regards,
Alexandre
Sarah Schuessler wrote:
> 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
>
>
> ------------------------------------------------------------------------
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Alexandre,
thanks for examples.
I went ahead with wfs-getfeature example selecting from a WFS.fromWMSLayer layer (changed this to simple wfs layer because I haven´t got a wms layer at my map right now)- but I get only a response at firebug not at my map because of different projection.
I have a viewport loading my layers:
xtype: "gx_mappanel",
map: map,
layers: [...,wfs2],
...
If I use map.addLayers(wfs2) after defining my layer my map is empty (no layers were loaded).
You said:
"unless you add all the vector layers to the SelectFeature control.
Also, you could use only one layer (wfs2) for feature selection instead
of two."
Can I use only one vector layer or more than one?
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Sarah,
Sarah Schuessler wrote:
> If I use map.addLayers(wfs2) after defining my layer my map is empty
> (no layers were loaded).
>
> You said:
> "unless you add all the vector layers to the SelectFeature control.
>
> Also, you could use only one layer (wfs2) for feature selection instead
> of two."
> Can I use only one vector layer or more than one?
If you have multiple layers of different types, let's say a 'city'
layer, a 'road' layer and a 'water' layer (all of them vector) and you
want to be able to select features from any of these layers, you can
define an array of layers to the SelectFeature control and you'll be
able to select any feature from any layer.
What you're currently doing is having a 'water' layer (I don't know what
is the type, but let's assume they are 'water' polygons) to display your
features and an other 'water' layer (that is empty) for feature
selection. Having 2 layers for just the purpose of selection seems odd
so that is why I proposed you should only have one.
Do you want your features to be always Vector of do you want to
'highlight' them only from drawing a box on the map ?
Also, do you have control on the feature server ? I mean, are you able
to add the missing projection on server-side ? That could resolve that
issue.
Kind regards,
--
Alexandre Dubé
Mapgears
www.mapgears.com
_______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Alexandre,
I think I mixed it all up.
I have included my event to my wfs2 layer and added feature to an empty vectorlayer (select):
wfs2.events.on({'featureselected': function(feature){
select.addFeatures([feature.feature]);},
'featureunselected': function(feature){..}
});
It worked.
If I use version 1.1.0 at GeFeature request (for server side reprojection) for my other kind of selection I get exception like: encode failed for value..(I think because of srs/epsg code, projection issue). I tried to change epsg code and some other things at geoserver but problem still remain.
I asked about this issue at geoserver list some time ago but could not solved it yet.
Thanks.
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Sarah,
I am trying to achieve the same thing that you did.I want to select a
portion within a wfs layer and view that selection in a different style.
I hope this is your requirement.
I find that you have taken a vector layer and a wfs layer and finally a
selectfeature
with a Control.SelectFeature.
Now I didn't understand your logic. Why it didn't work initially?
How it worked fine finally?
It would be great if you could explain your situation?
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/control-SelectFeature-tp4930933p4962622.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi,
I want to do the same like here: http://dev.openlayers.org/releases/OpenLayers-2.9/examples/getfeature-wfs.html and get information about selected feature(s) back.
I think that it didn`t work because of problems with geoserver wfs version (reproject) and/or params. I don`t know exactly (modified my code a few times;-)) (I`ve noticed that url at the control has to be same like the wfs/wms layer too)
So I still have problems with unselect (see other post).
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Sarah,
Have you been able to make the selection work with a layer over the region
of selection?
I need to get that working desperately.
My code is not that Good.
It works in one machine but doesn't work in other.
Can you give me better code?
WFS.FromWMSLayer does not work in my case, I 'm using Mapserver.
The guy called Bart told me that he has code to make circle work instead of
box but didn't give the code since then.
Pl tell me how you got the selection layer working.
Thanks for your reply.
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/control-SelectFeature-tp4930933p4992935.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Okay, the basic code for circle selection in the GetFeature control is here:
http://trac.openlayers.org/ticket/2609
Please give it a try.
Best regards,
Bart
On Apr 27, 2010, at 10:20 AM, wrote:
> I've got some code lying around to do circle selection with the GetFeature
> control. If anybody is interested I can open up a ticket with a patch.
>
> Some handlers have a persist option which indicate whether or not the
> drawn geometry should persist (not be cleared after drawing), however the
> box Handler (used by the GetFeature Control in box mode) does not have it
> currently.
>
> Circle uses the RegularPolygon handler, and that one can persist if you want.
>
> Best regards,
> Bart
>
>> Hi,
>>
>> I think you cannot use a circle instead of a box. But you can change your
>> code to do a GeFeature-request with a filter, so you can request your
>> features around a circle area.
>> To question 1: I had same occurrence with the fast disappearing box- but I
>> think that has to do with event and style for wfs layer (see my other
>> post).
>>
>> Hope that helped a little bit.
>>
>> best regards
>> Sarah
>>
>>
>>
>>
>> ________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi everyone,
I have SelectFeature Control which has multiple layers (3 actually).
Do any of know if it is possible to know from what layer does the
selectedFeature comes from ?
Thanks !
Ricardo
Check feature.layer, e.g. in the onSelect handler.
Best regards,
Bart
--
Looking for flexible support on OpenLayers or GeoExt? Please check out http://www.osgis.nl/support.html
Bart van den Eijnden
OSGIS
On Sep 21, 2010, at 8:05 PM, Ricardo Bayley wrote:
> Hi everyone,
>
> I have SelectFeature Control which has multiple layers (3 actually).
> Do any of know if it is possible to know from what layer does the selectedFeature comes from ?
>
>
> Thanks !
>
>
> Ricardo
> _______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
|
# 12

21-09-2010 07:25 PM
|
|
|
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
Hi Sarah,
Have you tried to put your wfs2 layer on top of your layers (as the last
one added to the map) ? Only the top-most layer can have its features
selected, unless you add all the vector layers to the SelectFeature control.
Also, you could use only one layer (wfs2) for feature selection instead
of two. It seems kinda odd to copy features from one layer to an other
for the purpose of "selection". Check the first example about that
matter (the other is just to let you know of the cool 'highlight'
feature you might be interested into ):
http://www.openlayers.org/dev/examples/select-feature.html
http://www.openlayers.org/dev/examples/highlight-feature.html
Best regards,
Alexandre
Sarah Schuessler wrote:
> 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
>
>
> ------------------------------------------------------------------------
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Alexandre,
thanks for examples.
I went ahead with wfs-getfeature example selecting from a WFS.fromWMSLayer layer (changed this to simple wfs layer because I haven´t got a wms layer at my map right now)- but I get only a response at firebug not at my map because of different projection.
I have a viewport loading my layers:
xtype: "gx_mappanel",
map: map,
layers: [...,wfs2],
...
If I use map.addLayers(wfs2) after defining my layer my map is empty (no layers were loaded).
You said:
"unless you add all the vector layers to the SelectFeature control.
Also, you could use only one layer (wfs2) for feature selection instead
of two."
Can I use only one vector layer or more than one?
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Sarah,
Sarah Schuessler wrote:
> If I use map.addLayers(wfs2) after defining my layer my map is empty
> (no layers were loaded).
>
> You said:
> "unless you add all the vector layers to the SelectFeature control.
>
> Also, you could use only one layer (wfs2) for feature selection instead
> of two."
> Can I use only one vector layer or more than one?
If you have multiple layers of different types, let's say a 'city'
layer, a 'road' layer and a 'water' layer (all of them vector) and you
want to be able to select features from any of these layers, you can
define an array of layers to the SelectFeature control and you'll be
able to select any feature from any layer.
What you're currently doing is having a 'water' layer (I don't know what
is the type, but let's assume they are 'water' polygons) to display your
features and an other 'water' layer (that is empty) for feature
selection. Having 2 layers for just the purpose of selection seems odd
so that is why I proposed you should only have one.
Do you want your features to be always Vector of do you want to
'highlight' them only from drawing a box on the map ?
Also, do you have control on the feature server ? I mean, are you able
to add the missing projection on server-side ? That could resolve that
issue.
Kind regards,
--
Alexandre Dubé
Mapgears
www.mapgears.com
_______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Alexandre,
I think I mixed it all up.
I have included my event to my wfs2 layer and added feature to an empty vectorlayer (select):
wfs2.events.on({'featureselected': function(feature){
select.addFeatures([feature.feature]);},
'featureunselected': function(feature){..}
});
It worked.
If I use version 1.1.0 at GeFeature request (for server side reprojection) for my other kind of selection I get exception like: encode failed for value..(I think because of srs/epsg code, projection issue). I tried to change epsg code and some other things at geoserver but problem still remain.
I asked about this issue at geoserver list some time ago but could not solved it yet.
Thanks.
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Sarah,
I am trying to achieve the same thing that you did.I want to select a
portion within a wfs layer and view that selection in a different style.
I hope this is your requirement.
I find that you have taken a vector layer and a wfs layer and finally a
selectfeature
with a Control.SelectFeature.
Now I didn't understand your logic. Why it didn't work initially?
How it worked fine finally?
It would be great if you could explain your situation?
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/control-SelectFeature-tp4930933p4962622.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi,
I want to do the same like here: http://dev.openlayers.org/releases/OpenLayers-2.9/examples/getfeature-wfs.html and get information about selected feature(s) back.
I think that it didn`t work because of problems with geoserver wfs version (reproject) and/or params. I don`t know exactly (modified my code a few times;-)) (I`ve noticed that url at the control has to be same like the wfs/wms layer too)
So I still have problems with unselect (see other post).
best regards
Sarah
________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi Sarah,
Have you been able to make the selection work with a layer over the region
of selection?
I need to get that working desperately.
My code is not that Good.
It works in one machine but doesn't work in other.
Can you give me better code?
WFS.FromWMSLayer does not work in my case, I 'm using Mapserver.
The guy called Bart told me that he has code to make circle work instead of
box but didn't give the code since then.
Pl tell me how you got the selection layer working.
Thanks for your reply.
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/control-SelectFeature-tp4930933p4992935.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Okay, the basic code for circle selection in the GetFeature control is here:
http://trac.openlayers.org/ticket/2609
Please give it a try.
Best regards,
Bart
On Apr 27, 2010, at 10:20 AM, wrote:
> I've got some code lying around to do circle selection with the GetFeature
> control. If anybody is interested I can open up a ticket with a patch.
>
> Some handlers have a persist option which indicate whether or not the
> drawn geometry should persist (not be cleared after drawing), however the
> box Handler (used by the GetFeature Control in box mode) does not have it
> currently.
>
> Circle uses the RegularPolygon handler, and that one can persist if you want.
>
> Best regards,
> Bart
>
>> Hi,
>>
>> I think you cannot use a circle instead of a box. But you can change your
>> code to do a GeFeature-request with a filter, so you can request your
>> features around a circle area.
>> To question 1: I had same occurrence with the fast disappearing box- but I
>> think that has to do with event and style for wfs layer (see my other
>> post).
>>
>> Hope that helped a little bit.
>>
>> best regards
>> Sarah
>>
>>
>>
>>
>> ________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
Hi everyone,
I have SelectFeature Control which has multiple layers (3 actually).
Do any of know if it is possible to know from what layer does the
selectedFeature comes from ?
Thanks !
Ricardo
Check feature.layer, e.g. in the onSelect handler.
Best regards,
Bart
--
Looking for flexible support on OpenLayers or GeoExt? Please check out http://www.osgis.nl/support.html
Bart van den Eijnden
OSGIS
On Sep 21, 2010, at 8:05 PM, Ricardo Bayley wrote:
> Hi everyone,
>
> I have SelectFeature Control which has multiple layers (3 actually).
> Do any of know if it is possible to know from what layer does the selectedFeature comes from ?
>
>
> Thanks !
>
>
> Ricardo
> _______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
On 09/21/2010 01:05 PM, Ricardo Bayley wrote:
> I have SelectFeature Control which has multiple layers (3 actually).
> Do any of know if it is possible to know from what layer does the
> selectedFeature comes from ?
On my maps, given a vector layer called "cameras", I do it like this:
sidebar_new = function (e) {
if (e.feature.layer === cameras) {
/* Code goes here. */
}
...
};
hover = new OpenLayers.Control.SelectFeature(
[
cameras,
...
],
{
clickout: false,
hover: true,
highlightOnly: true,
multiple: false,
toggle: false,
eventListeners: {
featurehighlighted: sidebar_new,
featureunhighlighted: sidebar_del
}
}
);
map.addControl(hover);
Hope that helps!
_______________________________________________
___________________________________________________
Posted on the Users mailing list. Go to http://openlayers.org/mailman/listinfo/users to subscribe.
|
NewsArc Lists
| Culture Pages
| Computing Archive
| Media-Pages
Link to this page on your blog or website by copying the HTML code below and pasting it into your site:
|
|