<div style="font-family: arial, helvetica, sans-serif; font-size: small; ">Hi Diego,</div><div style="font-family: arial, helvetica, sans-serif; font-size: small; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: small; ">Thank you for you answer.</div><div style="font-family: arial, helvetica, sans-serif; font-size: small; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: small; ">That was my first approach.</div><div style="font-family: arial, helvetica, sans-serif; font-size: small; ">I realized that:</div><div style="font-family: arial, helvetica, sans-serif; font-size: small; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: small; "><span style="font-family: alto-font, arial; font-size: 14px; ">var fv = new OpenLayers.Feature.Vector(linearRing, {}</span><span style="font-family: alto-font, arial; font-size: 14px; ">, </span>{strokeWidth: "#123456" ,strokeColor: "#123456", fillColor: "#123456", fillOpacity: "#123456"}<span style="font-family: alto-font, arial; font-size: 14px; ">);</span></div><div style="font-family: arial, helvetica, sans-serif; font-size: small; "><span style="font-family: alto-font, arial; font-size: 14px; "><br></span></div><div style="font-family: arial, helvetica, sans-serif; font-size: small; "><span style="font-family: alto-font, arial; font-size: 14px; ">is the same as:</span></div><div style="font-family: arial, helvetica, sans-serif; font-size: small; "><span style="font-family: alto-font, arial; font-size: 14px; "><br></span></div><div style="font-family: arial, helvetica, sans-serif; font-size: small; "><span style="font-family: alto-font, arial; font-size: 14px; ">var fv = new OpenLayers.Feature.Vector(linearRing</span><span style="font-family: alto-font, arial; font-size: 14px; ">);</span></div><div style="font-family: arial, helvetica, sans-serif; font-size: small; ">fv.style = {strokeWidth: "#123456" ,strokeColor: "#123456", fillColor: "#123456", fillOpacity: "#123456"};</div><div style="font-family: arial, helvetica, sans-serif; font-size: small; "><br></div><div><font face="alto-font, arial"><span style="font-size: 14px;">The thing is, I'm only defining one style. What I need is a style for "default" and a style for "select" but </span></font><span style="font-family: alto-font, arial; font-size: 14px; "> </span><span style="font-family: alto-font, arial; font-size: 14px; ">OpenLayers.Feature.Vector doesn't support an </span><a href="http://dev.openlayers.org/docs/files/OpenLayers/StyleMap-js.html#OpenLayers.StyleMap" class="LClass"><font face="arial, helvetica, sans-serif">OpenLayers.StyleMap</font></a> <font face="arial, helvetica, sans-serif" size="2">like the OpenLayers.Layer.Vector does. If an OpenLayers.StyleMap was supported I could define a renderIntent and therefore maybe implement the select behaviour.</font></div><div style="font-family: arial, helvetica, sans-serif; font-size: small; "><span style="font-family: alto-font, arial; font-size: 14px; "><br></span></div><div style="font-family: arial, helvetica, sans-serif; font-size: small; "><br><br><br></div><div class="">Sent from Alto - altomail.com</div><br><br><br><hr style="border:0;height:1px;color:#999;background-color:#999;width:100%;margin:0 0 9px 0;padding:0;"><b>From: </b>diegoguidi@gmail.com<diegoguidi@gmail.com><br><b>To: </b>mail.roliveira@gmail.com<mail.roliveira@gmail.com><br><b>cc: </b>openlayers-users@lists.osgeo.org<openlayers-users@lists.osgeo.org><br><b>Sent: </b>Monday, August 26, 2013<br><b>Subject: </b>Re: [OpenLayers-Users] Can't define hover behavior on a Feature.Vector or a Layer.Vector<br><br><title></title>Why you can't define a stylemap for "default" feature visibility?<br>You need some computation inside the loop to build a style for the feature?<br><br>Anyway, try to pass the style as a Style objectdirectly in the Vector<br>constructor, ie:<br>var yourstyle = new Openlayers.Style({strokeWidth: "#123456"<br>,strokeColor: "#123456", fillColor: "#123456", fillOpacity:<br>"#123456"});<br>var fv = new OpenLayers.Feature.Vector(linearRing, {/*empty<br>attributes*/, yourstyle);<br><br>Diego Guidi<br><br><br>On Mon, Aug 26, 2013 at 11:29 AM, <a href="mailto:mail.roliveira@gmail.com">mail.roliveira@gmail.com</a><br><<a href="mailto:mail.roliveira@gmail.com">mail.roliveira@gmail.com</a>> wrote:<br>> Hi.<br>><br>> I'm facing what appears to be a simple problem but there is something<br>> missing that I can't figure it out what it is...<br>><br>> Hi have this layer:<br>><br>> var layer_style = new OpenLayers.StyleMap({<br>>             "select": new OpenLayers.Style(OpenLayers.Util.applyDefaults({<br>>             fillColor: "#626262",<br>>             strokeColor: "#111111"},<br>> OpenLayers.Feature.Vector.style["select"]))<br>>         });<br>><br>> var vectorLayer = new OpenLayers.Layer.Vector("prach layer", {<br>> styleMap: layer_style,<br>> renderers: ['SVG', 'VML', 'Canvas']<br>> });<br>><br>><br>><br>> And have several OpenLayers.Feature.Vector instances that are added to<br>> vectorLayer:<br>><br>> features = [];<br>><br>> // START: for loop that sets different colors on each iteraction<br>> var fv = new OpenLayers.Feature.Vector(linearRing); // linearRing is an<br>> instance of OpenLayers.Geometry.LinearRing determined previously<br>><br>> fv.style = {strokeWidth: "#123456" ,strokeColor: "#123456", fillColor:<br>> "#123456", fillOpacity: "#123456"};<br>><br>> features.push(fv);<br>> // END: for loop that sets different colors on each iteraction<br>><br>> vectorLayer.addFeatures(features);<br>><br>> ==<br>><br>> My problem is:<br>><br>> If I click on each created shape the shape doesn't get selected as I would<br>> expect from the layer_style definition.<br>> But if I remove the style from each Feature.Vector, then the select behavior<br>> works. However, I really need to have a style on each Feature.Vector.<br>><br>> I can't figure out why the layer select behavior isn't working.<br>> As an alternative, is it possible to have a select style (as a render<br>> intent) on the Feature.Vector, instead of having it on the layer? From the<br>> docs, it seem this is not possible since the Feature.Vector only allows a<br>> style definition that maps the SVG style directives<br>> (<a href="http://dev.openlayers.org/docs/files/OpenLayers/Feature/Vector-js.html#OpenLayers.Feature.Vector.OpenLayers.Feature.Vector.style">http://dev.openlayers.org/docs/files/OpenLayers/Feature/Vector-js.html#OpenLayers.Feature.Vector.OpenLayers.Feature.Vector.style</a>).<br>><br>> On firebug, I can see that each Feature.Vector has a renderIntent set to<br>> 'default', so I deduce a Feature.Vector also has a renderIntent (probably<br>> inherited from the layer's renderIntent?).<br>><br>> Any idea on how to solve this?<br>><br>> Thanks in advance.<br>> Ruben.<br>><br>> _______________________________________________<br>> Users mailing list<br>> <a href="mailto:Users@lists.osgeo.org">Users@lists.osgeo.org</a><br>> <a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a><br>><br>