あなたの URl は、現在の場所に近い場所をリストしたいことを示しています。
そのためには、現在地の座標、半径、検索された場所の名前とキーが必要です。
これを行う:
ステップ 1: CoreLocation フレームワークを追加する
ステップ 2: #import
ステップ 3: CLLocationManagerDelegate デリゲートを追加する
ステップ 4: CLLocationManager *locationManager; を作成します。
ステップ 5: CLLocationManager を初期化します (通常は ViewDidLoad 内)。
self.locationManager = [[CLLocationManager alloc] init];// autorelease];
// This is the most important property to set for the manager. It ultimately determines how the manager will
// attempt to acquire location and thus, the amount of power that will be consumed.
locationManager.desiredAccuracy = kCLLocationAccuracyBest ;
// Once configured, the location manager must be "started".
[locationManager startUpdatingLocation];
locationManager.delegate = self;
ステップ 6: CLLocationManager のコードを書く
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
StrCurrentLongitude=[NSString stringWithFormat: @"%f", newLocation.coordinate.longitude]; // string value
StrCurrentLatitude=[NSString stringWithFormat: @"%f", newLocation.coordinate.latitude];
appDeleg.newlocation=newLocation;
[locationManager stopUpdatingLocation]; // string Value
}
ステップ 7: 座標を使用してリクエストを送信する:
[NSURL URLWithString:[NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/search/xml?location=%@,%@&radius=%@&name=%@&sensor=false&key=YOU-API-KEY",StrCurrentLatitude,StrCurrentLongitude,appDeleg.strRadius,strSelectedCategory]
楽しい