[OpenLayers-Users] Can't define hover behavior on a Feature.Vector or a Layer.Vector
Xavier Mamano (jorix)
xavier.mamano at gmail.com
Fri Aug 30 07:12:49 PDT 2013
Ih Ruben,
> However, if anyone can point me if this is a bug or not.
Is not a bug, `vectors.events.on({"featureselected": ...` works if there is
some piece of code that *selects the feature*. Usually a SelectFeature
control.
NOTE: Is not necessary to use `vectors.events.on` to highlight, it is
preferable to use a styleMap with a "default" & "select" keys on a
Layer.Vector.
See example: http://openlayers.org/dev/examples/highlight-feature.html (uses
the default styleMap)
> ...define hover behavior on a Feature.Vector or Layer.Vector
styleMap is only supported on Layer.Vector (I use a patch to use styleMap on
feature, but only in exceptional cases as highlight a KML + extractStyles)
Regrads,
Xavier
ramaralo wrote
> 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@
> <
> diegoguidi@
> >
> To:
> mail.roliveira@
> <
> mail.roliveira@
> >
> cc:
> openlayers-users at .osgeo
> <
> openlayers-users at .osgeo
> >
> 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@
> <
> mail.roliveira@
> > 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
>
> _______________________________________________
> Users mailing list
> Users at .osgeo
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Can-t-define-hover-behavior-on-a-Feature-Vector-or-a-Layer-Vector-tp5074269p5075231.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list