[OpenLayers-Users] Feature hover and highlighting

Alexandre Dube adube at mapgears.com
Fri Oct 9 08:42:24 EDT 2009


Hi Abhi,

  The 'overFeature' function is not really meant to be overwritten.  You 
should register a "featureselected" event instead to call your custom 
function.

  Also, see this example that demonstrate a nice with to "highlight 
only" the hovered feature (see eventListeners property for your function 
called on a specific event) :
http://openlayers.org/dev/examples/highlight-feature.html

Regards,

Alexandre

Abhi wrote:
> I have a vector layer defined as below:
>
> var poiLayer = new OpenLayers.Layer.Vector("poiLayer");
> map.addLayer(poiLayer);
>
> Hover control defined as below:
>
> var hover = new OpenLayers.Control.SelectFeature(poiLayer, {
>                 hover: true,
>                 overFeature: function(feature) {
>                  var longLat = feature.wkt.match(/(\d+.\d+)/g);
>                     popup = new OpenLayers.Popup("foo",
>                             new OpenLayers.LonLat(longLat[0], longLat[1]),
>                             new OpenLayers.Size(10, 10),
>                             feature.label,
>                             true);
>                     feature.popup = popup;
>                     map.addPopup(popup);
>                     popup.updateSize();
>                 }
>             });
>
>
> When a user hovers over a feature a popup is displayed.
>
> If I comment out the overFeature part, the feature gets highlighted on 
> mouse over. But, if I add the overFeature code the highlighting is 
> lost. How do I retain the hightlighting along with the overFeature code?
>
> -- 
> Cheers,
> Abhi
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>   


-- 
Alexandre Dubé
Mapgears
www.mapgears.com




More information about the Users mailing list