Przeglądaj źródła

💄 change default opacity of thematic layers

resolves #25
jmacura 3 lat temu
rodzic
commit
4f736d93a8
2 zmienionych plików z 11 dodań i 5 usunięć
  1. 4 1
      src/app.config.ts
  2. 7 4
      src/app.service.ts

+ 4 - 1
src/app.config.ts

@@ -14,6 +14,8 @@ function getHostname() {
   return urlArr[0] + '//' + domain;
 }
 
+export const DEFAULT_OPACITY = 0.7;
+
 export const perc2color = (perc: number): string => {
   perc = perc * 100;
   let r;
@@ -28,7 +30,7 @@ export const perc2color = (perc: number): string => {
   }
   // eslint-disable-next-line @typescript-eslint/no-unused-vars
   const h = r * 0x10000 + g * 0x100 + b * 0x1;
-  return `rgba(${r}, ${g}, ${b}, 0.7)`;
+  return `rgba(${r}, ${g}, ${b}, 1)`;
 };
 
 export const decimal2prettyPerc = (x) => {
@@ -113,6 +115,7 @@ export const nuts3IndexLayer = new VectorLayer({
     },
   },
   source: nuts3IndexSource,
+  opacity: DEFAULT_OPACITY,
   visible: true,
   style: indexStyle,
 });

+ 7 - 4
src/app.service.ts

@@ -1,4 +1,3 @@
-import hsv2rgb from 'hsv2rgb';
 import {Injectable} from '@angular/core';
 
 import {Feature} from 'ol';
@@ -13,7 +12,6 @@ import {
   HsEventBusService,
   HsLanguageService,
   HsLayoutService,
-  //HsMapService,
   HsPanelContainerService,
   HsSidebarService,
   HsToastService,
@@ -24,7 +22,12 @@ import {AdjusterEventService} from './adjuster/adjuster-event.service';
 import {AdjusterLegendService} from './adjuster/adjuster-legend.service';
 import {AdjusterService} from './adjuster/adjuster.service';
 import {AdjusterSimplePanelComponent} from './adjuster/adjuster-simple-panel/adjuster-simple-panel.component';
-import {AppConfig, nuts2Layer, nuts3IndexLayer} from './app.config';
+import {
+  AppConfig,
+  DEFAULT_OPACITY,
+  nuts2Layer,
+  nuts3IndexLayer,
+} from './app.config';
 
 @Injectable({providedIn: 'root'})
 export class AppService {
@@ -59,7 +62,6 @@ export class AppService {
     public hsEventBus: HsEventBusService,
     public hsLanguageService: HsLanguageService,
     public hsLayoutService: HsLayoutService,
-    //public hsMapService: HsMapService,
     public hsPanelContainerService: HsPanelContainerService,
     public hsSidebarService: HsSidebarService,
     public hsToastService: HsToastService
@@ -159,6 +161,7 @@ export class AppService {
           url: require('./data/NUTS_RG_20M_2016_3857_LEVL_3.topojson').default,
           overlaps: false,
         }),
+        opacity: DEFAULT_OPACITY,
         visible: true,
         style: this.generateStyle(method.codename),
       });