[OpenLayers-Users] combining handlers, or hover + select

Alexandre Dube adube at mapgears.com
Tue Feb 3 09:13:01 EST 2009


Hi Jesse,

What I did to accomplish this is a custom "HighlightFeature" control. 
You can have it and a SelectFeature at the same time.

See an example :

http://dev.openlayers.org/sandbox/adube/openlayers/examples/highlight-feature.html

See an example with SelectFeature at the same time :

http://dev4.mapgears.com/bdga/bdgaWFS-T.html

Of course this is only a possible solution among many others. Others 
should have more ideas.

Alexandre

Jesse V Griffis wrote:
> Thanks Eric,
>
> I wasn't sure if dumping a bunch of code to the list would be useful.
>
> Essentially, I just copied the Hover Control from the example page
> (http://openlayers.org/dev/examples/hover-handler.html) and tried to
> copy the stuff from the SelectFeature Control (in the source).
>
> Testing it, I know the hover/pause part of this is working, but I
> can't figure out how to apply the selection piece.  Please don't laugh
> too hard:
>
> OpenLayers.Control.Hover = OpenLayers.Class(OpenLayers.Control,
>   {
>     layer: null,
>
>     isPaused: false,
>
>     defaultHandlerOptions: {
>     'delay': 1000,
>     'pixelTolerance': 1,
>     'stopMove': false
>     },
>
>     initialize: function(layer, options)
>     {
>       this.layer = layer;
>       this.handlerOptions = OpenLayers.Util.extend(
>         {}, this.defaultHandlerOptions
>       );
>       OpenLayers.Control.prototype.initialize.apply(
>         this, arguments
>       );
>
>       this.handlers = {
>         feature: new OpenLayers.Handler.Feature(
>           this, this.layer, { 'over': this.over}, {}
>         ),
>         hover: new OpenLayers.Handler.Hover( this,
>           {'pause': this.onPause, 'move': this.onMove}, this.handlerOptions
>         )
>       }
>     },
>
>     draw: function() {
>       return false;
>     },
>
>     activate: function() {
>       this.handlers.feature.activate();
>       this.handlers.hover.activate();
>     },
>
>     deactivate: function() {
>       this.handlers.feature.deactivate();
>       this.handlers.hover.deactivate();
>     },
>
>
>     onPause: function(evt) {
>       this.isPaused = true;
>     },
>
>     onMove: function(evt) {
>       this.isPaused = false;
>     },
>
>     over: function(feature) {
>       if ( this.isPaused)
>       {
>         console.log(feature);
>       }
>     }
>   });
>
>
>
> On Tue, Feb 3, 2009 at 1:03 AM, Eric Lemoine <eric.c2c at gmail.com> wrote:
>   
>> Hi
>>
>> It is hard to help you without seeing actual code. Feel free to come
>> back to the list with your code.
>>
>> Cheers,
>>
>> Eric
>>
>> 2009/2/3, Jesse V Griffis <jvgriffis at gmail.com>:
>>     
>>> Greetings,
>>>
>>> I can successfully use the hover examples to create a "Hover" Control
>>> that uses the Hover handler to pop up info when you pause in one place
>>> long enough.  I can successfully use the SelectFeature Control to
>>> click and display info about Vectors.
>>>
>>> What I can't figure out is how to combine them, and make a pause on
>>> the map select the feature under the mouse.  It's frustrating to get
>>> so close and yet be so far.
>>>
>>> Does anyone have an example of this?
>>>
>>> Thanks,
>>>
>>> Jesse
>>> _______________________________________________
>>> Users mailing list
>>> Users at openlayers.org
>>> http://openlayers.org/mailman/listinfo/users
>>>
>>>       
> _______________________________________________
> 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