|
|
@@ -25,7 +25,7 @@ typedef enum {
|
|
|
HomeModeKPI = 1
|
|
|
} HomeMode;
|
|
|
|
|
|
-@interface HomeViewController () <UITableViewDelegate,UITableViewDataSource,UISearchBarDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,KPIDelegate>
|
|
|
+@interface HomeViewController () <UITableViewDelegate,UITableViewDataSource,UISearchBarDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,KPIDelegate,MKMapViewDelegate,ShipCellDelegate>
|
|
|
|
|
|
@property (strong, nonatomic) IBOutlet UISegmentedControl *segmentControl;
|
|
|
|
|
|
@@ -75,6 +75,7 @@ typedef enum {
|
|
|
[self registNotification];
|
|
|
[self configureTableView];
|
|
|
self.shipSearchBar.delegate =self;
|
|
|
+ self.mapView.delegate = self;
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(logout) name:APLogoutNotification object:nil];
|
|
|
|
|
|
@@ -520,7 +521,7 @@ typedef enum {
|
|
|
NSString *port = [item objectForKey:@"port"];
|
|
|
NSInteger stage = [[item objectForKey:@"transport_stage"] integerValue];
|
|
|
|
|
|
- [[[[[[[cell setTitle:title] setDescription:desc] setDetail:detail] setPort:port] setTime:date] setIcon:icon] setTransportStage:stage];
|
|
|
+ [[[[[[[[cell setTitle:title] setDescription:desc] setDetail:detail] setPort:port] setTime:date] setIcon:icon] setTransportStage:stage] setDelegate:self];
|
|
|
|
|
|
return cell;
|
|
|
} else {
|
|
|
@@ -754,4 +755,130 @@ typedef enum {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+#pragma mark - Map
|
|
|
+
|
|
|
+- (NSDictionary *)fakeLoaction {
|
|
|
+ NSArray *arr = [ApexMobileDB get_Location];
|
|
|
+
|
|
|
+ NSMutableDictionary *returnDic = [NSMutableDictionary dictionary];
|
|
|
+
|
|
|
+ for (int i = 0; i < arr.count ; i ++) {
|
|
|
+
|
|
|
+ NSDictionary* location = arr[i];
|
|
|
+ NSString* area = [location valueForKey:@"area"];
|
|
|
+ NSString* company = [location valueForKey:@"company"];
|
|
|
+// NSString* city = [location valueForKey:@"city"];
|
|
|
+ NSString *longitude = [location valueForKey:@"longitude"];
|
|
|
+ NSString *latitude = [location valueForKey:@"latitude"];
|
|
|
+
|
|
|
+ NSDictionary *dic = @{
|
|
|
+ @"addr" : area,
|
|
|
+ @"name" : company,
|
|
|
+ @"lon" : longitude,
|
|
|
+ @"lat" : latitude
|
|
|
+ };
|
|
|
+ if (i == 0) {
|
|
|
+ [returnDic setObject:dic forKey:@"pol"];
|
|
|
+ } else if (i == 1) {
|
|
|
+ [returnDic setObject:dic forKey:@"pod"];
|
|
|
+ } else if (i == 2) {
|
|
|
+ [returnDic setObject:dic forKey:@"poe"];
|
|
|
+ } else if (i == 3) {
|
|
|
+ [returnDic setObject:dic forKey:@"por"];
|
|
|
+ } else if (i == 4) {
|
|
|
+ [returnDic setObject:dic forKey:@"origin"];
|
|
|
+ } else if (i == 5) {
|
|
|
+ [returnDic setObject:dic forKey:@"destination"];
|
|
|
+ } else if (i == 6) {
|
|
|
+ [returnDic setObject:dic forKey:@"current"];
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return returnDic;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)setSelectedIndexPath:(NSIndexPath *)indexPath {
|
|
|
+
|
|
|
+ [self.mapView removeAnnotations:self.mapView.annotations];
|
|
|
+
|
|
|
+ NSDictionary *item = [self.shipArray objectAtIndex:indexPath.section];
|
|
|
+ NSDictionary *locationInfo = [item objectForKey:@"locations"];
|
|
|
+
|
|
|
+ locationInfo = [self fakeLoaction];
|
|
|
+
|
|
|
+ // pol,pod,poe,por,origin,destination,current
|
|
|
+ if (locationInfo) {
|
|
|
+ NSDictionary *pol = [locationInfo objectForKey:@"pol"];
|
|
|
+ [self handleLoaction:pol];
|
|
|
+
|
|
|
+ NSDictionary *pod = [locationInfo objectForKey:@"pod"];
|
|
|
+ [self handleLoaction:pod];
|
|
|
+
|
|
|
+ NSDictionary *poe = [locationInfo objectForKey:@"poe"];
|
|
|
+ [self handleLoaction:poe];
|
|
|
+
|
|
|
+ NSDictionary *por = [locationInfo objectForKey:@"por"];
|
|
|
+ [self handleLoaction:por];
|
|
|
+
|
|
|
+ NSDictionary *origin = [locationInfo objectForKey:@"origin"];
|
|
|
+ [self handleLoaction:origin];
|
|
|
+
|
|
|
+ NSDictionary *destination = [locationInfo objectForKey:@"destination"];
|
|
|
+ [self handleLoaction:destination];
|
|
|
+
|
|
|
+ NSDictionary *current = [locationInfo objectForKey:@"current"];
|
|
|
+ [self handleLoaction:current];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (void)handleLoaction:(NSDictionary *)location {
|
|
|
+ if (location == nil) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ NSString* addr = [location valueForKey:@"addr"];
|
|
|
+ NSString* name = [location valueForKey:@"name"];
|
|
|
+ double longitude = [[location valueForKey:@"lon"] doubleValue];
|
|
|
+ double latitude = [[location valueForKey:@"lat"] doubleValue];
|
|
|
+
|
|
|
+ // 创建大头针(标注)的数据模型(此处不创建视图,视图通过MKMapView的委托设置回调方法来生成的)
|
|
|
+ MKPointAnnotation *ann = [[MKPointAnnotation alloc] init];
|
|
|
+ CLLocationCoordinate2D c2d = CLLocationCoordinate2DMake(latitude, longitude);
|
|
|
+ // 指定大头针的经纬度坐标(位置)以及附加的信息
|
|
|
+ ann.coordinate = c2d;
|
|
|
+ ann.title = name;
|
|
|
+ ann.subtitle = addr;
|
|
|
+
|
|
|
+ // 将大头针数据模型添加到MKMapView上管理
|
|
|
+ [self.mapView addAnnotation:ann];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark - Map Delegate
|
|
|
+
|
|
|
+// 当地图上添加了标注以后要执行的回调方法
|
|
|
+- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
|
|
|
+
|
|
|
+// // 获取可复用的大头针视图
|
|
|
+// MKAnnotationView *pinView = (id)[mapView dequeueReusableAnnotationViewWithIdentifier:@"PIN"];
|
|
|
+//
|
|
|
+// if (!pinView) { // 如果没有可重用的大头针视图就创建并指定重用标识
|
|
|
+// pinView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"PIN"];
|
|
|
+// }
|
|
|
+// pinView.image = [UIImage imageNamed:@"ic_marker"];
|
|
|
+
|
|
|
+ return nil;
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark - ShipCell Delegate
|
|
|
+
|
|
|
+- (void)shipCellDidTapIcon:(ShipingStatusCell *)cell {
|
|
|
+ NSIndexPath *indexPath = [self.shipTableView indexPathForCell:cell];
|
|
|
+ [self setSelectedIndexPath:indexPath];
|
|
|
+}
|
|
|
+
|
|
|
@end
|