2014-07-01 210 views
0

我使用ILGeoNames作爲搜索國家的地理編碼服務,但它似乎不支持多種語言,我需要的是根據所選語言本地化搜索結果,例如阿拉伯語,法語,火雞等......有沒有辦法做到這一點ILGeoNames?如果沒有,是否有另一個客觀的c地理編碼服務來做到這一點? 在此先感謝。ILGeoNames語言支持

回答

0

在ILGeoNamesLookup.m你有這種功能

- (void)search:(NSString*)query maxRows:(NSInteger)maxRows startRow:(NSUInteger)startRow language:(NSString*)langCode { 
    NSString *urlString; 

    // Sanitize parameters 
    if(!langCode) { 
     NSBundle *bundle = [NSBundle bundleForClass:[self class]]; 
     NSArray *localizations = [bundle preferredLocalizations]; 
     if([localizations count]) 
      langCode = [localizations objectAtIndex:0]; 
     else 
      langCode = @"en"; 
    } 
    if(maxRows > 1000) 
     maxRows = 1000; 

    // Request formatted according to http://www.geonames.org/export/geonames-search.html 
    NSString *escQuery = [query stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 
    urlString = [NSString stringWithFormat:kILGeoNamesSearchURL, escQuery, maxRows, startRow, langCode, userID]; 
    [self sendRequestWithURLString:urlString]; 
} 

如果你把參數的langCode搜索將在您所選擇的語言返回。我已經嘗試過使用「es」,它正在正常工作。

乾杯