<br clear="all"><div><br></div>HI list,
<div>i want to get a featureinfo of an wfs-feature. I get my wfs from the geoserver. I can select a feature, but i don´t get any informations about it. I have used that example (<a href="http://dev.openlayers.org/releases/OpenLayers-2.12/examples/select-feature-multilayer.html">http://dev.openlayers.org/releases/OpenLayers-2.12/examples/select-feature-multilayer.html</a>).</div>
<div><br></div><div>So here is my code with some comments:</div><div><br></div><div><div>var map;</div><div>OpenLayers.ImgPath = "oltheme_dark/";</div><div>OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";</div>
<div>function init()</div><div>{</div><div> var bounds = new OpenLayers.Bounds(1000000.1,7000000.1,2000000.0,8000000.56); //only as an example</div><div> map = new OpenLayers.Map("map",</div><div> {</div><div>
restrictedExtent: bounds,</div><div> controls: [</div><div> new OpenLayers.Control.Navigation(),</div><div> new OpenLayers.Control.PanZoomBar(),</div><div> new OpenLayers.Control.MousePosition()</div>
<div> ],</div><div> numZoomLevels:12,</div><div> units:"m",</div><div> projection: "EPSG:4326",</div><div> displayProjection: new OpenLayers.Projection("EPSG:900913")</div>
<div> });</div><div> layer = new OpenLayers.Layer.OSM( "Simple OSM Map");</div><div> map.addLayer(layer);</div><div> </div><div> </div><div> var pointLayer = new OpenLayers.Layer.Vector("Points",</div>
<div> {</div><div> protocol: new OpenLayers.Protocol.WFS</div><div> ({</div><div> url:"<a href="http://localhost:8080/geoserver/wfs">http://localhost:8080/geoserver/wfs</a>",</div>
<div> featureType:"mypointsofinteressts", //only some testpoints</div><div> featureNS:"<a href="http://iamlearning.de/">iamlearning.de/</a>", //only a fantasydomain </div><div>
version: "1.1.0",</div><div> extractAttributes: true</div><div> }),</div><div> strategies:[</div><div> new OpenLayers.Strategy.BBOX(),</div><div> new OpenLayers.Strategy.Cluster({distance:15})</div>
<div> ]</div><div> });</div><div> map.addLayer(pointLayer);</div><div> var select = new OpenLayers.Control.SelectFeature</div><div> (</div><div> pointLayer, </div>
<div> {</div><div> hover: false,</div><div> toggle: true </div><div> }</div><div> );</div><div> map.addControl(select); </div>
<div> select.activate();</div><div> </div><div> pointLayer.events.on({</div><div> "featureselected": function(e) {</div><div> alert(e.toSource()); // works fine, but i am getting the hole gml </div>
<div> alert(<a href="http://e.feature.id">e.feature.id</a>); // feature is not defined, but why in the example is "feature" not defined too</div><div> },</div><div> "featureunselected": function(e) {</div>
<div> </div><div> }</div><div> });</div><div> </div><div> map.zoomToMaxExtent();</div><div>}</div></div><div><br></div><div><br></div><div><br></div><div>I hope someone can help me.</div>
<div>thanks a lot</div><div>Tim</div>