扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
在太仓等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都网站建设、成都网站设计 网站设计制作按需设计网站,公司网站建设,企业网站建设,品牌网站制作,营销型网站,外贸网站建设,太仓网站建设费用合理。
#import#import #import @interface DXWViewController : UIViewController @property (retain, nonatomic) IBOutlet MKMapView *mapview; @property(retain,nonatomic)CLLocationManager *manager; @property(retain,nonatomic)CLLocation *location; @property (retain, nonatomic) IBOutletCollection(UILabel) NSArray *labels; @end
#import "DXWViewController.h" #import "Place.h" @interface DXWViewController () @end @implementation DXWViewController - (void)viewDidLoad { [super viewDidLoad]; self.manager = [[CLLocationManager alloc] init]; self.manager.delegate = self; //精度 self.manager.desiredAccuracy = kCLLocationAccuracyBest; [self.manager startUpdatingLocation]; self.mapview.showsUserLocation = YES; } -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { self.location = [locations objectAtIndex:0]; [self.labels[0] setText:[NSString stringWithFormat:@"%f\u00B0",self.location.coordinate.longitude]]; [self.labels[1] setText:[NSString stringWithFormat:@"%f\u00B0",self.location.coordinate.longitude]]; [self.labels[2] setText:[NSString stringWithFormat:@"%gm",self.location.horizontalAccuracy]]; [self.labels[3] setText:[NSString stringWithFormat:@"%gm",self.location.altitude]]; [self.labels[4] setText:[NSString stringWithFormat:@"%gm",self.location.verticalAccuracy]]; Place *place = [[Place alloc] init]; place.coordinate = self.location.coordinate; place.title = @"Title"; place.subtitle = @"subTitle"; [self.mapview addAnnotation:place]; //设置精度范围 MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(place.coordinate, 1000, 1000); [self.mapview setRegion:region animated:YES]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (void)dealloc { [_mapview release]; [_labels release]; [super dealloc]; } @end
#import#import @interface Place : NSObject @property(copy,nonatomic)NSString *title; @property(copy,nonatomic)NSString *subtitle; @property(assign,nonatomic)CLLocationCoordinate2D coordinate; @end
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流