<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.19046"></HEAD>
<BODY>
<DIV dir=ltr align=left><FONT color=#0000ff size=2 face=Arial><SPAN 
class=234590820-18052011>i'm not sure, but if you add a style to a feature 
instead a styleMap to the layer, you can't add a select 
style.</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT color=#0000ff size=2 face=Arial><SPAN 
class=234590820-18052011></SPAN></FONT><FONT color=#0000ff size=2 
face=Arial><SPAN class=234590820-18052011></SPAN></FONT>&nbsp;</DIV>
<DIV dir=ltr align=left><FONT color=#0000ff size=2 face=Arial><SPAN 
class=234590820-18052011>But there is a property selectStyle for the 
SelectFeatureControl.<BR>It should also work, when the features have there own 
style.<BR></SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT color=#0000ff size=2 
face=Arial>//ctrlSelectFeature = new 
OpenLayers.Control.SelectFeature(...)<BR>var selectStyle = 
OpenLayers.Feature.Vector.style['select'];<BR>ctrlSelectFeature.selectStyle = 
selectStyle;<BR></FONT></DIV>
<DIV dir=ltr align=left><SPAN class=234590820-18052011><FONT color=#0000ff 
size=2 face=Arial>Arnd</FONT></SPAN></DIV><BR>
<DIV dir=ltr lang=de class=OutlookMessageHeader align=left>
<HR tabIndex=-1>
<FONT size=2 face=Tahoma><B>Von:</B> openlayers-users-bounces@lists.osgeo.org 
[mailto:openlayers-users-bounces@lists.osgeo.org] <B>Im Auftrag von </B>Gissur 
Þórhallsson<BR><B>Gesendet:</B> Mittwoch, 18. Mai 2011 19:13<BR><B>An:</B> 
openlayers-users@lists.osgeo.org<BR><B>Betreff:</B> [OpenLayers-Users] 
OpenLayers.Feature.style 
vs.OpenLayers.Layer.Vector.styleMap<BR></FONT><BR></DIV>
<DIV></DIV>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 = &nbsp;new 
OpenLayers.StyleMap(OpenLayers.Util.applyDefaults({</FONT></DIV>
<DIV><FONT class=Apple-style-span face="'courier new', monospace"><SPAN 
style="WHITE-SPACE: pre" 
class=Apple-tab-span></SPAN>strokeColor:'yellow',</FONT></DIV>
<DIV><FONT class=Apple-style-span face="'courier new', monospace"><SPAN 
style="WHITE-SPACE: pre" 
class=Apple-tab-span></SPAN>fillOpacity:0.0,</FONT></DIV>
<DIV><FONT class=Apple-style-span face="'courier new', monospace"><SPAN 
style="WHITE-SPACE: pre" 
class=Apple-tab-span></SPAN>strokeOpacity:1,</FONT></DIV>
<DIV><FONT class=Apple-style-span face="'courier new', monospace"><SPAN 
style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>strokeWidth: 
2,</FONT></DIV>
<DIV><FONT class=Apple-style-span face="'courier new', monospace"><SPAN 
style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>fillOpacity:0.1</FONT><SPAN 
style="FONT-FAMILY: 'courier new', monospace" class=Apple-style-span><SPAN 
style="WHITE-SPACE: pre" class=Apple-tab-span> </SPAN></SPAN><SPAN 
style="FONT-FAMILY: 'courier new', monospace" 
class=Apple-style-span>},</SPAN></DIV></DIV><SPAN style="WHITE-SPACE: pre" 
class=Apple-tab-span></SPAN>&nbsp; &nbsp; &nbsp; &nbsp;<SPAN 
style="FONT-FAMILY: 'courier new', monospace" 
class=Apple-style-span>OpenLayers.Feature.Vector.style["default"]));</SPAN><BR>
<BLOCKQUOTE 
style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 40px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: medium none; BORDER-RIGHT: medium none; PADDING-TOP: 0px" 
class=webkit-indent-blockquote>
  <DIV>
  <DIV><SPAN style="FONT-FAMILY: 'courier new', monospace" 
  class=Apple-style-span><SPAN style="WHITE-SPACE: pre" 
  class=Apple-tab-span></SPAN></SPAN></DIV></DIV></BLOCKQUOTE>
