[OpenLayers-Users] Some question to OpenLayers.Protocol.WFS.fromWMSLayer

Andreas Hocevar ahocevar at opengeo.org
Tue Jul 28 10:42:41 EDT 2009


Hi Kai,

Kai Behncke wrote:
> thank you for that hint, but unfortunately it doesn` work (well, the pixel tolerance works but then the coordinate is not fitted and it gives an "empty"-WFS result).
>
>   
>> var xyz = new OpenLayers.Control.GetFeature(
>>   {
>>     protocol: OpenLayers.Protocol.WFS.fromWMSLayer(layer),
>>     hover: true,
>>     styleMap: style_obj1
>>     handlerOptions : {
>>       hover: {
>>         pixelTolerance : 10
>>       }
>>     }
>>   }
>> );
>>     

Almost. The snippet below should work:

var xyz = new OpenLayers.Control.GetFeature(
  {
    protocol: OpenLayers.Protocol.WFS.fromWMSLayer(layer),
    hover: true,
    clickTolerance: 10
  }
);


Maybe the name of that property (*click*Tolerance) is misleading, but
that one is used for every request. I just fixed the docs, now at least
there is a hint that this is also for requests on hover.

Also note that Control.GetFeature cannot be configured with a styleMap.
You have to do this on the layer.

Regards,
Andreas.

>>>            var xyz = new OpenLayers.Control.GetFeature({
>>>                 protocol: OpenLayers.Protocol.WFS.fromWMSLayer(layer),
>>>                 hover: true,
>>>                 styleMap: style_obj1
>>>             });
>>>       
>>>             xyz.events.register("hoverfeature", this, function(e) {
>>>         hover.addFeatures([e.feature]);
>>>    });
>>>             map.addControl(xyz);
>>>             xyz.activate();
>>>
>>>
>>>
>>>
>>>       
>>> 2) Even I declared an own style in the "var xyz"-section I still get the
>>>       
>> typical-wfs-orange-opacity style.
>>     
>>> If I write:
>>>
>>> var my_feature = new OpenLayers.Feature.Vector(e.feature.geometry,null,
>>>       
>> style_obj1);
>>     
>>> hover.addFeatures([my_feature]);   
>>>
>>> I get what I want, but I wonder if there is a ways doing something like
>>>
>>>  hover.addFeatures([e.feature],{styleMap: style_obj1}); ??? (it doesn`t
>>>       
>> work in this way).
>>     
>>> Thank you very much, Kai
>>>       
>
>   


-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.




More information about the Users mailing list