如何初始化一个iOS原生地图

时间:2022-06-13 23:53:14

/**

初始化一个mapView  需导入 #import <MapKit/MapKit.h>

- returns: 返回一个mapView对象

*/

mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0,WIDTH, HEIGHT-200)];

/**

*  设置代理

*/

mapView.delegate = self;

/**

*  设置地图类型

*/

mapView.mapType = 0;

/**

*  设置是否可缩放

*/

mapView.zoomEnabled = YES;

/**

*  设置是否可滚动

*/

mapView.scrollEnabled = YES;

/**

*  设置是否显示用户当前位置

*/

mapView.showsUserLocation = YES;