更改agm-circle颜色

问题描述

当地图将其模式更改为暗模式时,我想更改agm-circle颜色。

我在服务文件中有一个行为主题

private isDarkModeActiveSubject = new BehaviorSubject<boolean>(false);
readonly isDarkModeActive$ = this.isDarkModeActiveSubject.asObservable();

在我的组件文件中,在ngOnInit方法中具有以下代码

this.mapToolbarService.isDarkModeActive$
  .pipe(takeuntil(this.unsubscriber.done))
  .subscribe((isDarkModeActive: boolean) => {
    this.changeTheAgCircleColor(isDarkModeActive);
    ComponentChangeUtils.detectChanges(this.changeRef);
  });

然后更改AgCircleColor方法

  changeTheAgCircleColor(isDarkModeActive: boolean) {
    if (isDarkModeActive) {
      this.pickupClusterPoints.forEach((point) => {
        point.fillColor = '#FFCF4D';
        point.strokeColor = '#FFEB3B';
      });
    } else {
      console.log('light mode',isDarkModeActive);
      // this.pickupClusterPoints.forEach((point) => {
      //   point.fillColor = '#333';
      //   point.strokeColor = '#333';
      // });
    }
  }

export interface PickupClusterPoint extends PositioningPoint {
  strokeColor?: string;
  fillColor?: string;
 // some other varibles 
}

HTML文件

  <ng-container *ngFor="let point of pickupClusterPoints">
    <agm-circle
       
      [strokeColor]="point.strokeColor"
      [strokeWeight]="point.strokeWeight"
      [fillColor]="point.fillColor"
   
    ></agm-circle>

如果激活了暗模式,则圆圈颜色会发生变化,但是当我恢复为亮模式时,它会保持不变。 else块中的注释代码,如果我取消注释,则它无用,我的意思是订户不起作用,因此没有方法调用。仅console.log有效。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)