[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
Mon Aug 26 02:29:08 PDT 2013


Hi.
I'm facing what appears to be a simple problem but there is something missing that I can't figure it out what it is...
Hi have this layer:
var layer_style = new OpenLayers.StyleMap({            "select": new OpenLayers.Style(OpenLayers.Util.applyDefaults({            	fillColor: "#626262",            	strokeColor: "#111111"}, OpenLayers.Feature.Vector.style["select"]))        })
;var vectorLayer = new OpenLayers.Layer.Vector("prach layer", {			styleMap: layer_style,			renderers: ['SVG', 'VML', 'Canvas']			})


;And have several OpenLayers.Feature.Vector instances that are added to vectorLayer:
features = []
;// START: for loop that sets different colors on each iteractionvar fv = new OpenLayers.Feature.Vector(linearRing); // linearRing is an instance of OpenLayers.Geometry.LinearRing determined previously
fv.style = {strokeWidth: "#123456" ,strokeColor: "#123456", fillColor: "#123456", fillOpacity: "#123456"}
;features.push(fv);// END: for loop that sets different colors on each iteraction
vectorLayer.addFeatures(features)
;==
My problem is:
If I click on each created shape the shape doesn't get selected as I would expect from the layer_style definition.But if I remove the style from each Feature.Vector, then the select behavior works. However, I really need to have a style on each Feature.Vector.
I can't figure out why the layer select behavior isn't working.As an alternative, is it possible to have a select style (as a render intent) on the Feature.Vector, instead of having it on the layer? From the docs, it seem this is not possible since the Feature.Vector only allows a style definition that maps the SVG style directives (http://dev.openlayers.org/docs/files/OpenLayers/Feature/Vector-js.html#OpenLayers.Feature.Vector.OpenLayers.Feature.Vector.style).
On firebug, I can see that each Feature.Vector has a renderIntent set to 'default', so I deduce a Feature.Vector also has a renderIntent (probably inherited from the layer's renderIntent?).
Any idea on how to solve this?
Thanks in advance.Ruben.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130826/f679221c/attachment.html>


More information about the Users mailing list