I&#39;ve done something like this with OL.<br>My layer loads a gml file:<br><br>var layer = new OpenLayers.Layer.Vector(&quot;Distretti ASL&quot;,{ featureClass: OpenLayers.Feature});<br>layer.setIsBaseLayer(false);<br>layer.setVisibility
(true);<br>PpenLayers.loadURL(GML_FILE, &#39;&#39;, &#39;&#39;, loadGml,errorGml);<br>map.addLayer(gmlLayer);<br><br>then I created a control to register functions to events:<br><br>var control = new OpenLayers.Control.SelectFeature
(gmlLayer,{hover: true,onSelect: selectFunction, onUnselect: unDelectFunction});<br>map.addControl(control);<br>control.activate();<br><br>The selectFunction registers a function to onClick event, so as to call a function when I click on the popup:
<br><br>this.popup.events.register(&#39;click&#39;, document.getElementById(&#39;link&#39;), onClick.bind(feature));<br><br>Hope this help.<br><br><div class="gmail_quote">On Jan 11, 2008 11:17 PM, Andreas Hocevar &lt;<a href="mailto:andreas.hocevar@gmail.com">
andreas.hocevar@gmail.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br><div class="Ih2E3d"><br>On Jan 11, 2008 5:36 PM, Eric Lemoine &lt;
<a href="mailto:eric.c2c@gmail.com">eric.c2c@gmail.com</a>&gt; wrote:<br>&gt; On Jan 11, 2008 5:15 PM, Dejung Gewissler<br>&gt; &lt;<a href="mailto:dejung.gewissler@oit.state.nj.us">dejung.gewissler@oit.state.nj.us</a>&gt; wrote:
<br></div><div class="Ih2E3d">&gt; &gt; &nbsp; &nbsp; 1) features rendered differently based on feature values (done with<br>&gt; &gt; styles and rules)<br>&gt; &gt; &nbsp; &nbsp; 2) on mouseover/hover of a feature the hover styles to take effect
<br>&gt; &gt; &nbsp; &nbsp; 3) on click of the feature a popup should appear<br>&gt; &gt;<br>&gt; &gt; 1) is done. 2) I can&#39;t get to work unless I attach a selectFeature<br>&gt; &gt; control to the layer and set {hover: true}. Is there a way to accomplish
<br>&gt; &gt; this task without using the selectFeature control?<br>&gt;<br>&gt; Not that I&#39;m aware of. But I understand why you&#39;re asking this - the<br>&gt; hover* style properties. I&#39;ve never use these properties myself, and I
<br>&gt; don&#39;t know if they&#39;re actually usable. Someone may want to jump in...<br><br></div>Those hover* style properties do not do anything. &nbsp;The proper way to<br>control styling of the features for mouseover is to set the
<br>selectStyle property of the OL.SelectFeature control, like Eric<br>already pointed out. &nbsp;If you also want to have those rule-based, you<br>have to create separate styling rules, again with fillColor,<br>strokeColor and so on. Then you have to write a custom select method
<br>for the SelectFeature control (as also shown in examples/sld.html):<br><br> &nbsp; &nbsp;var hover = new OpenLayers.Control.SelectFeature(myGML, {<br> &nbsp; &nbsp; &nbsp; &nbsp;hover: true,<br> &nbsp; &nbsp; &nbsp; &nbsp;selectStyle: yourSelectStyleHere,<br> &nbsp; &nbsp; &nbsp; &nbsp;select = function(feature) {
<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// store layer style<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var style = feature.layer.style;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// set temporary layer style for hover rendering<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;feature.layer.style = hover.selectStyle;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;OpenLayers.Control.SelectFeature.prototype.select.apply
(hover,<br>arguments);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// restore layer style<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;feature.layer.style = style;<br> &nbsp; &nbsp; &nbsp; &nbsp;}});<br><div class="Ih2E3d"><br><br>&gt; &gt; The reason why is<br>&gt; &gt; that I would like to use the selectFeature control in 3) and attach some
<br>&gt; &gt; functionality to the onSelect callback.<br>&gt;<br>&gt; Have you tried using two select feature controls on the same layer,<br>&gt; one with hover:true, the other with hover:false? Again, I&#39;ve never<br>&gt; tried this myself, and I&#39;m not actually sure it&#39;ll work. If that
<br>&gt; doesn&#39;t work, I&#39;d say it&#39;s a bug in OpenLayers, and we&#39;ll need to fix<br>&gt; it.<br><br></div>I also do not know if that works, but I did it using the following<br>trick: in the onSelect method of the SelectFeature control with
<br>hover:true, I defined a priority listener for mousedown:<br><br> &nbsp; &nbsp;var onClick = function(evt) {<br> &nbsp; &nbsp; &nbsp; &nbsp;// do your onClick stuff here<br> &nbsp; &nbsp; &nbsp; &nbsp;OpenLayers.Event.stop(evt);<br> &nbsp; &nbsp;}<br><br> &nbsp; &nbsp;feature.layer.events.registerPriority
(&#39;mousedown&#39;, feature, onClick);<br><br>In the onClick method, you can do the custom action you want to do on<br>click (note that onClick is called in the context of the feature, so<br>the feature can be accessed with &quot;this&quot;).
<br><br>And do not forget to also remove the mousedown event in the onUnselect method:<br><br> &nbsp; &nbsp;feature.layer.events.unregister(&#39;mousedown&#39;, feature, onClick);<br><br>Regards,<br><font color="#888888">Andreas.<br>
</font><div><div></div><div class="Wj3C7c">_______________________________________________<br>Dev mailing list<br><a href="mailto:Dev@openlayers.org">Dev@openlayers.org</a><br><a href="http://openlayers.org/mailman/listinfo/dev" target="_blank">
http://openlayers.org/mailman/listinfo/dev</a><br></div></div></blockquote></div><br>