[OpenLayers-Dev] 2.10 and 2.11-RC1 OpenLayers.Class behavior
changes
Richard Didier
didier.richard at ign.fr
Tue Jul 26 09:37:28 EDT 2011
Le mardi 26 juillet 2011 11:52:10, Andreas Hocevar a écrit :
> Hi Richard,
>
Hi Andreas,
> one note about license and patents: OpenLayers 2.11 is released under a
> simplified license, which does not contain any language about patent
> rights. See http://openlayers.org/blog/2011/05/17/simplified-license/
>
I was aware, but our legal experts are still explaining me not to send the CCLA ...
Nevertheless, we are internally talking of that to find out a workaround solution !
> Also, please let me know if you're able to override constructors in 2.11
> with this approach:
>
> var A = OpenLayers.Class({...});
> var B = OpenLayers.Class(A, {...});
>
> OverloadB = {
> initialize: function() {...},
> customMethod: function() {...},
> customProperty: "foo"
> };
> var BTemp = OverloadB.initialize;
> BTemp.prototpye = B.prototype;
> OpenLayers.Util.extend(BTemp.prototype, OverloadB);
> B = BTemp;
>
I made the following tests:
X= OpenLayers.Class({
p_:null,
px:"PX",
initialize: function() { this.p_= "X.initialize"; OpenLayers.Console.info(this.p_); }
});
X.Y= OpenLayers.Class(X,{
py:"PY"
});
X.Z= OpenLayers.Class(X,{
initialize: function() { this.p_= "Z.initialize"; OpenLayers.Console.info(this.p_); }
});
OverloadY= {
customProperty: "foo",
initialize: function() { this.p_= "Y.initialize"; OpenLayers.Console.info(this.p_); },
customMethod: function() { OpenLayers.Console.info("customMethod="+this.customProperty); }
};
var YTemp= OverloadY.initialize;
YTemp.prototype= X.Y.prototype;
OpenLayers.Util.extend(YTemp.prototype, OverloadY);
X.Y= YTemp;
delete OverloadY["initialize"];
var ZTemp= X.Z.prototype.initialize;
ZTemp.prototype= X.Z.prototype;
OpenLayers.Util.extend(ZTemp.prototype, OverloadY);
X.Z= ZTemp;
try {
var y= new X.Y();
OpenLayers.Console.assert((y instanceof X));
OpenLayers.Console.assert((y instanceof X.Y));
OpenLayers.Console.assert((y.p_=="Y.initialize"));
y.customMethod();
} catch (exy) {
OpenLayers.Console.warn(exy);
}
try {
var z= new X.Z();
OpenLayers.Console.assert((z instanceof X));
OpenLayers.Console.assert((z instanceof X.Z));
OpenLayers.Console.assert((z.p_=="Z.initialize"));
z.customMethod();
} catch(exz) {
OpenLayers.Console.warn(exz);
}
And it seems ok ! Nice.
I will incorporate this in my OpenLayers.overload method and test in both 2.11 and 2.10 ... Stay tuned !
Thanks
didier
> Andreas.
>
--
RICHARD Didier - Chef du pôle technique du Géoportail
2/4, avenue Pasteur - 94165 Saint Mandé Cedex
Tél : +33 (0) 1 43 98 83 23
More information about the Dev
mailing list