Skip to content

Commit

Permalink
feat(search-bar): can set appearance and map is optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc-André Barbeau committed Sep 8, 2020
1 parent 3008300 commit 3102156
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<div class="igo-search-bar-container" [ngClass]="{empty: empty$ | async}">
<mat-form-field [floatLabel]="floatLabel">
<mat-form-field [floatLabel]="floatLabel" [appearance]="appearance">
<mat-label *ngIf="label">{{label}}</mat-label>
<input
#input
matInput
autocomplete="off"
[ngClass]="{'hasSearchIcon': searchIcon}"
[disabled]="disabled$ | async"
[placeholder]="(placeholder$ | async) ? (placeholder$.value | translate) : undefined"
[placeholder]="placeholder ? placeholder : (placeholder$ | async) ? (placeholder$.value | translate) : undefined"
[value]="term$ | async"
(keyup)="onKeyup($event)"
(touchend)="onKeyup($event)">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
ViewChild,
ElementRef
} from '@angular/core';
import { FloatLabelType } from '@angular/material/form-field';
import { FloatLabelType, MatFormFieldAppearance } from '@angular/material/form-field';
import { BehaviorSubject, Subscription, EMPTY, timer } from 'rxjs';
import { debounce, distinctUntilChanged } from 'rxjs/operators';

Expand Down Expand Up @@ -127,6 +127,12 @@ export class SearchBarComponent implements OnInit, OnDestroy {
*/
@Input() floatLabel: FloatLabelType = 'never';

@Input() appearance: MatFormFieldAppearance = 'legacy';

@Input() placeholder: string;

@Input() label: string;

/**
* Icons color (search and clear)
*/
Expand Down
9 changes: 5 additions & 4 deletions packages/geo/src/lib/search/shared/search.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export class SearchService {
return [];
}

const response = stringToLonLat(term, this.mapService.getMap().projection, {
const proj = this.mapService.getMap()?.projection || 'EPSG:3857';
const response = stringToLonLat(term, proj, {
forceNA: options.forceNA
});
if (response.lonLat) {
Expand All @@ -53,7 +54,7 @@ export class SearchService {

options.extent = this.mapService
.getMap()
.viewController.getExtent('EPSG:4326');
?.viewController.getExtent('EPSG:4326');

let sources;

Expand All @@ -64,10 +65,10 @@ export class SearchService {
}

if (options.sourceId) {
sources = sources.filter(source => source.getId() === options.sourceId);
sources = sources.filter((source) => source.getId() === options.sourceId);
} else if (options.searchType) {
sources = sources.filter(
source => source.getType() === options.searchType
(source) => source.getType() === options.searchType
);
}

Expand Down

0 comments on commit 3102156

Please sign in to comment.