[OpenLayers-Users] Overwrite and extend initialize function of a class

Armin Burger armin.burger at gmx.net
Wed Feb 15 14:43:41 EST 2012


Eric

thanks. I saw some postings for this yesterday but did not get it to 
work, and thought it might not be fully functioning... Now I tried again 
- and succeeded... ;-)

I could overwrite the function by adding the complete original code and 
afterwards the lines I needed for extending it. But I did not find any 
possibility to make a call to the original initialize function and then 
afterwards just the few lines to extend the function. But maybe this is 
not possible.

Armin


On 15/02/2012 20:16, Eric Lemoine wrote:
>
>
> On Wednesday, February 15, 2012, Armin Burger <armin.burger at gmx.net
> <mailto:armin.burger at gmx.net>> wrote:
>  > Hi all
>  >
>  > I would like to overwrite and extend the "initialize" function of a
> class. For all other functions I used the method via
>  >
>  > OpenLayers.My_CLASS.prototype.funtionToOverWrite = function() {
>  >
>  > but in the case of the initialize function this does not show any
> effect (it is not used). OL version used is 2.11
>  >
>  > In addition I would not like to completely rewrite the function but
> extend it. I mean, calling the original function and then adding a few
> lines of code afterwards. Is this possible? If I create a new class
> inheriting from another I just can call the parent class like
>  >
>  >
> OpenLayers.Control.Parent_Class.prototype.initialize.functionToExtend(this,...);
>  >
>  > and add my code afterwards. But this does not work when modifying an
> existing class.
>  >
>  > Any ideas how to achieve these goals?
>  >
>  > Thanks in advance for any hints
>
> The overwrite function and its associated test functions in the IGN
> section of the Class tests may help you. See
> <https://github.com/openlayers/openlayers/blob/master/tests/BaseTypes/Class.html>
>
> --
> 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 <mailto:eric.lemoine at camptocamp.com>
> http://www.camptocamp.com
>


More information about the Users mailing list