2017-02-16 51 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) 



}