I am trying to extend a Leaflet class, and looking at the documentation it gives this example:
var MyBoxClass = L.Class.extend({
options: {
width: 1,
height: 1
},
initialize: function(name, options) {
this.name = name;
L.setOptions(this, options);
}
});
var instance = new MyBoxClass('Red', {width: 10});
console.log(instance.name); // Outputs "Red"
console.log(instance.options.width); // Outputs "10"
console.log(instance.options.height); // Outputs "1", the default
However, if I try to access this.options.height in initialize after calling L.setOptions it is undefined. Instead there appears to be a this.options.prototype.height.
How should I be accessing options members so I get the default if the caller doesn't define a value?
Thanks
this.options.height
in this example jsfiddle.net/hb6e5mo2 seems to work just fine