如何用LBS開放平臺開發(fā)全英文iOS 地圖應(yīng)用
?儅?
8.0) { [_locationManager requestAlwaysAuthorization]; }} //初始化MapView- (void) initMapView{ //構(gòu)造MKMapView _mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 21, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds))]; _mapView.delegate = self; _mapView.showsUserLocation = YES;//顯示標注圖標 [_mapView setUserTrackingMode:MKUserTrackingModeFollow];//設(shè)置標注模式 //將mapview添加到Subview中 [self.view addSubview:_mapView]; }第三步:初始化主搜索對象AMapSearchAPI構(gòu)造AMapSearchAPI對象,并設(shè)置搜索結(jié)果語言。(支持英文結(jié)果的搜索功能包括:POI搜索、逆地理編碼和地理編碼、輸入提示,能夠滿足基本的搜索功能)//初始化AMapSearchAPI- (void)initSearch{ //構(gòu)造AMapSearchAPI _search = [[AMapSearchAPI alloc] initWithSearchKey:APIKey Delegate:self]; _search.language = AMapSearchLanguage_en;//設(shè)置語言}第四步:構(gòu)造搜索對象,設(shè)置搜索參數(shù),發(fā)起,在相應(yīng)的回調(diào)中進行結(jié)果展示(如:POI結(jié)果以大頭針標注等等)。以Demo中的POI為例,以選擇的輸入提示語為關(guān)鍵字/* POI 搜索. */- (void)searchPOIWithKey:(NSString *) adcode:(NSString *)adcode{ if (.length == 0) { return; }//構(gòu)造POI搜索對象AMapPlaceSearchRequestAMapPlaceSearchRequest *place = [[AMapPlaceSearchRequest alloc] init];//設(shè)置關(guān)鍵字、 place.s = ; place.requireExtension = YES;//設(shè)置成YES,返回信息詳細,較費 if (adcode.length > 0) { place.city = @[adcode]; } //發(fā)起 [_search AMapPlaceSearch:place];} //回調(diào)中顯示結(jié)果- (void)onPlaceSearchDone:(AMapPlaceSearchRequest *)request response:(AMapPlaceSearchResponse *)respons{ if (respons.s.count == 0) { return; } NSMutableArray *Annotations = [NSMutableArray arrayWithCapacity:respons.s.count]; [respons.s enumerateObjectsUsingBlock:^(AMapPOI *obj, NSUInteger idx, BOOL *stop) { [Annotations addObject:[[POIAnnotation alloc] initWithPOI:obj]]; }]; /* 將結(jié)果以annotation的形式加載到地圖上. */ [_mapView addAnnotations:Annotations]; /* 如果只有一個結(jié)果,設(shè)置其為中心點. */ if (Annotations.count == 1) { _mapView.centerCoordinate = [Annotations[0] coordinate]; } /* 如果有多個結(jié)果, 設(shè)置地圖使所有的annotation都可見. */ else { [_mapView showAnnotations:Annotations animated:NO]; }}
2021-09-23 17:37:38 1108查看 0回答
B人的男人
2021-09-23 17:37:54 1088查看 1回答
花次元
2021-09-23 17:39:33 599查看 2回答
咕嚕咕嚕
2021-09-23 17:45:26 747查看 4回答
2021-09-23 17:51:32 521查看 2回答
2021-09-23 17:53:14 590查看 0回答
2021-09-23 17:53:14 489查看 0回答