Skip to content

Commit

Permalink
feat(project): add vicinity as option
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyNahas committed Jan 3, 2020
1 parent 3a96f05 commit 898c17a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@
<!-- <mat-icon color="primary" matSuffix>add_location</mat-icon>-->
<!-- <mat-error>{{ 'msa.contactData.currentAddress.error' | translate }}</mat-error>-->
</mat-form-field>
<mat-form-field *ngIf="showVicinity" fxFlex="auto" [appearance]="appearance"
[@animate]="{ value: '*', params: { y: '100%' } }">
<mat-label>{{vicinityLabel}}</mat-label>
<input
matInput
formControlName="vicinity"
/>
</mat-form-field>
<div formGroupName="locality" fxFlex="auto">
<mat-form-field fxFlex="auto" [appearance]="appearance" [@animate]="{ value: '*', params: { y: '100%' } }">
<mat-label>{{localityLabel}}</mat-label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ export class MatSearchGoogleMapsAutocompleteComponent implements OnInit {
@Input()
localityLabel = 'Locality';

@Input()
vicinityLabel = 'Vicinity';

@Input()
showVicinity: boolean;

@Input()
country: string | string[];

Expand Down Expand Up @@ -67,6 +73,7 @@ export class MatSearchGoogleMapsAutocompleteComponent implements OnInit {
streetName: [null, Validators.required],
streetNumber: [null, Validators.required],
postalCode: [null, Validators.required],
vicinity: [null],
locality: this.formBuilder.group({
long: [null, Validators.required],
}),
Expand All @@ -79,7 +86,9 @@ export class MatSearchGoogleMapsAutocompleteComponent implements OnInit {
}
const germanAddress: GermanAddress = parseGermanAddress($event);
this.germanAddress = germanAddress;
console.log('syncAutoComplete', $event, 'after parsing', germanAddress);
if (germanAddress.vicinity) {
this.addressFormGroup.get('vicinity').patchValue(germanAddress.vicinity);
}
if (germanAddress.streetName) {
this.addressFormGroup.get('streetName').patchValue(germanAddress.streetName);
}
Expand All @@ -94,8 +103,6 @@ export class MatSearchGoogleMapsAutocompleteComponent implements OnInit {
}

this.onGermanAddressMapped.emit(germanAddress);

console.log('address', this.addressFormGroup.getRawValue());
}

}
1 change: 1 addition & 0 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ <h2>Usage</h2>
<mat-card-content>
<mat-search-google-maps-autocomplete appearance="outline"
country="de"
[showVicinity]="true"
(onGermanAddressMapped)="onGermanAddressMapped($event)">
</mat-search-google-maps-autocomplete>
</mat-card-content>
Expand Down

0 comments on commit 898c17a

Please sign in to comment.