2017-03-16 2 views
-1

에지도 작성 장소를 자동 완성하는 방법 이것은 Baidu API를 처음 사용하는 것입니다. 내 프로젝트에 Baidu 장소 자동 완성 API를 구현하는 데 문제가 있습니다. 나는 http://lbsyun.baidu.com/index.php?title=iossdk에 Baidu 개발자 링크를 사용하고 있습니다.Baidu Map in IOS SDK

누군가 나에게이 자습서를 제공 해주시겠습니까?

이 자습서는 다음과 같습니다.

link하지만,이 튜토리얼에서 나는, JSON 파일을 수신 오류를 나에게

{ "상태"를 줄 수 : 102, "메시지": "MCODE 매개 변수가 존재하지 않는, 모바일 형 mCode를 필수 매개 변수 "}

+0

이 일을이 기능을 사용해야 함을 의미 당신은 "자동 완성 (autocomplete)"을 의미하며 어떤 기능을 수행하고 싶습니까? –

+0

내가 뭔가를 입력하면 근처 장소에 대한 제안을 전합니다. –

답변

1

BaiduMapKit의 POI 검색 모듈을 사용해야합니다. 이렇게하십시오.

BMKCitySearchOption *citySearchOption = [[BMKCitySearchOption alloc]init]; 
citySearchOption.pageIndex = curPage;//here is the page index , you can set it to 0 
citySearchOption.pageCapacity = 10; 
citySearchOption.city= @"上海";//here is the city where you want to search the road 
citySearchOption.keyword = @"淮海路";//here is the road name or someplace name you want to search 
BOOL flag = [_poisearch poiSearchInCity:citySearchOption]; 
if(flag) { 
    _nextPageButton.enabled = true; 
    NSLog(@"success"); 
} 
else { 
    _nextPageButton.enabled = false; 
    NSLog(@"fail"); 
} 
+0

확인해 보겠습니다. 감사합니다. –

0

바이두 웹 API를 사용하여 바이두지도에서 자동 완성 구현은

- (void)viewDidLoad { 
    BaseString = @"http://api.map.baidu.com/place/v2/suggestion?query="; 
    ak = @"56dIEtBAp1CU7u8ZMcq8DyUH2mVsn38x"; mcode = @"com.baidu.Baidu-Map-Demo"; 
    regionkey = @"中国"; 
    PathString = @"http://api.map.baidu.com/direction/v2/transit?origin="; 
    self .mapView .userTrackingMode = BMKUserTrackingModeFollow; 
    // 2. Set the map type self.mapView.mapType = BMKMapTypeStandard; 
    // 3. Set Agent self.mapView.delegate = self; 
    [super viewDidLoad]; 
    mapView.frame = CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height); 
    mapView.delegate = self; anotation = [[BMKPointAnnotation alloc]init]; 
    destination = [[BMKPointAnnotation alloc]init]; 
    PathUrl = [[NSURL alloc]init]; 
    finalPathArray = [[NSMutableArray alloc]init]; 
    session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; 
    downloadURL = [[NSURL alloc]init]; 
    path = [[BMKPolyline alloc]init]; 
    flag = 0; 
} 

-(void)GetSuggestion: (NSString *)query { 
    NSString *stringUrl = [NSString stringWithFormat:@"%@%@&page_size=10&page_num=0&scope=1&region=%@&output=json&ak=%@&mcode=%@",BaseString,query,regionkey,ak,mcode]; stringUrl = [stringUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]; 
    downloadURL = [NSURL URLWithString:stringUrl]; 
    if (downloadURL != nil) { 
     if (DownloadTask != nil) { 
      [DownloadTask suspend]; 
     } 
     DownloadTask = [session dataTaskWithURL:downloadURL completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { 
      NSDictionary *AutocompleteData = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil]; 
      resultArray = AutocompleteData[@"result"]; 
      tbl_result.hidden = NO; 
      [tbl_result reloadData]; 
     }]; 
     [DownloadTask resume]; 
    } 
} 

MCODE 매개 변수는 번들 ​​ID가 자동 완성에 대한 자동 완성에 대한 URLFor의 예를 쓰기 URL을 spacify 번들 ID가

+0

확인하겠습니다. 감사합니다. –

+0

버그를 발견하면 알려주십시오. –