import { Circle , Fill , Stroke , Style } from 'ol/style' ; import { Component } from '@angular/core' ; import { HsDrawService } from '../draw.service' ; import { HsLanguageService } from '../../language/language.service' ; import { HsLayerUtilsService } from '../../utils/layer-utils.service' ; import { HsLayoutService } from '../../layout/layout.service' ; import { getTitle } from '../../../common/layer-extensions' ; @ Component ( { selector : 'hs-draw-panel' , templateUrl : './draw-panel.component.html' , styleUrls : [ './draw-panel.component.scss' ] , } ) export class DrawPanelComponent { onFeatureSelected : any ; onFeatureDeselected : any ; drawToolbarExpanded : any ; opacity = 0.2 ; linewidth = 1 ; fillcolor : any = { 'background-color' : 'rgba(0, 153, 255, 1)' } ; onlyMineFilterVisible = false ; getTitle = getTitle ; constructor ( public HsDrawService , public HsLayerUtilsService , public hsLayoutService , public HsLanguageService ) { } translateString ( module , text ) { return this . HsLanguageService . getTranslationIgnoreNonExisting ( module , text ) ; } changeSnapSource ( layer ) { this . HsDrawService . changeSnapSource ( layer ) ; } setType ( what ) { const type = this . HsDrawService . setType ( what ) ; if ( type ) { this . activateDrawing ( this . hsLayoutService . panelVisible ( 'draw' ) ) ; } } activateDrawing ( withStyle ? ) { this . HsDrawService . activateDrawing ( { changeStyle : withStyle ? ( ) => this . changeStyle ( ) : undefined , } ) ; } selectLayer ( layer ) { this . HsDrawService . selectLayer ( layer ) ; } updateStyle ( ) { this . HsDrawService . updateStyle ( ( ) => this . changeStyle ( ) ) ; } param { Event } e description returns { Array } changeStyle ( e = null ) { const newStyle = new Style ( { stroke : new Stroke ( { color : this . fillcolor [ 'background-color' ] , width : this . linewidth , } ) , fill : new Fill ( { color : this . fillcolor [ 'background-color' ] . slice ( 0 , - 2 ) + this . opacity + ')' , } ) , image : new Circle ( { radius : 5 , fill : new Fill ( { color : this . fillcolor [ 'background-color' ] . slice ( 0 , - 2 ) + this . opacity + ')' , } ) , stroke : new Stroke ( { color : this . fillcolor [ 'background-color' ] , width : this . linewidth , } ) , } ) , } ) ; return newStyle ; } drawStyle ( ) { return { 'background-color' : this . fillcolor [ 'background-color' ] . slice ( 0 , - 2 ) + this . opacity + ')' , border : this . linewidth + 'px solid ' + this . fillcolor [ 'background-color' ] , } ; } }