@@ -23,7 +23,7 @@ export interface AddressInputProps {
2323 point : QueryPoint
2424 points : QueryPoint [ ]
2525 onCancel : ( ) => void
26- onAddressSelected : ( queryText : string , coord : Coordinate | undefined ) => void
26+ onAddressSelected : ( queryText : string , streetHint : string , coord : Coordinate | undefined ) => void
2727 onChange : ( value : string ) => void
2828 clearDragDrop : ( ) => void
2929 moveStartIndex : number
@@ -59,6 +59,7 @@ export default function AddressInput(props: AddressInputProps) {
5959 new GeocodingItem (
6060 obj . mainText ,
6161 obj . secondText ,
62+ hit . street ,
6263 hit . point ,
6364 hit . extent ? hit . extent : getBBoxFromCoord ( hit . point )
6465 )
@@ -120,13 +121,13 @@ export default function AddressInput(props: AddressInputProps) {
120121 // try to parse input as coordinate. Otherwise query nominatim
121122 const coordinate = textToCoordinate ( text )
122123 if ( coordinate ) {
123- props . onAddressSelected ( text , coordinate )
124+ props . onAddressSelected ( text , '' , coordinate )
124125 } else if ( autocompleteItems . length > 0 ) {
125126 const index = highlightedResult >= 0 ? highlightedResult : 0
126127 const item = autocompleteItems [ index ]
127128 if ( item instanceof POIQueryItem ) {
128129 handlePoiSearch ( poiSearch , item . result , props . map )
129- props . onAddressSelected ( item . result . text ( item . result . poi ) , undefined )
130+ props . onAddressSelected ( item . result . text ( item . result . poiType ) , '' , undefined )
130131 } else if ( highlightedResult < 0 && ! props . point . isInitialized ) {
131132 // by default use the first result, otherwise the highlighted one
132133 getApi ( )
@@ -135,13 +136,17 @@ export default function AddressInput(props: AddressInputProps) {
135136 if ( result && result . hits . length > 0 ) {
136137 const hit : GeocodingHit = result . hits [ 0 ]
137138 const res = nominatimHitToItem ( hit )
138- props . onAddressSelected ( res . mainText + ', ' + res . secondText , hit . point )
139+ props . onAddressSelected (
140+ res . mainText + ', ' + res . secondText ,
141+ hit . street ,
142+ hit . point
143+ )
139144 } else if ( item instanceof GeocodingItem ) {
140- props . onAddressSelected ( item . toText ( ) , item . point )
145+ props . onAddressSelected ( item . toText ( ) , item . street , item . point )
141146 }
142147 } )
143148 } else if ( item instanceof GeocodingItem ) {
144- props . onAddressSelected ( item . toText ( ) , item . point )
149+ props . onAddressSelected ( item . toText ( ) , item . street , item . point )
145150 }
146151 }
147152 // do not disturb 'tab' cycle
@@ -262,10 +267,10 @@ export default function AddressInput(props: AddressInputProps) {
262267 highlightedItem = { autocompleteItems [ highlightedResult ] }
263268 onSelect = { item => {
264269 if ( item instanceof GeocodingItem ) {
265- props . onAddressSelected ( item . toText ( ) , item . point )
270+ props . onAddressSelected ( item . toText ( ) , item . street , item . point )
266271 } else if ( item instanceof POIQueryItem ) {
267272 handlePoiSearch ( poiSearch , item . result , props . map )
268- setText ( item . result . text ( item . result . poi ) )
273+ setText ( item . result . text ( item . result . poiType ) )
269274 }
270275 searchInput . current ! . blur ( ) // see also AutocompleteEntry->onMouseDown
271276 } }
0 commit comments