[OpenLayers-Users] SelectFeature WFS => FeatureInfo

Xavier Mamano (jorix) xavier.mamano at gmail.com
Wed Feb 6 11:24:12 PST 2013


Hi Tim,

You use Strategy.Custer so you have to look for features in the array
`e.feature.cluster`. 

If you want to simplify your work you could use
https://github.com/jorix/OL-FeaturePopups

Regards,

Xavier Mamano


Tim Balschmiter wrote
> 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
> 
> _______________________________________________
> Users mailing list

> Users at .osgeo

> http://lists.osgeo.org/mailman/listinfo/openlayers-users





--
View this message in context: http://osgeo-org.1560.n6.nabble.com/SelectFeature-WFS-FeatureInfo-tp5032473p5032576.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list