<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><div><div>Hey list,</div><div><br></div><div>I have a question on the OpenLayers Cluster strategy and displaying attributes:</div><div><br></div><div>The situation: I have a map loading quite a number of points from a dynamically generated GML. Currently, I am not using a cluster strategy, but the handling gets more and more difficult. When I hover the points, I send the feature.attributes.Name content (Content of the Name attribute in the GML) to a function for displaying a tooltip. No problem until I want to cluster the features. I understand, that after clustering, the attribute "Name" doesn't exist anymore. What I want to do now is, when it is a cluster of more than one feature, I want to send "Cluster of feature.attributes.count" to my tooltip function, which is also not a problem, but, if there is only one feature in the cluster, I want to send the feature.attributes.Name of that feature to the tooltip function. I hope you understand what I am trying to achieve. </div><div><br></div><div>Here are the code fragments I am using at the moment:</div><div><br></div><div>--- The layer is generated with the following function (already including the cluster strategy): ---</div><div><br></div><div>...</div><div><br></div><div>pointLayer = new OpenLayers.Layer.Vector("Wasserhäuschen", {</div><div> strategies: [new OpenLayers.Strategy.Fixed(), new OpenLayers.Strategy.Cluster()],</div><div> attribution:"Dateneigentum: <a href='http://www.linie11.org' target='_blank'>linie11.org</a> <a href='http://www.l-11.de' target='_blank'><img src='./img/l11_attr.png' border='0'></a><br><br>",</div><div> protocol: new OpenLayers.Protocol.HTTP({</div><div> url: "./geoData/data.xml.gml",</div><div> format: new OpenLayers.Format.GML()</div><div> }),</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>styleMap: new OpenLayers.StyleMap({'default':defaultStyle,</div><div> 'select':selectStyle,</div><div> 'temporary':tempStyle</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>},{</div><div> context: {</div><div> // ...</div><div> label: function(feature) {</div><div> // clustered features count or blank if feature is not a cluster</div><div> return feature.cluster ? feature.cluster.count : ""; </div><div> }</div><div> // ..</div><div> }</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>})});</div><div><br></div><div>...</div><div><br></div><div>--- EOF ---</div><div><br></div><div>--- The code of the hover listener, that sends the data to the function openToolTip: ---</div><div><br></div><div>...</div><div><br></div><div> var highlightCtrl = new OpenLayers.Control.SelectFeature(</div><div> pointLayer,</div><div> {</div><div> hover: true,</div><div> highlightOnly: false,</div><div> clickout: false,</div><div> toggle: false,</div><div> multiple: false,</div><div> renderIntent: "select",</div><div> overFeature: function(feature) {</div><div> console.log('hover out: ' + feature.attributes.count);</div><div> openToolTip('Cluster of ' + feature.attributes.count);</div><div> },</div><div> outFeature: function(feature) {</div><div> console.log('hover out: ' + feature.attributes.count);</div><div> closeToolTip();</div><div> },</div><div> }</div><div> );</div><div><br></div><div>...</div><div><br></div><div>--- EOF ---</div><div><br></div><div>To my understanding, I somehow need to access the attributes of the feature selected. But I have absolutely no idea how to do this, and I hope to get a little help from you guys!</div><div><br></div><div>Thanks in advance,</div><div>Freddy</div></div> </div></body>
</html>