As Google’s documentation exhibits zero API to customise or conceal the icon
Google’s official docs for GMSAutocompleteViewController listing all customizable properties:tableCellBackgroundColor
tableCellSeparatorColor
primaryTextColor
secondaryTextColor
primaryTextHighlightColor
tintColor
searchBar
No, you can not take away the circle from the default Google autocomplete controller. Solely workaround is to keep away from utilizing that controller.
Google gives two APIs:
1. Predictions API
2. Place Particulars API
Create Autocomplete ViewModel
class AutocompleteViewModel: ObservableObject {
@Revealed var question = ""
@Revealed var predictions: [GMSAutocompletePrediction] = []
personal let token = GMSAutocompleteSessionToken()
func search() {
GMSPlacesClient.shared().findAutocompletePredictions(
fromQuery: question,
filter: nil,
sessionToken: token
) { outcomes, error in
DispatchQueue.important.async {
self.predictions = outcomes ?? []
}
}
}
func fetchPlace(_ prediction: GMSAutocompletePrediction,
completion: @escaping (GMSPlace?) -> Void) {
let fields: GMSPlaceField = [.name, .coordinate, .formattedAddress]
GMSPlacesClient.shared().fetchPlace(
fromPlaceID: prediction.placeID,
placeFields: fields,
sessionToken: token
) { place, error in
completion(place)
}
}
}
Create customized picker
struct CustomPlacePicker: View {
@StateObject personal var vm = AutocompleteViewModel()
var onSelect: (GMSPlace) -> Void
var physique: some View {
VStack {
TextField("Search location", textual content: $vm.question)
.padding()
.background(.ultraThinMaterial)
.cornerRadius(12)
.onChange(of: vm.question) { _ in vm.search() }
Listing(vm.predictions, id: .placeID) { prediction in
VStack(alignment: .main) {
Textual content(prediction.attributedPrimaryText.string)
.font(.headline)
Textual content(prediction.attributedSecondaryText?.string ?? "")
.font(.subheadline)
.foregroundColor(.secondary)
}
.onTapGesture {
vm.fetchPlace(prediction) { place in
if let place = place { onSelect(place) }
}
}
}
}
.padding()
}
}
