[OpenLayers-Users] Clicks on permalink control trigger clickout on vector layer

Eric Lemoine eric.lemoine at camptocamp.com
Mon Nov 16 00:43:01 EST 2009


On Saturday, November 14, 2009, Christoph Böhme <christoph at b3e.net> wrote:
> Hi all,
>
> in my application [1] a vector layer with an number of features is
> displayed on top of a base map. When users select one of the markers
> the permalink will be updated to include the id of the selected feature.
> This works all fine. The problem comes when users click on the
> permalink. This click will not only activate the permalink but also
> trigger a mouseout event on the vector layer which unselects the
> current feature and updates the permalink. This happens before the
> browser follows the link which makes it impossible to follow a
> permalink with a selected feature.
>
> I tried to add an event listener to the permalink control in the hope
> of catching and stopping the click event before it falls through to
> the map. However, for some reason the event handler is not called.
>
> This is the code I used for adding the event listener:
>
> this.permalink_control = new OpenLayers.Control.Permalink(null, null,
> { eventListeners: {
>         "click": function(e) {
>                 alert("Test");
>                 OpenLayers.Event.stop(e ? e: window.event);
>         }
> }});
> this.map.addControl(this.permalink_control);
> this.permalink_control.activate();
>
> Is this the correct way to add an event listener?

AFAIK you cannot register a browser event listener on a control's DOM
element using eventListeners (or control.events.register).

Have you tried

OpenLayers.Event.observe(control.element, "click", function(e) { ... });

?

cheers,

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com



More information about the Users mailing list