RADetailMapCell.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // RADetailMapCell.m
  3. // Apex And Drivers
  4. //
  5. // Created by Jack on 2018/9/4.
  6. // Copyright © 2018年 USAI. All rights reserved.
  7. //
  8. #import "RADetailMapCell.h"
  9. #import <MapKit/MapKit.h>
  10. #import "RADetailMapModel.h"
  11. @interface RADetailMapCell ()
  12. @property (strong, nonatomic) IBOutlet UILabel *titleLabel;
  13. @property (strong, nonatomic) IBOutlet MKMapView *mapView;
  14. @property (strong, nonatomic) IBOutlet UILabel *valueLabel;
  15. @end
  16. @implementation RADetailMapCell
  17. - (void)awakeFromNib {
  18. [super awakeFromNib];
  19. // Initialization code
  20. }
  21. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  22. [super setSelected:selected animated:animated];
  23. // Configure the view for the selected state
  24. }
  25. - (void)prepareForReuse {
  26. [super prepareForReuse];
  27. self.model = nil;
  28. }
  29. - (void)setModel:(RADetailMapModel *)model {
  30. _model = model;
  31. self.titleLabel.text = _model.title;
  32. self.valueLabel.text = _model.location;
  33. NSString *lonStr = _model.lon;
  34. NSString *latStr = _model.lat;
  35. if (lonStr && lonStr.length > 0 && latStr && latStr.length > 0) {
  36. double longitude = [lonStr doubleValue];
  37. double latitude = [latStr doubleValue];
  38. CLLocationCoordinate2D c2d = CLLocationCoordinate2DMake(latitude, longitude);
  39. MKCoordinateSpan span = MKCoordinateSpanMake(180, 360);
  40. // 创建一个区域结构体变量
  41. MKCoordinateRegion region = MKCoordinateRegionMake(c2d, span);
  42. // 将大头针数据模型添加到MKMapView上管理
  43. [self.mapView setRegion:region animated:YES];
  44. }
  45. }
  46. @end