Skip to content

Commit

Permalink
recenter map on project area selection
Browse files Browse the repository at this point in the history
  • Loading branch information
lastminutediorama committed Dec 20, 2024
1 parent f9490b7 commit 6598242
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import {
METRICS,
} from './metrics';
import { MapGeoJSONFeature } from 'maplibre-gl';
import { ImpactsProjectArea } from './direct-impacts/direct-impacts.component';
import { PrescriptionAction } from './prescriptions';
import { TreatmentsService } from '@services/treatments.service';
import { Injectable } from '@angular/core';
import { TreatmentPlan } from '../types';
import { TreatmentPlan, TreatmentProjectArea } from '../types';

export interface ImpactsResultData {
year: number;
Expand Down Expand Up @@ -53,7 +52,7 @@ export class DirectImpactsStateService {
public activeTreatmentPlan$ = this._activeTreatmentPlan$.asObservable();

private _selectedProjectArea$ =
new BehaviorSubject<ImpactsProjectArea | null>(null);
new BehaviorSubject<TreatmentProjectArea | null>(null);
public selectedProjectArea$ = this._selectedProjectArea$.asObservable();

private _changeOverTimeData$ = new BehaviorSubject<
Expand Down Expand Up @@ -128,9 +127,8 @@ export class DirectImpactsStateService {
this._selectedMetrics$.next(selections);
}

setProjectAreaForChanges(projectArea: ImpactsProjectArea | null) {
setProjectAreaForChanges(projectArea: TreatmentProjectArea | null) {
this._selectedProjectArea$.next(projectArea);

//then refresh the changes chart data
this.getChangesOverTimeData();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ import { ExpandedChangeOverTimeChartComponent } from '../expanded-change-over-ti
import { MatDialog } from '@angular/material/dialog';
import { ExpandedDirectImpactMapComponent } from '../expanded-direct-impact-map/expanded-direct-impact-map.component';
import { MapGeoJSONFeature } from 'maplibre-gl';

export interface ImpactsProjectArea {
project_area_id: number;
project_area_name: string;
}
import { TreatmentProjectArea } from '@types';

@Component({
selector: 'app-direct-impacts',
Expand Down Expand Up @@ -187,8 +183,14 @@ export class DirectImpactsComponent implements OnInit, OnDestroy {
Chart.unregister(ChartDataLabels);
}

setChartProjectArea(e: ImpactsProjectArea) {
this.directImpactsStateService.setProjectAreaForChanges(e);
setChartProjectArea(pa: TreatmentProjectArea) {
this.directImpactsStateService.setProjectAreaForChanges(pa);
if (!pa) {
const s = this.treatmentsState.getCurrentSummary();
this.mapConfigState.updateMapCenter(s.extent);
return;
}
this.mapConfigState.updateMapCenter(pa.extent);
}

expandChangeChart() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { DirectImpactsStateService } from '../direct-impacts.state.service';
import { FormsModule } from '@angular/forms';
import { TreatmentsState } from '../treatments.state';
import { map } from 'rxjs';
import { ImpactsProjectArea } from '../direct-impacts/direct-impacts.component';
import { TreatmentProjectArea } from '@types';

@Component({
selector: 'app-expanded-change-over-time-chart',
Expand Down Expand Up @@ -43,7 +43,7 @@ export class ExpandedChangeOverTimeChartComponent {
})
);

setChartProjectArea(e: ImpactsProjectArea) {
setChartProjectArea(e: TreatmentProjectArea) {
this.directImpactsStateService.setProjectAreaForChanges(e);
}

Expand Down

0 comments on commit 6598242

Please sign in to comment.