1. #1
    Ext JS Premium Member
    Join Date
    Apr 2011
    Posts
    7
    Vote Rating
    0
    JoepRonde is on a distinguished road

      0  

    Default Unanswered: Extending a class other than ExtJS (like OpenLayers.Map)

    Unanswered: Extending a class other than ExtJS (like OpenLayers.Map)


    In ExtJS 3.2  I extended a class which is not part of the ExtJS framework (the OpenLayer.Map class) with the folowing code:

    Code:
    MyMap = Ext.extend(OpenLayers.Map, {
        constructor: function() {
            config = {
                div: 'olMap',
                projection: 'EPSG:28992'
                // ... other config settings
            }
            MyMap.superclass.constructor.call(this, config)
        },
    
        myFunction: function() {
            //Do something
        }
    });
    This all worked fine, the constructor above created a OpenLayer.Map instance and returned it. But now I'm upgrading to ExtJS 4 and would like to do exactly the same, but I can't make it work. The code I have so far is this:

    Code:
    Ext.define('MyMap', {
        extend: 'OpenLayers.Map',
        constructor: function() {
            config = {
                div: 'olMap',
                projection: 'EPSG:28992'
                // ... other config settings
            }
            this.callParent(arguments);
            this.initConfig(config);
        },
    
        myFunction: function() {
            //Do something
        }
    });
    The constructor above doesn't create return an instance of OpenLayers.Map though. I thought that this.callParent in the constructor should create a instance it's parent class (OpenLayer.Map), but is does not. So now I am wondering how can I extend a class other than an ExtJS class?

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,011
    Answers
    668
    Vote Rating
    460
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Move to Q&A, plugins is for release.

    Scott.

Thread Participants: 1