苹果地图使用之MKMapView定位显示
来源:互联网 发布:hbase java api 编辑:程序博客网 时间:2024/04/29 19:02
#import <MapKit/MapKit.h>#define kScreenWidht [UIScreen mainScreen].bounds.size.width#define kScreenHeight [UIScreen mainScreen].bounds.size.height@interface ViewController () <MKMapViewDelegate>@property (nonatomic, strong) MKMapView *mapView;@property (nonatomic, strong) CLLocationManager *locationManager;@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; _mapView = [[MKMapView alloc] initWithFrame:self.view.bounds]; _mapView.delegate = self; [_mapView setUserTrackingMode:MKUserTrackingModeFollow]; [self.view addSubview:_mapView]; _locationManager = [[CLLocationManager alloc] init]; [_locationManager requestAlwaysAuthorization]; CLLocationCoordinate2D coordinate = {30.26667, 120.20000}; [_mapView setCenterCoordinate:coordinate animated:YES]; // 定位按钮 UIButton *resetLocationBtn = [[UIButton alloc] initWithFrame:CGRectMake(10, kScreenHeight - 45, 30, 35)]; [resetLocationBtn setBackgroundImage:[UIImage imageNamed:@"location.jpg"] forState:UIControlStateNormal]; [resetLocationBtn addTarget:self action:@selector(resetLocation:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:resetLocationBtn];}#pragma mark - MKMapViewDelegate- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation{ // 位置发生变化调用 NSLog(@"lan = %f, long = %f", userLocation.coordinate.latitude, userLocation.coordinate.longitude);}- (void)resetLocation:(id)sender { // 定位到我的位置 [_mapView setCenterCoordinate:_mapView.userLocation.coordinate animated:YES];}@end
0 0
- 苹果地图使用之MKMapView定位显示
- 苹果地图使用之定位
- CLLocationManager定位经纬度,MKReverseGeocoder地址解析, MKMapView 地图显示 iphone
- CLLocationManager定位经纬度,MKReverseGeocoder地址解析, MKMapView 地图显示 iphone
- ios-MKMapView苹果地图开发
- iOS 苹果地图 MKMapView总结
- IOS 地图定位,标记位置,获取经纬度,MKMapView的使用
- IOS 地图定位,标记位置,获取经纬度,MKMapView的使用
- IOS 地图定位,标记位置,获取经纬度,MKMapView的使用
- IOS 地图定位,标记位置,获取经纬度,MKMapView的使用
- IOS 地图定位,标记位置,获取经纬度,MKMapView的使用
- MKMapView显示位置的地图
- 使用苹果的地图与定位
- swift地图定位(十八)发送网络请求给苹果服务器获取导航路线并解析和绘制到MKMapView
- 浏览器定位之 - 百度定位地图显示
- 利用MKMapView显示自己当前位置的地图
- 百度地图之---定位实现 并显示定位结果地图
- iOS开发 地图:MKMapView控件的使用
- Android第八课;CheckBox
- C# USB通信(调用Windows API)
- 使用pymssql进行中文操作时候可能会出现中文乱码
- 有关java中对象序列化与反序列化的乱码问题
- 12-Oracle入门之集合运算
- 苹果地图使用之MKMapView定位显示
- poj 2947 Widget Factory (高斯消元)
- 大话数据机构读书笔记(一)-基本概念
- ubuntu下caffe的FCN8模型训练
- 基于zookeeper+leveldb搭建activemq集群【转】
- 习题六
- Spark Streaming如何使用checkpoint容错
- JAVA源码分析-HashMap源码分析(二)
- C语言基本数据类型