[OpenLayers-Users] Add new Parameter to options

Eric Lemoine eric.lemoine at camptocamp.com
Sat Dec 26 16:29:47 EST 2009


On Tuesday, December 22, 2009, Moataz Elmasry
<zaza1851983ml at googlemail.com> wrote:
> Hello List
>
> I've created a custom toolbar as follows:
>
> OpenLayers.Control.CustomNavToolbar =
> OpenLayers.Class(OpenLayers.Control.Panel, {
>      Map : null,
>      initialize : function(options) {console.log(Map);}
> });
>
> Now I want to add the parameter Map to to the constructor:
> var nav = OpenLayers.Control.CustomNavToolbar({Map:map})
>
> On the console.log(Map) I get that object Map is not defined. When I
> call on the other hand console.log(options.Map) I get the actual object.
>
> How can I define the parameter so that I can directly use "Map" instead
> of options.Map?

Hi. I don't know if that answers your question but you can use
OpenLayers.Util.extend in the "initialize" method to set the options
passed to the constructor in the instance:

    initialize: function(options) {
        OpenLayers.Util.extend(this, options);
    }

You can then use this.Map from any method of the class.

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