RADetailMapCell.m 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 UITextView *valueLabel;
  15. @property (strong, nonatomic) IBOutlet UIButton *navigationBtn;
  16. @end
  17. @implementation RADetailMapCell
  18. - (void)awakeFromNib {
  19. [super awakeFromNib];
  20. // Initialization code
  21. self.valueLabel.textContainerInset = UIEdgeInsetsMake(0, -5, 0, -5);
  22. }
  23. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  24. [super setSelected:selected animated:animated];
  25. // Configure the view for the selected state
  26. }
  27. - (void)prepareForReuse {
  28. [super prepareForReuse];
  29. self.model = nil;
  30. }
  31. - (void)setModel:(RADetailMapModel *)model {
  32. _model = model;
  33. self.titleLabel.text = _model.title;
  34. self.valueLabel.text = _model.location;
  35. if (_model.highlight) {
  36. self.valueLabel.textColor = [UIColor redColor];
  37. } else{
  38. self.valueLabel.textColor = [UIColor blackColor];
  39. }
  40. NSString *lonStr = _model.lon;
  41. NSString *latStr = _model.lat;
  42. if (lonStr && lonStr.length > 0 && latStr && latStr.length > 0) {
  43. // double longitude = [lonStr doubleValue];
  44. // double latitude = [latStr doubleValue];
  45. //
  46. // CLLocationCoordinate2D c2d = CLLocationCoordinate2DMake(latitude, longitude);
  47. //
  48. // MKCoordinateSpan span = MKCoordinateSpanMake(180, 360);
  49. // // 创建一个区域结构体变量
  50. // MKCoordinateRegion region = MKCoordinateRegionMake(c2d, span);
  51. //
  52. // // 将大头针数据模型添加到MKMapView上管理
  53. // [self.mapView setRegion:region animated:YES];
  54. if ([lonStr isEqualToString:@"-999"] && [latStr isEqualToString:@"-999"]) {
  55. self.navigationBtn.enabled = NO;
  56. [self.navigationBtn setImage:[UIImage imageNamed:@"btn_map_no"] forState:UIControlStateNormal];
  57. } else {
  58. self.navigationBtn.enabled = YES;
  59. [self.navigationBtn setImage:[UIImage imageNamed:@"btn_map"] forState:UIControlStateNormal];
  60. }
  61. } else {
  62. self.navigationBtn.enabled = NO;
  63. [self.navigationBtn setImage:[UIImage imageNamed:@"btn_map_no"] forState:UIControlStateNormal];
  64. }
  65. if (model.detectTel) {
  66. self.valueLabel.dataDetectorTypes = UIDataDetectorTypePhoneNumber;
  67. } else {
  68. self.valueLabel.dataDetectorTypes = UIDataDetectorTypeNone;
  69. }
  70. }
  71. - (IBAction)navigationBtnClick:(UIButton *)sender {
  72. // MKMapItem *currentLocation = [MKMapItem mapItemForCurrentLocation];
  73. if (self.delegate && [self.delegate respondsToSelector:@selector(mapCell:clickMapButtonWithModel:)]) {
  74. [self.delegate mapCell:self clickMapButtonWithModel:self.model];
  75. }
  76. }
  77. @end