Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!this.map) {
throw new Error('Missing map');
}
if (!this.measure) {
throw new Error('Missing measure');
}
this.measure.setActive(this.active);
interactionDecoration(this.measure);
const drawInteraction = this.measure.getDrawInteraction();
if (!(drawInteraction instanceof MobileDraw)) {
throw new Error('Wrong drawInteraction');
}
this.drawInteraction = drawInteraction;
interactionDecoration(drawInteraction);
Object.defineProperty(this, 'hasPoints', {
get() {
return this.drawInteraction.getFeature() !== null;
}
});
listen(drawInteraction, 'change:dirty', (evt) => {
this.dirty = drawInteraction.getDirty();
// this is where the angular scope is forced to be applied. We
// only need to do this when dirty, as going to "no being dirty"
// is made by a click on a button where Angular is within scope
if (this.dirty) {
this.scope.$apply();
}
stroke: new olStyleStroke({
color: '#ffcc33',
width: 2
})
});
overlay.setStyle(style);
/**
* @type {import("ol/interaction/Draw.js").default}
*/
this.interaction = new olInteractionDraw({
type: 'LineString',
features: this.features_
});
interactionDecoration(this.interaction);
// Clear the line as soon as a new drawing is started.
this.interaction.on('drawstart', (event) => {
this.features_.clear();
});
// Update the profile with the new geometry.
this.interaction.on('drawend', (event) => {
this.line = event.feature.getGeometry();
// using timeout to prevent double click to zoom the map
$timeout(() => {
this.interaction.setActive(false);
}, 0);
});
// Line may be removed from an other component
this.interactions_.forEach((interaction) => {
interaction.setActive(false);
ngeoMiscDecorateInteraction(interaction);
});
};
registerInteraction(interaction) {
if (!this.map) {
throw new Error('Missing map');
}
this.interactions_.push(interaction);
interaction.setActive(false);
ngeoMiscDecorateInteraction(interaction);
this.map.addInteraction(interaction);
}
this.interactions_.forEach((interaction) => {
interaction.setActive(false);
ngeoMiscDecorateInteraction(interaction);
});
};
MeasueMobileBaseController.prototype.init = function() {
if (!this.map) {
throw new Error('Missing map');
}
if (!this.measure) {
throw new Error('Missing measure');
}
this.measure.setActive(this.active);
interactionDecoration(this.measure);
const drawInteraction = this.measure.getDrawInteraction();
if (!(drawInteraction instanceof MobileDraw)) {
throw new Error('Wrong drawInteraction');
}
this.drawInteraction = drawInteraction;
interactionDecoration(drawInteraction);
Object.defineProperty(this, 'hasPoints', {
get() {
return this.drawInteraction.getFeature() !== null;
}
});
listen(drawInteraction, 'change:dirty', (evt) => {
this.dirty = drawInteraction.getDirty();