限制 Objective C 中特定城市的 Google 自动完成搜索 api

Restrict GoogleAutocomplete search api for a particular city in Objective C

我已经针对特定国家/地区(例如孟加拉国)限制了 Google 自动完成搜索 api。现在我想将它限制在孟加拉国的达卡市。下面提供了我的代码

  APICommunicator *api = [[APICommunicator alloc] init];
             _searchTermArray=[[NSMutableArray alloc]init];


           NSDictionary *arr = [api getGoogleAPIArrByPOST:[NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/autocomplete/json?input=%@&region=BD&components=country:BD&types=geocode&key=%@",searchTerms,API_KEY]parameter:nil];

            NSString *areaName;
            for (areaName in arr) {
                _searchTermArray=[[arr valueForKey:@"predictions"]valueForKey:@"description"];



            }

请告诉我如何限制城市的方式或代码

由此 documentation,您可以通过传递 cities 类型参数将来自地点自动完成请求的结果限制为特定类型。

the cities type collection instructs the Places service to return results that match locality or administrative_area_level_3.

示例:

请求包含 "Vict" 的城市,结果为巴西葡萄牙语:

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Vict&types=(cities)&language=pt_BR&key=YOUR_API_KEY

希望对您有所帮助!