[OpenLayers-Users] How to prevent PanZoomBar clicks from
propagating to Click control
Rohan Parkes
rohan.parkes at pelicancorp.com
Sun Aug 8 19:13:16 EDT 2010
Thanks for your reply.
I didnt post the code, because it's trivial, and straight out of one of the
online demos.
But here it is:
OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
defaultHandlerOptions: {
'single': true,
'double': true,
'pixelTolerance': 0,
'stopSingle': true,
'stopDouble': false
},
initialize: function(options)
{
this.handlerOptions = OpenLayers.Util.extend(
{}, this.defaultHandlerOptions
);
OpenLayers.Control.prototype.initialize.apply(
this, arguments
);
this.handler = new OpenLayers.Handler.Click(this,
{'click': this.trigger}, this.handlerOptions);
},
trigger: processMapClick
});
processMapClick() just has a call to setCenter(), so the map re-centres to
wherever the user clicks.
The problem is that if the user clicks on the zoom bar, the map, as well as
zooming, also pans. So presumably the click event is going through to the
map as well. This doesnt happen if they click on the end icons of the zoom
bar, so presumably there is some way of preventing them from going through
to other elements.
I tried adding a handler to the PanZoomBar to try to filter the clicks, but
my attempt was probably very naïve.
Rohan Parkes
Developer
PelicanCorp
79 Rokeby Street, Collingwood 3066, VIC, AU
(m) +61 (0)407 094 251
(p) +613 8413 5212
(f) +613 8413 5299
www.pelicancorp.com
The information contained in this email communication may be confidential.
You should only read, disclose, re-transmit, copy, distribute, act in
reliance on or commercialise the information if you are authorised to do so.
If you are not the intended recipient of this email communication, please
notify us immediately by email at contactus at pelicancorp.com or reply by
email directly to the sender and then destroy any electronic or paper copy
of this message.
-----Original Message-----
From: Pierre Giraud [mailto:pierre.giraud at camptocamp.com]
Sent: Thursday, 5 August 2010 17:15
To: rohan.parkes at pelicancorp.com
Cc: users at openlayers.org
Subject: Re: [OpenLayers-Users] How to prevent PanZoomBar clicks from
propagating to Click control
I'm not sure I fully understand what your custom control is supposed to do.
However, you can have a look at the fallThrough config option for the
Map object. It may help.
If not, please show us some code.
Regards,
Pierre
On Thu, Aug 5, 2010 at 7:39 AM, Rohan Parkes
<rohan.parkes at pelicancorp.com> wrote:
> My map has a click control that allows users to re-centre the map by
> clicking on it.
>
> However, there is one drawback it responds to clicks on the PanZoomBar
> control, creating a strange blend of panning and zooming when the user
> zooms.
>
> It doesnt respond to the Zoom In or Zoom Out icons just the bar
element.
>
> Presumably I have to find a way to prevent clicks on the Zoom bar from
> propagating to the map.
>
> If the user clicks on the map at least once, it works correctly, and the
map
> does not pan when the user zooms. But if they start by clicking on the
zoom
> bar, they get the unwanted behaviour.
>
> Ive been messing around with the Handler.Click class, but I cant get
> anything to work.
>
> The code for the OpenLayers.Control.Click control is from the OL Click
Event
> example. The trigger member just calls a function that re-centres the map.
>
> Rohan Parkes
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>
--
Pierre GIRAUD
Géomaticien, Analyste
Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex
Tel : 00 33 4 79 44 44 93
Mail : pierre.giraud at camptocamp.com
http://www.camptocamp.com
More information about the Users
mailing list