2017-02-16 45 views
0

我使用谷歌的地方iOS SDK來搜索附近的地方。我通過Xcode在我的設備上模擬了丹佛的位置。但是,當搜索「星巴克」時,我期待在列表中看到「星巴克,3110E 1st Ave,Denver,CO 80206」。但我不知道。只有當我使用「星巴克,3110 E」進行搜索時,我才能看到它。以下是我正在使用的代碼:谷歌放置iOS SDK搜索時不返回附近的地方

CLLocation *userLocation = [[CLLocation alloc] initWithLatitude:latitude longitude:longitude]; 

    GMSAutocompleteFilter *filter = [[GMSAutocompleteFilter alloc] init]; 
    filter.type = kGMSPlacesAutocompleteTypeFilterNoFilter; 
    GMSAutocompleteViewController *acController = [[GMSAutocompleteViewController alloc] init]; 
    acController.delegate = self; 
    acController.autocompleteFilter.type = kGMSPlacesAutocompleteTypeFilterNoFilter; 
    CLLocationCoordinate2D newLocation = [self locationWithBearing:userLocation.course distance:30000.0 fromLocation:userLocation.coordinate]; 

    acController.autocompleteBounds = [[GMSCoordinateBounds alloc]initWithCoordinate:userLocation.coordinate coordinate:newLocation]; 

newlocation使用用戶位置計算的30英里範圍。

請糾正我,如果我做錯了什麼。

+0

爲什麼這個問題被標記爲「Android」! –

+0

嗨Atef,我在Android也有同樣的問題..所以也想到標籤...我需要刪除它嗎? – user3584797

+0

你不能發佈Android和IOS的一個問題和一個代碼,因爲它們是不同的,STO的讀者也不同,請發表另一個問題。任何方式@Selvin編輯你的問題,並刪除了Android標籤 –

回答

0

你必須提供附近地點的界限。

func openPlacePicker(){  

let acController = GMSAutocompleteViewController() 
    let neBoundsCorner = CLLocationCoordinate2D(latitude: (locationManager.location?.coordinate.latitude)!, 
               longitude: (locationManager.location?.coordinate.longitude)!) 

    let swBoundsCorner = CLLocationCoordinate2D(latitude: (locationManager.location?.coordinate.latitude.abs)! + 1, 
               longitude: (locationManager.location?.coordinate.longitude.abs)! + 1) 

    let bounds = GMSCoordinateBounds(coordinate: neBoundsCorner, 
            coordinate: swBoundsCorner) 

    acController.autocompleteBounds = bounds 

    acController.delegate = self 
    present(acController, animated: true, completion: nil) 



}