现在很多社交、电商、团购应用都引入了地图和定位功能,似乎地图功能不再是地图应用和导航应用所特有的。的确,有了地图和定位功能确实让我们的生活更加丰富多彩,极大的改变了我们的生活方式。例如你到了一个陌生的地方想要查找附近的酒店、超市等就可以打开软件搜索周边;类似的,还有很多团购软件可以根据你所在的位置自动为你推荐某些商品。总之,目前地图和定位功能已经大量引入到应用开发中。今天就和大家一起看一下iOS如何进行地图和定位开发。
#import "ViewController.h"
#import <MapKit/MapKit.h>
@interface ViewController ()<CLLocationManagerDelegate,MKMapViewDelegate>
{
MKMapView *mv;
CLLocationManager *locationManager;
UITextField *tfLatitude;
UITextField *tfLongitude;
CLGeocoder *geocoder;
CLLocationCoordinate2D coor;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
geocoder = [[CLGeocoder alloc] init];
//初始化CLLocationManager
locationManager=[[CLLocationManager alloc]init];
//代理
locationManager.d