[OpenLayers-Users] Can't define hover behavior on a Feature.Vector or a Layer.Vector

mail.roliveira at gmail.com mail.roliveira at gmail.com
Tue Aug 27 08:07:08 PDT 2013


I guess it is. I'm going deeper in documentation and found this on the drawFeature method:


«
drawFeature: function(feature,style)
Draw (or redraw) a feature on the layer.   If the optional style 
argument is included, this style will be used.   If no style is 
included, the feature’s style will be used.   If the feature doesn’t 
have a style, the layer’s style will be used.
»


Taken from: 
http://dev.openlayers.org/releases/OpenLayers-2.6/doc/apidocs/files/OpenLayers/Layer/Vector-js.html#OpenLayers.Layer.Vector.drawFeature


I'm assuming that when a feature gets selected, it is redrawn. And since it has a style attached, that's the style OL uses.


However, I'm also doing this:



vectorLayer.events.on({"featureselected": function(e) {
                console.log(logId, e.feature); // confirmes that I'm getting a feature
                var layer = e.feature.layer
;                layer.drawFeature(e.feature, "select")
;            }})


;But this doesn't work either. From the docs, it should work since the select is a render intent defined on the layer styleMap (If there is a bug, it is here).


However, this does work:

vectorLayer.events.on({"featureselected": function(e) {
                console.log(logId, e.feature)
;                var layer = e.feature.layer
;                layer.drawFeature(e.feature, {fillCollor: "#000000"})
;            }})


;I guess I'm going to have to live with this solution since it works for me and the select style is made on the layer "level".


However, if anyone can point me if this is a bug or not, I would appreciate, since I'd like to "give something back" to community (although a bug is not what I call a gift... :) )


I guess there is no need to bother you with sample code (unless you absolutely demand for it :) )


Thank you Diego!
Greetings from Portugal!


Ruben.


Sent from Alto - altomail.com


From: diegoguidi at gmail.com<diegoguidi at gmail.com>
To: mail.roliveira at gmail.com<mail.roliveira at gmail.com>
cc: openlayers-users at lists.osgeo.org<openlayers-users at lists.osgeo.org>
Sent: Tuesday, August 27, 2013
Subject: Re: [OpenLayers-Users] Can't define hover behavior on a Feature.Vector or a Layer.Vector

On Tue, Aug 27, 2013 at 4:27 PM, mail.roliveira at gmail.com
<mail.roliveira at gmail.com> wrote:
> Could this be a bug?
this is exactly how openlayers works, if you override the default
style using feature.style, this style is used.



Diego Guidi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130827/23b345c9/attachment.html>


More information about the Users mailing list