如何用LBS開放平臺開發全英文iOS 地圖應用
?儅?
8.0) { [_locationManager requestAlwaysAuthorization]; }} //初始化MapView- (void) initMapView{ //構造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];//設置標注模式 //將mapview添加到Subview中 [self.view addSubview:_mapView]; }第三步:初始化主搜索對象AMapSearchAPI構造AMapSearchAPI對象,并設置搜索結果語言。(支持英文結果的搜索功能包括:POI搜索、逆地理編碼和地理編碼、輸入提示,能夠滿足基本的搜索功能)//初始化AMapSearchAPI- (void)initSearch{ //構造AMapSearchAPI _search = [[AMapSearchAPI alloc] initWithSearchKey:APIKey Delegate:self]; _search.language = AMapSearchLanguage_en;//設置語言}第四步:構造搜索對象,設置搜索參數,發起,在相應的回調中進行結果展示(如:POI結果以大頭針標注等等)。以Demo中的POI為例,以選擇的輸入提示語為關鍵字/* POI 搜索. */- (void)searchPOIWithKey:(NSString *) adcode:(NSString *)adcode{ if (.length == 0) { return; }//構造POI搜索對象AMapPlaceSearchRequestAMapPlaceSearchRequest *place = [[AMapPlaceSearchRequest alloc] init];//設置關鍵字、 place.s = ; place.requireExtension = YES;//設置成YES,返回信息詳細,較費 if (adcode.length > 0) { place.city = @[adcode]; } //發起 [_search AMapPlaceSearch:place];} //回調中顯示結果- (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]]; }]; /* 將結果以annotation的形式加載到地圖上. */ [_mapView addAnnotations:Annotations]; /* 如果只有一個結果,設置其為中心點. */ if (Annotations.count == 1) { _mapView.centerCoordinate = [Annotations[0] coordinate]; } /* 如果有多個結果, 設置地圖使所有的annotation都可見. */ else { [_mapView showAnnotations:Annotations animated:NO]; }}
2021-09-23 17:37:38 1077查看 0回答
B人的男人
2021-09-23 17:37:54 1060查看 1回答
花次元
2021-09-23 17:39:33 580查看 2回答
咕嚕咕嚕
2021-09-23 17:45:26 728查看 4回答
2021-09-23 17:51:32 501查看 2回答
2021-09-23 17:53:14 573查看 0回答
2021-09-23 17:53:14 465查看 0回答