Reputation: 13636
I have this class based on pure javascript:
var DrawFeatureP = /*@__PURE__*/(function (Draw) {
function DrawFeatureP() {
debugger
Draw.call(this, {
source: new ol.layer.Vector({ source: new ol.source.Vector() }),
type: 'change this property from function in pottom'
});
document.getElementById('lineToggle').onclick = this.handleDrawFeature.bind(this);
}
if (Draw) DrawFeatureP.__proto__ = Draw;
DrawFeatureP.prototype = Object.create(Draw && Draw.prototype);
DrawFeatureP.prototype.constructor = DrawFeatureP;
DrawFeatureP.prototype.handleDrawFeature = function handleDraw(evt) {
//when is function is fired how ca i set 'type' property?
};
return DrawFeatureP;
}(ol.interaction.Draw));
When this function is fired:
DrawFeatureP.prototype.handleDrawFeature = function handleDraw(evt) {
//when is function is fired how ca I set 'type' property?
};
I need to change the 'type' property :
type: 'change this property from function in the bottom'
My question is how to edit type property from handleDraw function?
Upvotes: 0
Views: 372
Reputation: 782564
Since you bind this
when assigning the onclick
handler, you can use this.type
in the handler function.
DrawFeatureP.prototype.handleDrawFeature = function handleDraw(evt) {
this.type = "new type";
};
Upvotes: 1