在IOS上,寻找选项来检测当前位置在谷歌地点sdk

我不熟悉Swift3,但是我从自由职业者开发我的应用程序,但他们说,他们不能够添加检测当前位置在谷歌地点api sdk执行在我的IOS应用程序开发swift3search地址。 我正在尝试执行我的地址search页面,如下所示

当前位置链接应该像在图像上自动检测用户的当前位置

在这个function的任何指针将是一个很大的帮助。 请分享我可以与开发人员分享的这种实现的任何示例/教程来实现。

先安装

pod 'GooglePlaces' pod 'GooglePlacePicker' pod 'GoogleMaps' 

然后按照下面的代码只是为了查看

 import GoogleMaps import GooglePlaces class SrarchPlacesViewController: UIViewController, UISearchDisplayDelegate,UISearchBarDelegate { @IBOutlet weak var searchView: UISearchBar! var searchBar: UISearchBar? var tableDataSource: GMSAutocompleteTableDataSource? var srchDisplayController: UISearchDisplayController? var resultsViewController: GMSAutocompleteResultsViewController? var searchController: UISearchController? override func viewDidLoad() { super.viewDidLoad() searchView.delegate = self searchBar = UISearchBar(frame: CGRect(x: 0, y: 0, width: 250.0, height: 44.0)) tableDataSource = GMSAutocompleteTableDataSource() tableDataSource?.delegate = self srchDisplayController = UISearchDisplayController(searchBar: searchView, contentsController: self) srchDisplayController?.searchResultsDataSource = tableDataSource srchDisplayController?.searchResultsDelegate = tableDataSource srchDisplayController?.delegate = self } @objc(didUpdateAutocompletePredictionsForTableDataSource:) func didUpdateAutocompletePredictions(for tableDataSource: GMSAutocompleteTableDataSource) { // Turn the network activity indicator off. UIApplication.shared.isNetworkActivityIndicatorVisible = false // Reload table data. srchDisplayController?.searchResultsTableView.reloadData() } @objc(didRequestAutocompletePredictionsForTableDataSource:) func didRequestAutocompletePredictions(for tableDataSource: GMSAutocompleteTableDataSource) { // Turn the network activity indicator on. UIApplication.shared.isNetworkActivityIndicatorVisible = true // Reload table data. srchDisplayController?.searchResultsTableView.reloadData() } //MARK:- SEARCH BAR FUCNTION func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) { // self.tableViews.hidden = true dPrint("BIGIN") } func searchBarTextDidEndEditing(_ searchBar: UISearchBar) { // self.tableViews.hidden = false dPrint("ending") } func searchBarCancelButtonClicked(_ searchBar: UISearchBar) { // self.tableViews.hidden = false dPrint("cancel") } func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) { if(searchText == ""){ dPrint("text chnange") // self.tableViews.hidden = false } } @objc(tableDataSource:didSelectPrediction:) func tableDataSource(_ tableDataSource: GMSAutocompleteTableDataSource, didSelect prediction: GMSAutocompletePrediction) -> Bool { return true } } extension SrarchPlacesViewController: GMSAutocompleteTableDataSourceDelegate{ /** * Called when a non-retryable error occurred when retrieving autocomplete predictions or place * details. A non-retryable error is defined as one that is unlikely to be fixed by immediately * retrying the operation. * <p> * Only the following values of |GMSPlacesErrorCode| are retryable: * <ul> * <li>kGMSPlacesNetworkError * <li>kGMSPlacesServerError * <li>kGMSPlacesInternalError * </ul> * All other error codes are non-retryable. * @param tableDataSource The |GMSAutocompleteTableDataSource| that generated the event. * @param error The |NSError| that was returned. */ public func tableDataSource(_ tableDataSource: GMSAutocompleteTableDataSource, didFailAutocompleteWithError error: Error) { dPrint("Error: \(error.localizedDescription)") } func tableDataSource(_ tableDataSource: GMSAutocompleteTableDataSource, didAutocompleteWith place: GMSPlace) { srchDisplayController?.isActive = false // Do something with the selected place. print(place.coordinate) print("Place name: \(place.name)") print("Place address: \(place.formattedAddress)") print("Place attributions: \(place.attributions)") } @objc(searchDisplayController:shouldReloadTableForSearchString:) func searchDisplayController(_ controller: UISearchDisplayController, shouldReloadTableForSearch searchString: String?) -> Bool { tableDataSource?.sourceTextHasChanged(searchString) return false } }