<DIV>
<DIV><SPAN style="FONT-FAMILY: 'courier new', monospace" 
class=Apple-style-span>vectorLayer.styleMap =&nbsp;</SPAN><SPAN 
style="FONT-FAMILY: 'courier new', monospace" 
class=Apple-style-span>vector_style</SPAN><SPAN 
style="FONT-FAMILY: 'courier new', monospace" 
class=Apple-style-span>;</SPAN></DIV>
<DIV><SPAN style="FONT-FAMILY: 'courier new', monospace" 
class=Apple-style-span><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&gt;=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">&nbsp; &nbsp; 
if(feats[i+1]!==undefined)</FONT></DIV>
<DIV><FONT class=Apple-style-span face="'courier new', monospace"><SPAN 
style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>{</FONT></DIV>
<DIV><FONT class=Apple-style-span face="'courier new', monospace">&nbsp; &nbsp; 
&nbsp; &nbsp; if(feats[i].geometry.intersects(feats[i+1].geometry))</FONT></DIV>
<DIV><FONT class=Apple-style-span face="'courier new', monospace"><SPAN 
style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>cursize++;</FONT></DIV>
<DIV><FONT class=Apple-style-span face="'courier new', monospace">&nbsp; &nbsp; 
&nbsp; &nbsp; else</FONT></DIV>
<DIV><FONT class=Apple-style-span face="'courier new', monospace">&nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; cursize = 2;</FONT></DIV>
<DIV><FONT class=Apple-style-span face="'courier new', monospace"><SPAN 
style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>}</FONT></DIV>
<DIV><FONT class=Apple-style-span face="'courier new', monospace"><SPAN 
style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>feats[i].style = 
OpenLayers.Util.applyDefaults(</FONT></DIV>
<DIV><FONT class=Apple-style-span face="'courier new', monospace">&nbsp; &nbsp; 
&nbsp; &nbsp; {</FONT></DIV>
<DIV><FONT class=Apple-style-span face="'courier new', monospace"><SPAN 
style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>graphicZIndex : 
(lengd-i)+1000,</FONT></DIV>
<DIV><FONT class=Apple-style-span face="'courier new', monospace"><SPAN 
style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>strokeColor : 
"#"+genHex(),</FONT></DIV>
<DIV><FONT class=Apple-style-span face="'courier new', monospace"><SPAN 
style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>fillOpacity : 
0.03,</FONT></DIV>
<DIV><FONT class=Apple-style-span face="'courier new', monospace"><SPAN 
style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>pointRadius : 
7*(cursize)</FONT></DIV>
<DIV><FONT class=Apple-style-span face="'courier new', monospace"><SPAN 
style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>},</FONT></DIV>
<DIV><FONT class=Apple-style-span face="'courier new', monospace">&nbsp; &nbsp; 
&nbsp; &nbsp; 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&nbsp;</FONT><SPAN 
style="FONT-FAMILY: arial, helvetica, sans-serif" class=Apple-style-span>(these 
are all Points)</SPAN><FONT class=Apple-style-span 
face="arial, helvetica, sans-serif">, and if it finds&nbsp;</FONT><SPAN 
style="FONT-FAMILY: arial, helvetica, sans-serif" 
class=Apple-style-span>features</SPAN><SPAN 
style="FONT-FAMILY: arial, helvetica, sans-serif" 
class=Apple-style-span>&nbsp;</SPAN><SPAN 
style="FONT-FAMILY: arial, helvetica, sans-serif" 
class=Apple-style-span>adjacent to each other in the array which also 
intersect/share the same location &nbsp;- it draws them in bigger and bigger 
increments.</SPAN></DIV>
<DIV><SPAN style="FONT-FAMILY: arial, helvetica, sans-serif" 
class=Apple-style-span><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&nbsp;</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).&nbsp;</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></BODY></HTML>