Skip to content

Commit

Permalink
+ Filter CAR and UC fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesCodesUFG committed Feb 7, 2025
1 parent 4880b60 commit e47a8fb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
2 changes: 2 additions & 0 deletions client/src/app/@core/services/map.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class MapService {
public addLayer(layer: BaseLayer): void {
if (!this.layers.every(element => element.get('key') != layer.get('key'))) return;

console.log('adicionaou')

this._map.addLayer(layer);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ import { TextFilter } from '@core/interfaces';
import {
RegionFilterService,
DEFAULT_REGION,
DescriptorService,
MapAPIService,
} from '@core/services';
import { MapService } from '@core/services/map.service';

/**
* PrimeNg imports.
*/
import { MessageService, SelectItem } from 'primeng/api';
import { AutoCompleteCompleteEvent } from 'primeng/autocomplete';

/**
Expand Down Expand Up @@ -91,7 +89,6 @@ export class FilterComponent implements OnInit, OnDestroy {

public otherLayerFromFilters: any = {
layer: null,
strokeColor: '#363230',
};

private source: VectorSource<any> = new VectorSource();
Expand All @@ -106,9 +103,7 @@ export class FilterComponent implements OnInit, OnDestroy {
constructor(
private mapService: MapService,
private regionFilterService: RegionFilterService,
private descriptorService: DescriptorService,
private mapAPIService: MapAPIService,
private messageService: MessageService
) {}

public ngOnInit(): void {
Expand Down Expand Up @@ -137,7 +132,7 @@ export class FilterComponent implements OnInit, OnDestroy {
this.onChangeSearchOption();
}

ngOnDestroy(): void {}
public ngOnDestroy(): void {}

public onClearFilter() {
this.updateRegion(DEFAULT_REGION);
Expand All @@ -158,7 +153,7 @@ export class FilterComponent implements OnInit, OnDestroy {
public filterSearch(event: AutoCompleteCompleteEvent): void {
let query: string = event.query;

switch (this.selectedSearchOption.toLowerCase()) {
switch (this.selectValue.toLowerCase()) {
case 'region':
this.mapAPIService.getRegions(query).subscribe((result) => {
this.listForAutoComplete = result.search;
Expand Down Expand Up @@ -250,14 +245,12 @@ export class FilterComponent implements OnInit, OnDestroy {
});
}

private async updateAreaOnMap(event: any) {
private updateAreaOnMap(event: any) {
if (this.selectRegion != DEFAULT_REGION) {
await this.clearAreaBeforeSearch();
this.onClearFilter()
}

let map = this.mapService.map;

map.removeLayer(this.otherLayerFromFilters.layer);
this.mapService.removeLayer(this.otherLayerFromFilters.layer);

this.autoCompleteValue = event;

Expand All @@ -269,18 +262,22 @@ export class FilterComponent implements OnInit, OnDestroy {
});

this.otherLayerFromFilters.layer = new VectorLayer({
zIndex: 10000000,
zIndex: 99,
source: vectorSource,
properties: {
key: 'filter',
type: 'filter',
},
style: [
new Style({
stroke: new Stroke({
color: this.otherLayerFromFilters.strokeColor,
color: '#363230',
width: 4,
}),
}),
new Style({
stroke: new Stroke({
color: this.otherLayerFromFilters.strokeColor,
color: '#363230',
width: 4,
lineCap: 'round',
}),
Expand All @@ -289,12 +286,9 @@ export class FilterComponent implements OnInit, OnDestroy {
});

this.mapService.addLayer(this.otherLayerFromFilters.layer);

let extent = this.otherLayerFromFilters.layer.getSource().getExtent();

map.getView().fit(extent, { duration: 1800 });
}

private async clearAreaBeforeSearch() {
await this.updateRegion(DEFAULT_REGION);
this.mapService.map.getView().fit(extent, { duration: 1800 });
}
}

0 comments on commit e47a8fb

Please sign in to comment.