2012-12-01 2 views
1

신생아 iPhone 개발에 익숙하지 않습니다. 나는 url 요청에 위도와 langtitude를 보내지 않고 새로운 위치를 얻는 방법을 알아야한다.아이폰에 구글 장소에 새로운 위치를 얻는 방법?

NSURL *URL = [NSURL URLWithString:@"https://maps.googleapis.com/maps/api/place/search   /json?location=40.7143528,-74.0059731&radius=10000&types=school&sensor=false&key=AIzaSyDbiWWIOmc08YSb9DAkdyTWXh_PirVuXpM"]; 

이것은 여기 내 코드입니다. iat와 lang 값을 url 요청을 통해 요청 했으므로 이제이 두 값을주지 않아도됩니다. 현재 값을 받아 들여야합니다.

+0

당신의 장치를 오래 걸릴 거라고 말하는 건가요 ??? –

+0

@InderKumarRathore : 예 inder kumar rathore – Vijay

답변

0
locationManager = [[CLLocationManager alloc] init]; 
locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move 
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; // 100 m 
[locationManager startUpdatingLocation]; 

//These are your delegate methods 
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { 
    //if the time interval returned from core location is more than two minutes we ignore it because it might be from an old session 
    if (abs([newLocation.timestamp timeIntervalSinceDate: [NSDate date]]) < 120) {  
     // Make your request here as 
     NSString *urlStr = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/search/json?location=%f,%f&radius=10000&types=school&sensor=false&key=AIzaSyDbiWWIOmc08YSb9DAkdyTWXh_PirVuXpM",newLocation.Latitude,newLocation.Longitude]; 
     NSURL *URL = [NSURL URLWithString:urlStr]; 

    } 
} 

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { 
    UIAlertView *alert; 
    alert = [[UIAlertView alloc] initWithTitle:@"Error" message:[error description] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
    [alert show]; 
    [alert release]; 
}