LocationPicker
LocationPicker copied to clipboard
Swift UI support
Is there any plan to support swift ui i used UIViewControllerRepresentable to integrate picker but search bar won't show
func makeUIViewController(context: Context) -> LocationPickerViewController {
let locationPicker = LocationPickerViewController()
let placemark = MKPlacemark(coordinate: CLLocationCoordinate2D(latitude: initalLat, longitude: initalLong), addressDictionary: nil)
let location = Location(name: "Current location", location: nil, placemark: placemark)
locationPicker.location = location
// button placed on right bottom corner
locationPicker.showCurrentLocationButton = true // default: true
// default: navigation bar's `barTintColor` or `UIColor.white`
locationPicker.currentLocationButtonBackground = .red
// ignored if initial location is given, shows that location instead
locationPicker.showCurrentLocationInitially = true // default: true
locationPicker.mapType = .standard // default: .Hybrid
// for searching, see `MKLocalSearchRequest`'s `region` property
locationPicker.useCurrentLocationAsHint = true // default: false
locationPicker.searchBarPlaceholder = "Search places" // default: "Search or enter an address"
locationPicker.searchHistoryLabel = "Previously searched" // default: "Search History"
// optional region distance to be used for creation region when user selects place from search results
locationPicker.resultRegionDistance = 500 // default: 600
locationPicker.completion = completion
return locationPicker
}
any fix? please help
works fine
`struct LocationPicker: UIViewControllerRepresentable {
func updateUIViewController(_ uiViewController: UINavigationController, context: Context) {
}
func makeUIViewController(context: Context) -> UINavigationController {
let locationPicker = LocationPickerViewController()
//let placemark = MKPlacemark(coordinate: CLLocationCoordinate2D(latitude: initalLat, longitude: initalLong), addressDictionary: nil)
// let location = Location(name: "Current location", location: nil, placemark: placemark)
//locationPicker.location = location
//locationPicker.location = location
locationPicker.showCurrentLocationButton = true
locationPicker.useCurrentLocationAsHint = true
locationPicker.showCurrentLocationInitially = true
// locationPicker.completion = {
// self.location = $0
// }
// button placed on right bottom corner
locationPicker.showCurrentLocationButton = true // default: true
// default: navigation bar's `barTintColor` or `UIColor.white`
locationPicker.currentLocationButtonBackground = .red
// ignored if initial location is given, shows that location instead
locationPicker.showCurrentLocationInitially = true // default: true
locationPicker.mapType = .standard // default: .Hybrid
// for searching, see `MKLocalSearchRequest`'s `region` property
locationPicker.useCurrentLocationAsHint = true // default: false
locationPicker.searchBarPlaceholder = "Search places" // default: "Search or enter an address"
locationPicker.searchHistoryLabel = "Previously searched" // default: "Search History"
// optional region distance to be used for creation region when user selects place from search results
locationPicker.resultRegionDistance = 500 // default: 600
//locationPicker.completion = completion
locationPicker.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(MainViewHelper().closeAction))
let navController = UINavigationController(rootViewController: locationPicker)
navController.modalPresentationStyle = .formSheet
return navController
}
} `