<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Well hey its great to solve ones own issues. The sample code did not have a line "selectControl.activate()" on it. Found this and -- it worked.<div>kewl.</div><div><br></div><div>regards to all</div><div><br></div><div>Grant</div><div><br><div><div>On 25/03/2013, at 6:43 PM, Grant Maxwell <<a href="mailto:grant.maxwell@maxan.com.au">grant.maxwell@maxan.com.au</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=us-ascii"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi All<div><br></div><div>I'm sure this has been asked many times and yes I've found samples but I just can't make it work. I want to have a popup when I hover the mouse over the objects on the layer.</div><div>My code is below.</div><div><br></div><div>I've spent several hours on this and really would appreciate some help</div><div><br></div><div>kind regards</div><div>Grant</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #931a68">this</span>.addVectorLayer = <span style="color: #931a68">function</span>(name){</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #931a68">var</span> drawControls, selectedFeature = <span style="color: #931a68">null</span>, selectControl = <span style="color: #931a68">null</span>;</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #931a68">var</span> newLayer = <span style="color: #931a68">new</span> OpenLayers.Layer.Vector(name);</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>selectControl = <span style="color: #931a68">new</span> OpenLayers.Control.SelectFeature(newLayer, {</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>hover: <span style="color: #931a68">true</span>,</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>onSelect: onFeatureSelect, </div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>onUnselect: onFeatureUnselect</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px; "><br></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>});</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px; "><br></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #931a68">function</span> onPopupClose(evt) {</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>selectControl.unselect(selectedFeature);</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #931a68">function</span> onFeatureSelect(feature) {</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>selectedFeature = feature;</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>popup = <span style="color: #931a68">new</span> OpenLayers.Popup.FramedCloud(<span style="color: #3933ff">"popup"</span>, </div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>feature.geometry.getBounds().getCenterLonLat(),</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #931a68">null</span>,</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(57, 51, 255); "><span style=""><span class="Apple-tab-span" style="white-space:pre"> </span></span>"<div style='font-size:.8em'>Feature: "<span style=""> + feature.id +</span>"<br>Area: "<span style=""> + feature.geometry.getArea()+</span>"</div>"<span style="">,</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #931a68">null</span>, <span style="color: #931a68">true</span>, onPopupClose);</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>feature.popup = popup;</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>map.addPopup(popup);</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #931a68">function</span> onFeatureUnselect(feature) {</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>map.removePopup(feature.popup);</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>feature.popup.destroy();</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>feature.popup = <span style="color: #931a68">null</span>;</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>} </div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>drawControls = {</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>polygon: <span style="color: #931a68">new</span> OpenLayers.Control.DrawFeature(newLayer, OpenLayers.Handler.Polygon),</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>select: selectControl</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>};</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px; "><br></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #931a68">for</span>(<span style="color: #931a68">var</span> key <span style="color: #931a68">in</span> drawControls) {</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>map.addControl(drawControls[key]);</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>layers.push({<span style="color: #3933ff">"id"</span>:name, <span style="color: #3933ff">"layer"</span>:newLayer, <span style="color: #3933ff">"features"</span>:[]});</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>};</div></div><div><br></div></div>_______________________________________________<br>Users mailing list<br><a href="mailto:Users@lists.osgeo.org">Users@lists.osgeo.org</a><br>http://lists.osgeo.org/mailman/listinfo/openlayers-users<br></blockquote></div><br></div></body></html>