目录

创建地图实例

设置国家码

初始化地图前,可以设置国家码:

使用HMapService的setCountryCode方法设置国家码,如果未设置,将以IP自动判断国家码。

地图容器

目前地图SDK支持的地图容器为HMapView。HMapView是iOS UIView类的子类,允许您将地图放置在iOS视图中。MapView充当地图的容器。

[h2]MapView

  1. 在ViewController中创建地图。

    self.mapView = [[HMapView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame) - CGRectGetMinY(self.navigationController.navigationBar.frame))
    self.mapView.delegate = self; 
    self.mapView.centerCoordinate = CLLocationCoordinate2DMake(48.893478, 2.334595); 
    [self.view addSubview:self.mapView]; 
    self.mapView.showsScale = false; 

  2. 运行您刚完成的工程就可以在您的App中看到地图了。运行效果如图所示: