WMS/WFS getfeature on hover, problem to display the GML (mapserver)
I had a hard time programming something similar to the "WFS GetFeature Example" shown in the OpenLayers examples, the example uses calls to a WFS/WMS services that have the same name and data origin.
The WFS/WMS service call is done with the OpenLayers.Protocol.WFS.fromWMSLayer as follows (the layerWMS is a OpenLayrs.Layer.WMS object)
control = new OpenLayers.Control.GetFeature({
protocol: OpenLayers.Protocol.WFS.fromWMSLayer(layerWMS),
hover: true
});
Using firebug it is possible to see the requests going back-and-forward when hovering the polygons, but in the end the polygons aren't select, because trigger-events aren't called.
The problem is cause by the namespace used in the WFS of mapserver (since the example given in the web site uses geoserver, everything is ok), the solution is to indicate the namespace and featureTypeName.
In my mapserver response I have something like this:
<gml:featureMember>
<ms:wdpa gml:id="wdpa.67886">
Therefore control has to be changed as follows:
control = new OpenLayers.Control.GetFeature({
protocol: OpenLayers.Protocol.WFS.fromWMSLayer(layerWMS,{featureType:"wdpa",featurePrefix:"ms"}),
hover: true
});
It seems that the same has to be done for the standard WFS layer when using mapserver.
Labels: cannot be displayed, fromWMSLayer, problem, trigger
5 Comments:
Hi,
I've the same problem, and I've tried to fix it using your advice, but I'm still unable to request data from WMS layers :(
I've noticed, you have
and I have only fid:
Any idea?
the missing part was:
I've noticed you have
gml:featureMember
ms:wdpa gml:id="wdpa.67886"
but I only have fid instead of gml:id
gml:featureMember
ms:elteresek fid="elteresek.1"
Hi
Normally attributes in XML don't have spacenames, in my case mapserver uses it (gml:id="wdpa.67886"). So probably you can't get things to work because you set a namespace and then Openlayers excepts for all the tag and attribute content to have the specific namespace
If you have problems send me an email
jorge.de-jesus__AT__jrc.it
Thanks for post. It’s really informative stuff.
I really like to read.Hope to learn a lot and have a nice experience here! my best regards guys!
Never I had issues about it. Easy to follow.
Post a Comment
<< Home