[OpenLayers-Users] "hover: true" together with callback "over" problem

Christopher Schmidt crschmidt at metacarta.com
Thu May 14 20:46:08 EDT 2009


On Fri, May 15, 2009 at 09:43:51AM +0900, Daniel Kastl wrote:
> Hi list,
> 
> I have a problem with hovering over features of my vector layer.
> When moving over a feature with the mouse, the icon should resize, so I 
> did this in StyleMap:
> 
> var myLayer = new OpenLayers.Layer.Vector( "Vector Layer", {
>     styleMap: new OpenLayers.StyleMap({
>         'default': new OpenLayers.Style({
>                         pointRadius: 20,
>                         externalGraphic: 'img/icon.png'
>         }),
>         'select': new OpenLayers.Style({
>                         pointRadius: 24
>         })
>     })
> });
> 
> Additionally I wanted to open a popup (or do something else) when my 
> mouse is over a feature, so I add this control:
> 
> var select = new OpenLayers.Control.SelectFeature( myLayer, {
>     hover: true,
>     callbacks: {
>         over: function(e){
>             console.info(e);
>         }
>     },
> });
> map.addControl(select);
> select.activate();
> 
> Resizing the icon works fine if I only set "hover: true". But when I use 
> "hover" together with "callbacks + over" it just calls the function, but 
> doesn't resize anymore.
> 
> I'm using GeoExt, so OpenLayers version should be the current 2.8 branch.
> 
> Can anyone give me an advice what I'm doing wrong or how to solve this?
> Thanks in advance,

In general, I'd recommend using the featureselected event on the layer.
The callbacks are likely to be used internally, and you're overriding
the behavior that ctually does what you want. 

  http://docs.openlayers.org/library/overlays#interaction

For example.  

Best Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list