您当前的位置: IOS API 概述
基础地图

初始化地图界面

1.在您的AppDelegate.m文件中添加对HYHandlerEnvironment的初始化,并填入您申请的授权Key,示例如下

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    [HYHandlerEnvironment setAppkey:@"1v3s0684t30F93z20n86615n"];
    return YES;
}
									

2.创建HYTDTMapView

CGFloat origin_y = 64;
self.mapView = [[HYTDTMapView alloc] initWithFrame:CGRectMake(0, origin_y, self.view.bounds.size.width, self.view.bounds.size.height-origin_y)];
self.mapView.delegate = self;
//显示当前位置
self.mapView.showUserLocation = YES;
//当前位置的图标(如果要显示当前位置,此项必须设置)
self.mapView.userLocationImage = [UIImage imageNamed:@"user_location"];
[self.view addSubview:self.mapView];
									

编译,运行,效果如下图所示:

ios-jicheng.jpg