[OpenLayers-Users] OpenLayers equivalent of ka-map pause event?

Steve Lime Steve.Lime at dnr.state.mn.us
Fri Jan 4 00:24:45 EST 2008


For completeness here's what has worked for me, as hijacked from ka-map:

var timer=null, delay=2000;
var paused=false;

function mousePaused(e) {
   var coord = map.getLonLatFromViewPortPx(e.xy);
   ... do something with the coordinate ...
}

function mouseMove(e) {
   if(timer) clearTimeout(timer);
   if(paused == false) 
     self.timer = setTimeout(function(){clearTimeout(timer); paused = true; mousePaused(e); paused=false;}, delay);
}

function mouseOut(e) {
   clearTimeout(timer);
}

and in the onload function...

map.events.register("mousemove", map, mouseMove);
map.events.register("mouseout", map, mouseOut);

I can file a ticket if that would help.

Steve

>>> Tim Schaub <tschaub at openplans.org> 12/26/07 2:10 PM >>>
Mike Quentel wrote:
 > As far as the mouse events go, you might consider using a timer to
 > detect if user has paused for the amount of time over the map feature.
 > onmouseover could start the timer.  If user does not move (mousemove)
 > after a certain amount of time, then show the pop-up window if over a
 > map feature.

We could cook up a pause handler pretty easily.  This would let you 
develop controls that respond to mouse pauses.  The reason to use a 
handler for this is so that it can be used in multiple controls - or can 
be used to set the behavior of a control that might respond to clicks by 
default.  For example, an Information control (requests GetFeatureInfo 
by default) might use a click handler by default (responding to single 
or double-clicks) - giving this control a pause handler instead of a 
click handler would change it's behavior to respond to mouse pauses 
instead of mouse clicks.  No code floating around yet for this, but it 
shouldn't be hard to write.

A ticket would be the first step.  Then a patch.

Tim


> 
> I had to make timer functionality to ignore mouse wheel events that were
> too fast.  I've attached a simpler example of using a timer.  This is
> not the same as using the javascript setTimeout function.
> 
> Cheers,
>  
> Mike Quentel
> 
> 
> -----Original Message-----
> From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org]
> On Behalf Of Steve Lime
> Sent: Wednesday, 19 December 2007 16:12
> To: Eric Lemoine
> Cc: users at openlayers.org
> Subject: Re: [OpenLayers-Users] OpenLayers equivalent of ka-map pause
> event?
> 
> I'd just want a callback run with the x,y of the pause. In my case I do
> pure MapServer query requests with JSON or HTML responses. I ported the
> ka-map approach to my own non-tiled framework (for example,
> http://www.dnr.state.mn.us/waters/csg/index.html) and want to use a
> similar approach with OpenLayers clients I'm working on. 
> 
> Steve
> 
>>>> On 12/19/2007 at 2:47 PM, in message
> <5ec103de0712191247m1c7576b2vb63a50b0dbe0059d at mail.gmail.com>, "Eric
> Lemoine"
> <eric.c2c at gmail.com> wrote:
>> On Dec 19, 2007 9:37 PM, Steve Lime <Steve.Lime at dnr.state.mn.us>
> wrote:
>>> Folks familiar with ka-map might also be familiar with a mouse pause 
>>> event
>> that has proven
>>> to be really useful (for me anyway). I fires if the mouse has been
>> stationary a certain
>>> amount of time. I grep'd the source but didn't find anything obvious.
> 
>>> Does
>> anything like it
>>> exist? Thanks.
>> Steve
>>
>> What kind of request would you like to see triggered? WMS
> GetFeatureInfo?
>> FYI, we implemented this in MapFish, using our own REST-based protocol
> 
>> between the client and the server.
>>
>> --
>> Eric
> 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 
> ---------------------------------------------------------------------
> This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.
> 
> 
> !DSPAM:4033,4769fcc0133261439371379!
> 
> 
> ------------------------------------------------------------------------
> 
> Scroll mouse wheel to see delta here.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 
> 
> !DSPAM:4033,4769fcc0133261439371379!

_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users




More information about the Users mailing list