You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
570 lines
22 KiB
570 lines
22 KiB
// |
|
// MapViewController.m |
|
// LekangGuard |
|
// |
|
// Created by ecell on 2022/9/27. |
|
// |
|
|
|
#import "MapViewController.h" |
|
#import "GDMapView.h" |
|
#import "GoogleMapView.h" |
|
#import "MarkExplainViewController.h" |
|
#import "ElectronicFenceViewController.h" |
|
#import "TrackViewController.h" |
|
#import "SLMarqueeControl.h" |
|
#import "MapBtnTableViewCell.h" |
|
|
|
|
|
@interface MapViewController () |
|
|
|
@property (nonatomic ,strong) UIView *topView; |
|
|
|
@property (nonatomic ,strong) UIView *bottomView; |
|
|
|
@property (nonatomic ,weak) UIButton *dianBtn; |
|
/// 设备名称 |
|
@property (nonatomic ,weak) UILabel *nameLabel; |
|
|
|
/// 电量Img |
|
@property (nonatomic ,weak) UIImageView *batteryImg; |
|
|
|
/// 电量Label |
|
@property (nonatomic ,weak) UILabel *batteryLabel; |
|
|
|
/// 状态Img |
|
@property (nonatomic ,weak) UIImageView *statusImg; |
|
|
|
/// 状态Label |
|
@property (nonatomic ,weak) UILabel *statusLabel; |
|
|
|
/// 连接时间Label |
|
@property (nonatomic ,weak) UILabel *lineTimeLabel; |
|
|
|
/// 定位图片 |
|
@property (nonatomic ,weak) UIImageView *mapImg; |
|
|
|
// 定位地址内容标题 |
|
@property (weak, nonatomic) SLMarqueeControl *marqueeControl; |
|
|
|
/// 位置 |
|
@property (nonatomic ,weak) UILabel *addLabel; |
|
|
|
/// 高德地图 |
|
@property (nonatomic ,strong) GDMapView *gdMapView; |
|
|
|
/// 谷歌地图 |
|
@property (nonatomic ,strong) GoogleMapView *googleMapView; |
|
|
|
/// 地图模式切换View |
|
@property (nonatomic ,strong) UIView *mapSwitchView; |
|
|
|
@property (nonatomic ,strong) CommonTableView *btnTableView; |
|
|
|
@property (nonatomic ,strong) NSMutableArray *cellTitleArr; |
|
@property (nonatomic ,strong) NSMutableArray *cellImageArr; |
|
|
|
@end |
|
|
|
@implementation MapViewController |
|
|
|
- (void)viewDidLoad { |
|
[super viewDidLoad]; |
|
// Do any additional setup after loading the view. |
|
self.view.backgroundColor = KKBackgroundGrey; |
|
[MAMapView updatePrivacyShow:AMapPrivacyShowStatusDidShow privacyInfo:AMapPrivacyInfoStatusDidContain]; |
|
[MAMapView updatePrivacyAgree:AMapPrivacyAgreeStatusDidAgree]; |
|
[AMapSearchAPI updatePrivacyShow:(AMapPrivacyShowStatusDidShow) privacyInfo:(AMapPrivacyInfoStatusDidContain)]; |
|
|
|
self.zx_navLeftBtn.titleLabel.font = FontBoldADA_(18); |
|
[self.zx_navLeftBtn setTitleColor:KKWhiteColorColor forState:0]; |
|
|
|
[self zx_setRightBtnWithImg:ImageName_(@"icon_switch_devices") clickedBlock:^(ZXNavItemBtn * _Nonnull btn) { |
|
[self isMapShowMenu]; |
|
}]; |
|
//[self.cellTitleArr addObject:@"学生证短信"]; |
|
[self.cellTitleArr addObject:@"定位模式"]; |
|
[self.cellTitleArr addObject:@"定位说明"]; |
|
//[self.cellTitleArr addObject:@"定位纠偏"]; |
|
// [self.cellImageArr addObject:@"icon_watch_sms"]; |
|
[self.cellImageArr addObject:@"icon_map_mode"]; |
|
[self.cellImageArr addObject:@"icon_explain"]; |
|
// [self.cellImageArr addObject:@"icon_correction"]; |
|
|
|
[self.view addSubview:self.gdMapView]; |
|
[self.view addSubview:self.topView]; |
|
[self.view addSubview:self.bottomView]; |
|
[self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.right.equalTo(self.view).inset(10); |
|
make.bottom.equalTo(self.view.mas_bottom).inset(10); |
|
make.height.mas_equalTo(136); |
|
}]; |
|
|
|
[self.view addSubview:self.btnTableView]; |
|
[self.view addSubview:self.mapSwitchView]; |
|
[self.mapSwitchView mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.right.equalTo(self.view.mas_right).inset(85); |
|
make.bottom.equalTo(self.bottomView.mas_top).inset(5); |
|
make.size.mas_equalTo(CGSizeMake(80, 90)); |
|
}]; |
|
|
|
|
|
|
|
[[[NSNotificationCenter defaultCenter] rac_addObserverForName:@"updateBatteryAndLocation" object:nil] subscribeNext:^(NSNotification *x){ |
|
[self UpdataLatestlocation:APIManager.sharedManager.deviceModel.imei]; |
|
}]; |
|
[[[NSNotificationCenter defaultCenter] rac_addObserverForName:@"deviceNowLocation" object:nil] subscribeNext:^(NSNotification *x) |
|
{ |
|
[self UpdataLatestlocation:APIManager.sharedManager.deviceModel.imei]; |
|
}]; |
|
|
|
|
|
} |
|
|
|
/// 点击切换设备 |
|
- (void)isMapShowMenu |
|
{ |
|
WeakSelf |
|
[DeviceSwitchover.sharedManager showMenuViewWithAdd:NO ]; |
|
[DeviceSwitchover.sharedManager setSwitchDevice:^(NSInteger index) { |
|
DeviceModel *model = APIManager.sharedManager.deviceList[index]; |
|
APIManager.sharedManager.deviceModel = model; |
|
[APIManager.sharedManager.cache setObject:model forKey:sDeviceKey]; |
|
[weakSelf UpdataLatestlocation:model.imei]; |
|
}]; |
|
} |
|
|
|
|
|
|
|
- (GDMapView *)gdMapView |
|
{ |
|
kWeakSelf(self) |
|
if (!_gdMapView) |
|
{ |
|
_gdMapView = [[GDMapView alloc] initWithFrame:CGRectMake(0, iPhoneX_NavHeight, SCREEN_WIDTH, SCREEN_HEIGHT-iPhoneX_NavHeight)]; |
|
_gdMapView.addAnalyzeSucceed = ^(NSString * _Nonnull addName) { |
|
weakself.marqueeControl.marqueeLabel.text = addName; |
|
}; |
|
} |
|
return _gdMapView; |
|
} |
|
|
|
- (GoogleMapView *)googleMapView |
|
{ |
|
if (!_googleMapView) |
|
{ |
|
_googleMapView = [[GoogleMapView alloc] initWithFrame:CGRectMake(0, self.topView.bottom, SCREEN_WIDTH, SCREEN_HEIGHT-self.topView.bottom)]; |
|
} |
|
return _googleMapView; |
|
} |
|
|
|
|
|
- (UIView *)topView |
|
{ |
|
if (!_topView) |
|
{ |
|
_topView = [UICommon ui_view:CGRectZero backgroundColor:KKWhiteColorColor cornerRadius:Adapted(12.5) borderWidth:0 borderColor:KKWhiteColorColor]; |
|
_topView.frame = CGRectMake(10, iPhoneX_NavHeight+6, SCREEN_WIDTH-20, Adapted(25)); |
|
|
|
UIImageView *locationTypeImageView = [UIImageView new]; |
|
self.mapImg = locationTypeImageView; |
|
[_topView addSubview:locationTypeImageView]; |
|
[locationTypeImageView mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.equalTo(_topView).offset(13); |
|
make.centerY.equalTo(_topView); |
|
make.size.mas_equalTo(CGSizeMake(15, 15)); |
|
}]; |
|
|
|
|
|
/// 位置跑马灯 |
|
SLMarqueeControl *control = [[SLMarqueeControl alloc] initWithFrame:CGRectMake(38, 5, SCREEN_WIDTH-20-38-15, 15)]; |
|
control.backgroundColor = KKClearColor; |
|
control.marqueeLabel.text = @"当前位置未知,请确保设备开机且能够联网,再点击定位按钮进行定位"; |
|
self.marqueeControl = control; |
|
[_topView addSubview:control]; |
|
} |
|
return _topView; |
|
} |
|
|
|
|
|
- (void)viewDidAppear:(BOOL)animated |
|
{ |
|
[super viewDidAppear:animated]; |
|
LatestLocationModel *model = APIManager.sharedManager.laloModel; |
|
[self UpdataMapViewLocation:model]; |
|
} |
|
|
|
|
|
#pragma mark 主动请求位置下发 |
|
/// 主动请求位置下发 |
|
- (void)GetLatest |
|
{ |
|
NSString *imei = APIManager.sharedManager.deviceModel.imei; |
|
[UICommon MessageUpload:@"定位中"]; |
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
|
[[[APIManager sharedManager] APGET:F(@"%@/%@", Latest_location_app_instructions_URL,imei) parameters:parameters resultClass:nil] subscribeNext:^(id _Nullable x) { |
|
|
|
|
|
NSLog(@"-->%@",x); |
|
} error:^(NSError * _Nullable error) { |
|
NSDictionary *dic = error.userInfo; |
|
[UICommon MessageErrorText:dic[NSLocalizedDescriptionKey]]; |
|
}]; |
|
} |
|
|
|
|
|
#pragma mark 获取设备最新位置信息(推送时使用) |
|
/// 获取设备最新位置信息(推送时使用) |
|
- (void)UpdataLatestlocation:(NSString *)imei |
|
{ |
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
|
[[[APIManager sharedManager] APGET:F(@"%@/%@", Latest_location_app_URL,imei) parameters:parameters resultClass:LatestLocationModel.class] subscribeNext:^(LatestLocationModel *model) { |
|
[UICommon HidenLoading]; |
|
[self UpdataMapViewLocation:model]; |
|
NSLog(@"-->%@",model); |
|
} error:^(NSError * _Nullable error) { |
|
NSDictionary *dic = error.userInfo; |
|
[UICommon MessageErrorText:dic[NSLocalizedDescriptionKey]]; |
|
}]; |
|
} |
|
|
|
|
|
- (void)UpdataMapViewLocation:(LatestLocationModel *)model |
|
{ |
|
self.gdMapView.laloModel = model; |
|
if(model) |
|
{ |
|
NSString *imgStr = [model.locationType isEqualToString:@"WIFI"] ? @"icon_wifi_positioning" : [model.locationType isEqualToString:@"GPS"] ? @"home_icon_gps" : @"icon_base_station"; |
|
self.mapImg.image = ImageName_(imgStr); |
|
self.marqueeControl.marqueeLabel.text = model.addr; |
|
self.marqueeControl.marqueeLabel.textColor = KKGrey133; |
|
} |
|
else |
|
{ |
|
self.mapImg.image = ImageName_(@"home_icon_gps_inaccurate"); |
|
self.marqueeControl.marqueeLabel.text = @"当前位置未知,请确保设备开机且能够联网,再点击定位按钮进行定位"; |
|
self.marqueeControl.marqueeLabel.textColor = RGB(249, 107, 87); |
|
} |
|
self.nameLabel.text = APIManager.sharedManager.deviceModel.name; |
|
[self.zx_navLeftBtn setTitle:APIManager.sharedManager.deviceModel.name forState:0]; |
|
self.statusImg.image = APIManager.sharedManager.laloModel.onlineStatus ? ImageName_(@"icon_device_connected") : ImageName_(@"icon_device_unconnected"); |
|
self.statusLabel.text = APIManager.sharedManager.laloModel.onlineStatus ? @"已连接" : @"未连接"; |
|
self.lineTimeLabel.text = APIManager.sharedManager.laloModel.updateTime; |
|
NSInteger battery = model.battery; |
|
NSString *imageName = @""; |
|
if(battery == 0) |
|
imageName = @"battery_0"; |
|
else if (battery < 10) |
|
imageName = @"battery_low"; |
|
else if (battery < 20) |
|
imageName = @"battery_1"; |
|
else if (battery < 30) |
|
imageName = @"battery_2"; |
|
else if (battery < 40) |
|
imageName = @"battery_3"; |
|
else if (battery < 50) |
|
imageName = @"battery_4"; |
|
else if (battery < 60) |
|
imageName = @"battery_4"; |
|
else if (battery < 70) |
|
imageName = @"battery_6"; |
|
else if (battery < 80) |
|
imageName = @"battery_7"; |
|
else if (battery < 90) |
|
imageName = @"battery_8"; |
|
else if (battery < 100) |
|
imageName = @"battery_9"; |
|
else |
|
imageName = @"battery_10"; |
|
|
|
self.batteryImg.image = ImageName_(imageName); |
|
self.batteryLabel.text = [NSString stringWithFormat:@"%ld%%",battery]; |
|
} |
|
|
|
|
|
- (UIView *)bottomView |
|
{ |
|
if (!_bottomView) |
|
{ |
|
_bottomView = [UICommon ui_view:CGRectZero backgroundColor:KKWhiteColorColor cornerRadius:10 borderWidth:0 borderColor:KKWhiteColorColor]; |
|
|
|
UILabel *nameLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:FontBoldADA_(14) textColor:KKTextBlackColor text:@"" Radius:0]; |
|
self.nameLabel = nameLabel; |
|
[_bottomView addSubview:nameLabel]; |
|
[nameLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.equalTo(_bottomView).offset(20); |
|
make.top.equalTo(_bottomView).offset(19); |
|
}]; |
|
|
|
/// 电量图片 |
|
UIImageView *batteryImg = [UIImageView new]; |
|
self.batteryImg = batteryImg; |
|
[_bottomView addSubview:batteryImg]; |
|
[batteryImg mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.equalTo(nameLabel.mas_left); |
|
make.top.equalTo(nameLabel.mas_bottom).offset(15); |
|
make.size.mas_equalTo(CGSizeMake(24.5, 10)); |
|
}]; |
|
|
|
/// 电量Label |
|
UILabel *batteryLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:Font_(12) textColor:KKTextBlackColor text:@"" Radius:0]; |
|
self.batteryLabel = batteryLabel; |
|
[_bottomView addSubview:batteryLabel]; |
|
[batteryLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.equalTo(batteryImg.mas_right).offset(8); |
|
make.centerY.equalTo(batteryImg.mas_centerY); |
|
}]; |
|
|
|
/// 状态图片 |
|
UIImageView *statusImg = [UIImageView new]; |
|
self.statusImg = statusImg; |
|
[_bottomView addSubview:statusImg]; |
|
[statusImg mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.equalTo(batteryLabel.mas_right).offset(25); |
|
make.centerY.equalTo(batteryImg.mas_centerY); |
|
make.size.mas_equalTo(CGSizeMake(15, 15)); |
|
}]; |
|
|
|
/// 状态 |
|
UILabel *statusLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:Font_(12) textColor:KKTextBlackColor text:@"" Radius:0]; |
|
self.statusLabel = statusLabel; |
|
[_bottomView addSubview:statusLabel]; |
|
[statusLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.equalTo(statusImg.mas_right).offset(8); |
|
make.centerY.equalTo(batteryImg.mas_centerY); |
|
}]; |
|
|
|
/// 更新时间Label |
|
UILabel *lineTimeLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:Font_(12) textColor:KKTextBlackColor text:@"" Radius:0]; |
|
self.lineTimeLabel = lineTimeLabel; |
|
[_bottomView addSubview:lineTimeLabel]; |
|
[lineTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.equalTo(statusLabel.mas_right).offset(20); |
|
make.centerY.equalTo(batteryImg.mas_centerY); |
|
}]; |
|
|
|
CGFloat ww = (SCREEN_WIDTH-40-20-100)/2; |
|
|
|
CGFloat wws = SCREEN_WIDTH-90-(ww*2); |
|
NSArray *titleArr = @[@"历史轨迹",@"电子围栏",@""]; |
|
NSArray *imageArr = @[@"icon_history",@"icon_fence",@"icon_more"]; |
|
|
|
for (int i = 0; i < titleArr.count; i++) |
|
{ |
|
UIButton *button = [UICommon ui_buttonSimple:CGRectZero font:FontBoldADA_(12) normalColor:KKTextBlackColor normalText:titleArr[i] click:^(UIButton *btn) { |
|
if (btn.tag == 0) |
|
{ |
|
TrackViewController *vc = [TrackViewController new]; |
|
[self.navigationController pushViewController:vc animated:YES]; |
|
// if (!self.btnTableView.hidden) |
|
// { |
|
// [self dismiss]; |
|
// self.dianBtn.selected = NO; |
|
// } |
|
} |
|
else if (btn.tag == 1) |
|
{ |
|
ElectronicFenceViewController *vc = [ElectronicFenceViewController new]; |
|
[self.navigationController pushViewController:vc animated:YES]; |
|
// if (!self.btnTableView.hidden) |
|
// { |
|
// [self dismiss]; |
|
// self.dianBtn.selected = NO; |
|
// } |
|
} |
|
else |
|
{ |
|
self.dianBtn.selected = !self.dianBtn.selected; |
|
if (self.dianBtn.selected) |
|
[self showView]; |
|
else |
|
[self dismiss]; |
|
} |
|
|
|
}]; |
|
button.tag = i; |
|
button.layer.cornerRadius = 5; |
|
button.layer.masksToBounds = YES; |
|
button.backgroundColor = RGB(232, 245, 255); |
|
[button setImage:ImageName_(imageArr[i]) forState:0]; |
|
if (i == titleArr.count-1) |
|
self.dianBtn = button; |
|
[_bottomView addSubview:button]; |
|
[button mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.equalTo(_bottomView).offset(20+i*ww+15*i); |
|
make.bottom.equalTo(_bottomView.mas_bottom).inset(20); |
|
make.size.mas_equalTo(CGSizeMake(i == 2 ? wws : ww, 35)); |
|
}]; |
|
} |
|
|
|
/// 定位 |
|
UIButton *button = [UICommon ui_buttonSimple:CGRectZero font:FontBoldADA_(12) normalColor:KKTextBlackColor normalText:@"" click:^(UIButton *btn) { |
|
|
|
[self GetLatest]; |
|
}]; |
|
[button setImage:ImageName_(@"map_button_gps") forState:0]; |
|
[_bottomView addSubview:button]; |
|
[button mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.right.equalTo(_bottomView.mas_right).inset(20); |
|
make.top.equalTo(_bottomView).offset(15); |
|
make.size.mas_equalTo(CGSizeMake(40, 40)); |
|
}]; |
|
|
|
} |
|
return _bottomView; |
|
} |
|
|
|
|
|
|
|
- (CommonTableView *)btnTableView |
|
{ |
|
if (!_btnTableView) |
|
{ |
|
_btnTableView = [[CommonTableView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-30-50, SCREEN_HEIGHT-TabBarHeight-95, 50, 0.000001) style:UITableViewStylePlain cellHeight:71 cellRow:self.cellTitleArr.count isAdaptive:NO isLine:YES commonCell:MapBtnTableViewCell.class createCell:^(ZZTableViewCell * _Nonnull cells, NSIndexPath * _Nonnull indexPath) { |
|
MapBtnTableViewCell *cell = (MapBtnTableViewCell *)cells; |
|
cell.imageName = self.cellImageArr[indexPath.row]; |
|
cell.titleName = self.cellTitleArr[indexPath.row]; |
|
|
|
} selectedCell:^(UITableView * _Nonnull tableView, NSIndexPath * _Nonnull indexPath) { |
|
NSString *title = self.cellTitleArr[indexPath.row]; |
|
if ([title isEqualToString:@"标准模式"] || [title isEqualToString:@"卫星模式"] || [title isEqualToString:@"3D模式"] || [title isEqualToString:@"定位模式"]) |
|
{ |
|
BOOL ish = self.mapSwitchView.hidden; |
|
self.mapSwitchView.hidden = !ish; |
|
} |
|
else if ([title isEqualToString:@"定位说明"]) |
|
{ |
|
/// 定位说明 |
|
MarkExplainViewController *vc = [MarkExplainViewController new]; |
|
[self.navigationController pushViewController:vc animated:YES]; |
|
// [self dismiss]; |
|
// self.dianBtn.selected = NO; |
|
} |
|
else if ([title isEqualToString:@"位置纠偏"]) |
|
{ |
|
// MapReviseViewController *vc = [[MapReviseViewController alloc] init]; |
|
// [self.navigationController pushViewController:vc animated:YES]; |
|
} |
|
// |
|
|
|
} DidscrollView:^(UIScrollView * _Nonnull scrollView) {}]; |
|
_btnTableView.layer.cornerRadius = 10; |
|
_btnTableView.layer.masksToBounds = YES; |
|
_btnTableView.hidden = YES; |
|
[UICommon setTavleViewlink:_btnTableView distance:0]; |
|
[UICommon setExtraCellLineHidden:_btnTableView]; |
|
|
|
} |
|
return _btnTableView; |
|
} |
|
|
|
- (void)showView |
|
{ |
|
self.btnTableView.hidden = NO; |
|
self.btnTableView.size = CGSizeMake(50, self.cellTitleArr.count*71); |
|
[UIView animateWithDuration:0.25f |
|
delay:0.0f |
|
options:UIViewAnimationOptionCurveEaseOut |
|
animations:^{ |
|
CGRect frame = self.btnTableView.frame; |
|
frame.origin.y = frame.origin.y - frame.size.height-10; |
|
self.btnTableView.frame = frame; |
|
}completion:^(BOOL finished) { |
|
self.btnTableView.conrnerRadius(10).shadowColor(KKMainColor).shadowOffset(CGSizeMake(3, 3)).shadowRadius(5).shadowOpacity(0.1).showVisual(); |
|
}]; |
|
} |
|
|
|
- (void)dismiss |
|
{ |
|
self.btnTableView.conrnerRadius(10).shadowColor(KKClearColor).shadowOffset(CGSizeMake(3, 3)).shadowRadius(5).shadowOpacity(0.1).showVisual(); |
|
self.btnTableView.clerVisual(); |
|
self.mapSwitchView.hidden = YES; |
|
[UIView animateWithDuration:0.25f |
|
delay:0.0f |
|
options:UIViewAnimationOptionCurveEaseIn |
|
animations:^{ |
|
CGRect frame = self.btnTableView.frame; |
|
frame.origin.y = frame.origin.y + frame.size.height+10; |
|
self.btnTableView.frame = frame; |
|
}completion:^(BOOL finished) { |
|
self.btnTableView.hidden = YES; |
|
}]; |
|
} |
|
|
|
- (UIView *)mapSwitchView |
|
{ |
|
if (!_mapSwitchView) |
|
{ |
|
NSArray *arr = @[@"标准模式",@"卫星模式"]; |
|
_mapSwitchView = [UICommon ui_view:CGRectZero backgroundColor:KKWhiteColorColor cornerRadius:10 borderWidth:0 borderColor:KKClearColor]; |
|
_mapSwitchView.hidden = YES; |
|
for (int i = 0; i < arr.count; i++) |
|
{ |
|
UIButton *btn = [UICommon ui_buttonSimple:CGRectZero font:Font_(14) normalColor:KKTextBlackColor normalText:arr[i] click:^(UIButton *button) { |
|
self.mapSwitchView.hidden = YES; |
|
[self dismiss]; |
|
self.dianBtn.selected = NO; |
|
[self.cellTitleArr replaceObjectAtIndex:0 withObject:button.currentTitle]; |
|
[self.btnTableView reloadData]; |
|
if([button.currentTitle isEqualToString:@"标准模式"]) |
|
self.gdMapView.mapView.mapType = MKMapTypeStandard; |
|
else if([button.currentTitle isEqualToString:@"卫星模式"]) |
|
self.gdMapView.mapView.mapType = MKMapTypeSatellite; |
|
else |
|
{ |
|
|
|
} |
|
|
|
}]; |
|
[_mapSwitchView addSubview:btn]; |
|
[btn mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.right.equalTo(_mapSwitchView); |
|
make.top.equalTo(_mapSwitchView).offset(i*45); |
|
make.height.mas_equalTo(45); |
|
}]; |
|
if (i < arr.count-1) |
|
{ |
|
UILabel *line = [UILabel new]; |
|
line.backgroundColor = RGB(235, 235, 235); |
|
[_mapSwitchView addSubview:line]; |
|
[line mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.right.equalTo(_mapSwitchView); |
|
make.bottom.equalTo(btn.mas_bottom); |
|
make.height.mas_equalTo(0.5); |
|
}]; |
|
} |
|
} |
|
} |
|
return _mapSwitchView; |
|
} |
|
|
|
- (void)viewWillDisappear:(BOOL)animated { |
|
[super viewWillDisappear:animated]; |
|
if (!self.btnTableView.hidden) |
|
{ |
|
[self dismiss]; |
|
self.dianBtn.selected = NO; |
|
} |
|
} |
|
|
|
- (NSMutableArray *)cellTitleArr |
|
{ |
|
if (!_cellTitleArr) _cellTitleArr = [NSMutableArray new]; |
|
return _cellTitleArr; |
|
} |
|
|
|
- (NSMutableArray *)cellImageArr |
|
{ |
|
if (!_cellImageArr) _cellImageArr = [NSMutableArray new]; |
|
return _cellImageArr; |
|
} |
|
/* |
|
#pragma mark - Navigation |
|
|
|
// In a storyboard-based application, you will often want to do a little preparation before navigation |
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { |
|
// Get the new view controller using [segue destinationViewController]. |
|
// Pass the selected object to the new view controller. |
|
} |
|
*/ |
|
|
|
@end
|
|
|