[OpenLayers-Users] control.activate()

Eric Lemoine eric.lemoine at camptocamp.com
Wed Jul 22 02:07:02 EDT 2009


On Tuesday, July 21, 2009,  <Steve.Toutant at inspq.qc.ca> wrote:
>
>
> Hi,

Hi


>
> I don't know when I should and should
> not use the activate function when I create a control. My understanding
> was to use activate only when deactivate was called but I'm not sure.

Not always true. For example the SelecFature control must be activated
after it is added to the map.


>
> Here are 2 examples copied from an openlayers
> example
>
>
> var navControl = new OpenLayers.Control.Navigation({
>
>
>     type: OpenLayers.Control.TYPE_TOGGLE,
>
>
>     zoomWheelEnabled: true
>
>  });
>
> map.addControl(navControl);
>
> navControl.activate();

The Navigation activates itself when it's added to the map, so you
don't need to activate it yourself.

>
>
>
>
> var MousePosition = new OpenLayers.Control.MousePosition({element:
> $('mouseTrack')});
>
> map.addControl(MousePosition);
>
>
> Why call this? navControl.activate();
>
> It seems to work even if I don,t use
> it.

Right.

>
> And that works without .activate
>
> map.addControl(MousePosition);

Also right.

The Navigation and MousePosition controls activate themselves when
they're added to the map, as I think most visual controls do. Other
controls, like SelectFeature, don't, so one needs to manually activate
them.


>
> Thanks for clarifying this
>
> Regards,
>
> Steve
>
>
>
> Steve Toutant, M. Sc.
> Analyste en géomatique
> Secteur environnement
> Direction des risques biologiques, environnementaux et occupationnels
> Institut national de santé publique du Québec
> 945, avenue Wolfe
> Québec, Qc G1V 5B3
> Tél.: (418) 650-5115 #5281
> Fax.: (418) 654-3144
> steve.toutant at inspq.qc.ca
> http://www.inspq.qc.ca
>
>

-- 
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