Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
karussell committed Jul 10, 2024
1 parent 5146e7f commit b988eeb
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/sidebar/search/AddressInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface AddressInputProps {
point: QueryPoint
points: QueryPoint[]
onCancel: () => void
onAddressSelected: (queryText: string, coord: Coordinate | undefined, bbox: Bbox | undefined) => void
onAddressSelected: (queryText: string, coord: Coordinate | undefined) => void
onChange: (value: string) => void
clearDragDrop: () => void
moveStartIndex: number
Expand Down Expand Up @@ -114,20 +114,19 @@ export default function AddressInput(props: AddressInputProps) {
// try to parse input as coordinate. Otherwise query nominatim
const coordinate = textToCoordinate(text)
if (coordinate) {
props.onAddressSelected(text, coordinate, getBBoxFromCoord(coordinate))
props.onAddressSelected(text, coordinate)
} else if (autocompleteItems.length > 0) {
// by default use the first result, otherwise the highlighted one
getApi().geocode(text, 'nominatim').then(result => {
if (result && result.hits.length > 0) {
const hit: GeocodingHit = result.hits[0]
const res = nominatimHitToItem(hit)
const bbox = hit.extent ? hit.extent : getBBoxFromCoord(hit.point)
props.onAddressSelected(res.mainText + ', ' + res.secondText, hit.point, bbox)
props.onAddressSelected(res.mainText + ', ' + res.secondText, hit.point)
} else {
const index = highlightedResult >= 0 ? highlightedResult : 0
const item = autocompleteItems[index]
if (item instanceof GeocodingItem)
props.onAddressSelected(item.toText(), item.point, item.bbox)
props.onAddressSelected(item.toText(), item.point)
}
})
}
Expand Down Expand Up @@ -222,7 +221,7 @@ export default function AddressInput(props: AddressInputProps) {
setHasFocus(false)
if (item instanceof GeocodingItem) {
hideSuggestions()
props.onAddressSelected(item.toText(), item.point, item.bbox)
props.onAddressSelected(item.toText(), item.point)
} else if (item instanceof SelectCurrentLocationItem) {
hideSuggestions()
onCurrentLocationSelected(props.onAddressSelected)
Expand Down

0 comments on commit b988eeb

Please sign in to comment.