Hi guys,<div><br></div><div>I've got a vector layer that I initialize with the following code:<br clear="all"><div><font class="Apple-style-span" face="'courier new', monospace">var vector_style = new OpenLayers.StyleMap(OpenLayers.Util.applyDefaults({</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>strokeColor:'yellow',</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>fillOpacity:0.0,</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>strokeOpacity:1,</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>strokeWidth: 2,</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>fillOpacity:0.1</font><span class="Apple-style-span" style="font-family: 'courier new', monospace; "><span class="Apple-tab-span" style="white-space:pre">        </span></span><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">},</span></div>
</div><span class="Apple-tab-span" style="white-space:pre">        </span> <span class="Apple-style-span" style="font-family: 'courier new', monospace; ">OpenLayers.Feature.Vector.style["default"]));</span><br>
<blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace; "><span class="Apple-tab-span" style="white-space:pre">        </span></span></div>
</div></blockquote><div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">vectorLayer.styleMap = </span><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">vector_style</span><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">;</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace; "><br></span></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif">This renders fine, I get yellow vector features that turn blue when I hover over them (per default)</font></div>
<div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><br></font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif">The problem is that later on I have an event that styles each feature depending on a certain condition, the event is something like the following:</font></div>
<div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><br></font></div><div><div><font class="Apple-style-span" face="'courier new', monospace">var feats =map.layers[22].features;</font></div><div>
<font class="Apple-style-span" face="'courier new', monospace">var lengd = feats.length;</font></div><div><font class="Apple-style-span" face="'courier new', monospace">cursize = 2;</font></div><div><font class="Apple-style-span" face="'courier new', monospace">for(var i=lengd-1 ;i>=0 ;i--)</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">{</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> if(feats[i+1]!==undefined)</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>{</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> if(feats[i].geometry.intersects(feats[i+1].geometry))</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-tab-span" style="white-space:pre">                        </span>cursize++;</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> else</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> cursize = 2;</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>}</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>feats[i].style = OpenLayers.Util.applyDefaults(</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> {</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-tab-span" style="white-space:pre">                </span>graphicZIndex : (lengd-i)+1000,</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-tab-span" style="white-space:pre">                </span>strokeColor : "#"+genHex(),</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-tab-span" style="white-space:pre">                </span>fillOpacity : 0.03,</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-tab-span" style="white-space:pre">                </span>pointRadius : 7*(cursize)</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>},</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> OpenLayers.Feature.Vector.style["select"]);</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">}</font></div></div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif">The code above loops through the features array </font><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif; ">(these are all Points)</span><font class="Apple-style-span" face="arial, helvetica, sans-serif">, and if it finds </font><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif; ">features</span><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif; "> </span><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif; ">adjacent to each other in the array which also intersect/share the same location - it draws them in bigger and bigger increments.</span></div>
<div><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif; "><br></span></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif">The code works fine, except for the fact that I lose the select </font><font class="Apple-style-span" face="arial, helvetica, sans-serif">behavior from before (the points don't turn blue when I hover over them). </font></div>
<div></div><div><br></div>Firebug reveals that the style object that I assign to the features contain hoverStrokeColor, hoverFillColor etc, but these don't seem to do anything.</div><div><br></div><div>Does anybody have ideas?</div>
<div><br></div><div>Kind regards from Iceland,</div><div>Gissur</div><div><br></div><div>-- <br>Gissur Þórhallsson<br><br>Loftmyndir ehf.<br>Laugavegur 13<br>IS 101 Reykjavík - Iceland<br>sími (tel): (+354) 540 2500<br>tölvupóstur (email): <a href="mailto:gissur@loftmyndir.is">gissur@loftmyndir.is</a><br>
</div>