File tree Expand file tree Collapse file tree 3 files changed +12
-3
lines changed
Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,10 @@ export class Search implements SearchInterface {
4848 return this ;
4949 }
5050
51+ public getInput ( ) : HTMLInputElement | undefined {
52+ return this . searchUi . getInput ( ) ;
53+ }
54+
5155 public getContainer ( ) : HTMLElement | undefined {
5256 return this . searchUi . getContainer ( ) ;
5357 }
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ export class SearchUi implements SearchUiInterface {
5555 listItem . addEventListener ( 'click' , ( ) => {
5656 this . itemClickListeners . forEach ( listener => listener ( item ) ) ;
5757 if ( this . input ) {
58- this . input . value = item . address as string ;
58+ this . input . value = this . getTitleFromPlaceSchema ( item ) ;
5959 this . input . focus ( ) ;
6060 }
6161
@@ -77,6 +77,7 @@ export class SearchUi implements SearchUiInterface {
7777 }
7878
7979 private getTitleFromPlaceSchema ( item : PlaceObject ) : string {
80+ console . log ( item ) ;
8081 if ( ! item . address ) {
8182 return item . name as string ?? '' ;
8283 }
@@ -85,6 +86,10 @@ export class SearchUi implements SearchUiInterface {
8586 return item . address ;
8687 }
8788
89+ if ( 'name' in item . address ) {
90+ return item . address . name as string ;
91+ }
92+
8893 const address = [ ] ;
8994
9095 if ( item . name ) {
@@ -107,7 +112,6 @@ export class SearchUi implements SearchUiInterface {
107112 address . push ( item . address . postalCode ) ;
108113 }
109114
110-
111115 if ( 'addressCountry' in item . address ) {
112116 address . push ( item . address . addressCountry ) ;
113117 }
@@ -214,7 +218,7 @@ export class SearchUi implements SearchUiInterface {
214218 return this . resetButton ;
215219 }
216220
217- private getInput ( ) : HTMLInputElement | undefined {
221+ public getInput ( ) : HTMLInputElement | undefined {
218222 if ( ! this . input ) {
219223 this . input = this . getContainer ( ) ?. querySelector ( 'input' ) ?? undefined ;
220224 }
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ export interface SearchUiInterface extends AddTo {
1515 removeSearch ( ) : this;
1616 getContainer ( ) : HTMLElement | undefined ;
1717 addTo ( map : MapInterface ) : this;
18+ getInput ( ) : HTMLInputElement | undefined ;
1819 setSearchListItems ( items : any ) : this;
1920 addListItemListener ( listItemClickListener : ListItemClickListener ) : this;
2021}
You can’t perform that action at this time.
0 commit comments