如何用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 1007查看 0回答
2021-09-23 17:39:33 520查看 2回答
2021-09-23 17:45:26 672查看 4回答
2021-09-23 17:51:32 463查看 2回答
2021-09-23 17:53:14 510查看 0回答
2021-09-23 17:53:14 400查看 0回答