[OpenLayers-Users] Hover control sample (share)

Alexandre Dube adube at mapgears.com
Thu Jan 15 13:29:50 EST 2009


Thanks Eric for your comments,

  As you said, it was not too hard to build.  My first thought was that 
a SelectFeature control actually "select" the feature ( change its 
renderIntent to "select" ) so a selected feature gets drawn with the 
"select" style.  That was not what I had in mind at first.  I wanted to 
have an other color for that, or I could say that I actually wanted to 
know when I could click a feature to select it by changing its color first.

  I would be glad to create a ticket for this feature.  Do you think 
"Hover" is a good name for what this control does ? ( changing the style 
of features when the mouse is over it, can also display a popup at the 
same time with all the features attributes/values )

  Thanks again,

Alexandre

Eric Lemoine wrote:
> Thanks for sharing your code Alexandre.
>
> I thought about a Feature control in the past. That control would use
> a Feature handler internally and would be configured to work either in
> hover or click mode, just like the SelectFeature control. But, as
> yours, it wouldn't select features, but just trigger events when
> features are hovered or clicked. To avoid code duplication I also
> imagined that the SelectFeature control could be based on that control
> instead of relying directly on the Feature handler.
>
> But I had the same reasoning as you: why bother? Building a custom
> Feature handler-based control is easy enough...
>
> But, actually, there are so many people needing that thing that it may
> be valuable to have it in trunk.
>
> Cheers,
>
> Eric
>
> 2009/1/15, Alexandre Dube <adube at mapgears.com>:
>   
>> Hi list,
>>
>>   I just want to share a sample of Handler.Hover usage I do.  The result
>> is a Control.Hover I use to change the style of features hover the mouse
>> without selecting them and display a popup at the same time.  You could
>> also register events on "hoverfeatureset" and "hoverfeaturereset" to do
>> more stuff if you want.
>>
>>   See the example :
>>
>> http://dev.openlayers.org/sandbox/adube/openlayers/examples/hover-control.html
>>
>>   See the code :
>>
>> http://dev.openlayers.org/sandbox/adube/openlayers/lib/OpenLayers/Control/Hover.js
>>
>>   At first I wanted it to be a new OpenLayers feature, but then I
>> thought that Handlers were created for the purpose of customizing our
>> own controls depending of what our needs are.  So this Hover control is
>> one of many possible usage of Handlers, so IMHO it's not useful to make
>> it a new feature.  Sharing it is enough.
>>
>>   Comments are welcomed,
>>
>> --
>> Alexandre Dubé
>> Mapgears
>> www.mapgears.com
>>
>> _______________________________________________
>> 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