[OpenLayers-Users] SelectFeature WFS => FeatureInfo
Tim Balschmiter
tb.rostock at gmail.com
Wed Feb 6 05:42:09 PST 2013
HI list,
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 (
http://dev.openlayers.org/releases/OpenLayers-2.12/examples/select-feature-multilayer.html
).
So here is my code with some comments:
var map;
OpenLayers.ImgPath = "oltheme_dark/";
OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";
function init()
{
var bounds = new
OpenLayers.Bounds(1000000.1,7000000.1,2000000.0,8000000.56); //only as an
example
map = new OpenLayers.Map("map",
{
restrictedExtent: bounds,
controls: [
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.MousePosition()
],
numZoomLevels:12,
units:"m",
projection: "EPSG:4326",
displayProjection: new OpenLayers.Projection("EPSG:900913")
});
layer = new OpenLayers.Layer.OSM( "Simple OSM Map");
map.addLayer(layer);
var pointLayer = new OpenLayers.Layer.Vector("Points",
{
protocol: new OpenLayers.Protocol.WFS
({
url:"http://localhost:8080/geoserver/wfs",
featureType:"mypointsofinteressts", //only some testpoints
featureNS:"iamlearning.de/", //only a fantasydomain
version: "1.1.0",
extractAttributes: true
}),
strategies:[
new OpenLayers.Strategy.BBOX(),
new OpenLayers.Strategy.Cluster({distance:15})
]
});
map.addLayer(pointLayer);
var select = new OpenLayers.Control.SelectFeature
(
pointLayer,
{
hover: false,
toggle: true
}
);
map.addControl(select);
select.activate();
pointLayer.events.on({
"featureselected": function(e) {
alert(e.toSource()); // works fine, but i am
getting the hole gml
alert(e.feature.id); // feature is not
defined, but why in the example is "feature" not defined too
},
"featureunselected": function(e) {
}
});
map.zoomToMaxExtent();
}
I hope someone can help me.
thanks a lot
Tim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130206/6bef2b8f/attachment.html>
More information about the Users
mailing list