Explorar el Código

2.修改iOS Apex Mobile Detail增加地图。

Pen Li hace 8 años
padre
commit
32ee1aa32f

+ 5 - 5
Apex Mobile/Apex Mobile/AMAnnotationView.m

@@ -12,7 +12,7 @@
 @interface AMAnnotationView ()
 @interface AMAnnotationView ()
 
 
 @property (strong,nonatomic) UIControl *calloutView;
 @property (strong,nonatomic) UIControl *calloutView;
-@property (strong,nonatomic) AMMapAnnotaion *myAnnotation;
+//@property (strong,nonatomic) AMMapAnnotaion *myAnnotation;
 @property (nonatomic,strong) UILabel *titleLabel;
 @property (nonatomic,strong) UILabel *titleLabel;
 @property (nonatomic,strong) UILabel *detailLabel;
 @property (nonatomic,strong) UILabel *detailLabel;
 @property (nonatomic,assign) BOOL tapedCallout;
 @property (nonatomic,assign) BOOL tapedCallout;
@@ -28,7 +28,7 @@
         self.opaque = NO;
         self.opaque = NO;
         self.canShowCallout = NO;
         self.canShowCallout = NO;
 
 
-        self.myAnnotation = (AMMapAnnotaion *)annotation;
+//        self.myAnnotation = (AMMapAnnotaion *)annotation;
         self.calloutView = [[UIControl alloc] init];
         self.calloutView = [[UIControl alloc] init];
         self.calloutView.backgroundColor = [UIColor colorWithWhite:1 alpha:0.9];
         self.calloutView.backgroundColor = [UIColor colorWithWhite:1 alpha:0.9];
         [self.calloutView addTarget:self action:@selector(calloutDidClicked:) forControlEvents:UIControlEventTouchUpInside];
         [self.calloutView addTarget:self action:@selector(calloutDidClicked:) forControlEvents:UIControlEventTouchUpInside];
@@ -96,7 +96,7 @@
 
 
 - (void)calloutDidClicked:(id)sender {
 - (void)calloutDidClicked:(id)sender {
     if (self.delegate && [self.delegate respondsToSelector:@selector(mapView:didTapAnnotaionCallout:)]) {
     if (self.delegate && [self.delegate respondsToSelector:@selector(mapView:didTapAnnotaionCallout:)]) {
-        [self.delegate mapView:[self findMap:self] didTapAnnotaionCallout:self.myAnnotation];
+        [self.delegate mapView:[self findMap:self] didTapAnnotaionCallout:self.annotation];
     }
     }
 }
 }
 
 
@@ -108,8 +108,8 @@
     UIView *calloutView = self.calloutView;
     UIView *calloutView = self.calloutView;
     if (selected) {
     if (selected) {
 
 
-        NSString *title = self.myAnnotation.title;
-        NSString *detail = self.myAnnotation.subtitle;
+        NSString *title = self.annotation.title;
+        NSString *detail = self.annotation.subtitle;
 
 
         CGFloat maxWidth = [UIScreen mainScreen].bounds.size.width * 0.8f;
         CGFloat maxWidth = [UIScreen mainScreen].bounds.size.width * 0.8f;
 
 

+ 4 - 0
Apex Mobile/Apex Mobile/DetailPageViewController.m

@@ -7,6 +7,8 @@
 //
 //
 
 
 #import "DetailPageViewController.h"
 #import "DetailPageViewController.h"
+#import "AMShipMap.h"
+
 #define  DEF_CELL_HEIGHT 44
 #define  DEF_CELL_HEIGHT 44
 #define  DEF_TABLE_HEIGHT 44
 #define  DEF_TABLE_HEIGHT 44
 #define  LINE_WIDTH 0
 #define  LINE_WIDTH 0
@@ -111,6 +113,8 @@
 @property (nonatomic,copy) NSString *email_subject;
 @property (nonatomic,copy) NSString *email_subject;
 @property (nonatomic,copy) NSString *email_content;
 @property (nonatomic,copy) NSString *email_content;
 
 
+@property (nonatomic,strong) IBOutlet AMShipMap *shipMap;
+
 @end
 @end
 
 
 @implementation DetailPageViewController
 @implementation DetailPageViewController

+ 16 - 71
Apex Mobile/Apex Mobile/HomeViewController.m

@@ -15,7 +15,7 @@
 #import "KPICell.h"
 #import "KPICell.h"
 #import "KPITableCell.h"
 #import "KPITableCell.h"
 #import "AMResultViewController.h"
 #import "AMResultViewController.h"
-#import <MapKit/MapKit.h>
+#import "AMShipMap.h"
 
 
 #define SHIP_CELL_IDENTIFIER @"ShippingStatusCell"
 #define SHIP_CELL_IDENTIFIER @"ShippingStatusCell"
 #define KPI_CELL_IDENTIFIER @"KPITableCell"
 #define KPI_CELL_IDENTIFIER @"KPITableCell"
@@ -25,7 +25,7 @@ typedef enum {
     HomeModeKPI = 1
     HomeModeKPI = 1
 } HomeMode;
 } HomeMode;
 
 
-@interface HomeViewController () <UITableViewDelegate,UITableViewDataSource,UISearchBarDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,KPIDelegate,MKMapViewDelegate,ShipCellDelegate>
+@interface HomeViewController () <UITableViewDelegate,UITableViewDataSource,UISearchBarDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,KPIDelegate,ShipCellDelegate>
 
 
 @property (strong, nonatomic) IBOutlet UISegmentedControl *segmentControl;
 @property (strong, nonatomic) IBOutlet UISegmentedControl *segmentControl;
 
 
@@ -53,7 +53,7 @@ typedef enum {
 @property (nonatomic,assign) BOOL recentRefresh;
 @property (nonatomic,assign) BOOL recentRefresh;
 @property (nonatomic,assign) BOOL kpiRefresh;
 @property (nonatomic,assign) BOOL kpiRefresh;
 
 
-@property (nonatomic,strong) IBOutlet MKMapView *mapView;
+@property (nonatomic,strong) IBOutlet AMShipMap *mapView;
 @property (nonatomic,strong) NSIndexPath *iconSelectedIndexPath;
 @property (nonatomic,strong) NSIndexPath *iconSelectedIndexPath;
 
 
 @end
 @end
@@ -77,9 +77,7 @@ typedef enum {
     [self configureTableView];
     [self configureTableView];
     self.shipSearchBar.delegate =self;
     self.shipSearchBar.delegate =self;
     
     
-    self.mapView.showsScale = YES;
-    self.mapView.rotateEnabled = NO;
-    self.mapView.delegate = self;
+    [self configureMap];
     
     
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(logout) name:APLogoutNotification object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(logout) name:APLogoutNotification object:nil];
     
     
@@ -135,6 +133,17 @@ typedef enum {
     self.tabBarController.navigationItem.rightBarButtonItems = nil;
     self.tabBarController.navigationItem.rightBarButtonItems = nil;
 }
 }
 
 
+- (void)configureMap {
+    
+    self.mapView.showCurrent = YES;
+    self.mapView.showPoe = YES;
+    self.mapView.showPol = YES;
+    self.mapView.showPod = YES;
+    self.mapView.showPor = YES;
+    self.mapView.showOrigin = YES;
+    self.mapView.showDestination = YES;
+}
+
 - (void)configureNavigationBar {
 - (void)configureNavigationBar {
     
     
     if (self.navigationController && !self.navigationController.isNavigationBarHidden) {
     if (self.navigationController && !self.navigationController.isNavigationBarHidden) {
@@ -826,76 +835,12 @@ typedef enum {
     [self.shipTableView selectRowAtIndexPath:self.iconSelectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
     [self.shipTableView selectRowAtIndexPath:self.iconSelectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
     [cell setIconSelect:YES];
     [cell setIconSelect:YES];
     
     
-    [self.mapView removeAnnotations:self.mapView.annotations];
-    
     NSDictionary *item = [self.shipArray objectAtIndex:indexPath.section];
     NSDictionary *item = [self.shipArray objectAtIndex:indexPath.section];
     NSDictionary *locationInfo = [item objectForKey:@"locations"];
     NSDictionary *locationInfo = [item objectForKey:@"locations"];
-    
     locationInfo = [self fakeLoaction];
     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"];
+    [self.mapView showShipAnnotaion:locationInfo];
     
     
-    return nil;
 }
 }
 
 
 #pragma mark - ShipCell Delegate
 #pragma mark - ShipCell Delegate

+ 23 - 13
Apex Mobile/Apex Mobile/Main.storyboard

@@ -343,11 +343,12 @@
                             <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="TYb-wc-Nwg">
                             <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="TYb-wc-Nwg">
                                 <rect key="frame" x="0.0" y="104" width="375" height="514"/>
                                 <rect key="frame" x="0.0" y="104" width="375" height="514"/>
                                 <subviews>
                                 <subviews>
-                                    <mapView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" mapType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="NXU-e4-wFa">
-                                        <rect key="frame" x="5" y="2" width="365" height="170.5"/>
-                                    </mapView>
+                                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="3XI-3N-fFl" customClass="AMShipMap">
+                                        <rect key="frame" x="5" y="2" width="365" height="170"/>
+                                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                    </view>
                                     <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="iIl-j9-7oa">
                                     <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="iIl-j9-7oa">
-                                        <rect key="frame" x="0.0" y="174.5" width="375" height="339.5"/>
+                                        <rect key="frame" x="0.0" y="174" width="375" height="340"/>
                                         <color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
                                         <color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
                                         <inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
                                         <inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
                                         <connections>
                                         <connections>
@@ -385,19 +386,19 @@
                                         </constraints>
                                         </constraints>
                                     </activityIndicatorView>
                                     </activityIndicatorView>
                                 </subviews>
                                 </subviews>
-                                <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                <color key="backgroundColor" red="0.94709358808290156" green="0.94709358808290156" blue="0.94709358808290156" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                 <constraints>
                                 <constraints>
+                                    <constraint firstItem="3XI-3N-fFl" firstAttribute="height" secondItem="iIl-j9-7oa" secondAttribute="height" multiplier="1:2" id="0GT-rR-dp3"/>
+                                    <constraint firstItem="3XI-3N-fFl" firstAttribute="leading" secondItem="TYb-wc-Nwg" secondAttribute="leading" constant="5" id="1iS-rP-Kd6"/>
+                                    <constraint firstItem="3XI-3N-fFl" firstAttribute="top" secondItem="TYb-wc-Nwg" secondAttribute="top" constant="2" id="386-pN-3RJ"/>
                                     <constraint firstItem="iIl-j9-7oa" firstAttribute="width" secondItem="TYb-wc-Nwg" secondAttribute="width" id="3bU-Ll-nT0"/>
                                     <constraint firstItem="iIl-j9-7oa" firstAttribute="width" secondItem="TYb-wc-Nwg" secondAttribute="width" id="3bU-Ll-nT0"/>
                                     <constraint firstAttribute="bottom" secondItem="iIl-j9-7oa" secondAttribute="bottom" id="4yV-a1-feP"/>
                                     <constraint firstAttribute="bottom" secondItem="iIl-j9-7oa" secondAttribute="bottom" id="4yV-a1-feP"/>
                                     <constraint firstItem="0Al-V9-YKc" firstAttribute="centerX" secondItem="TYb-wc-Nwg" secondAttribute="centerX" id="8a8-fw-f0B"/>
                                     <constraint firstItem="0Al-V9-YKc" firstAttribute="centerX" secondItem="TYb-wc-Nwg" secondAttribute="centerX" id="8a8-fw-f0B"/>
-                                    <constraint firstItem="NXU-e4-wFa" firstAttribute="top" secondItem="TYb-wc-Nwg" secondAttribute="top" constant="2" id="DQD-M7-57a"/>
+                                    <constraint firstItem="iIl-j9-7oa" firstAttribute="top" secondItem="3XI-3N-fFl" secondAttribute="bottom" constant="2" id="DIE-VF-8bw"/>
                                     <constraint firstItem="iIl-j9-7oa" firstAttribute="centerX" secondItem="TYb-wc-Nwg" secondAttribute="centerX" id="Jd3-gv-peg"/>
                                     <constraint firstItem="iIl-j9-7oa" firstAttribute="centerX" secondItem="TYb-wc-Nwg" secondAttribute="centerX" id="Jd3-gv-peg"/>
-                                    <constraint firstItem="NXU-e4-wFa" firstAttribute="leading" secondItem="TYb-wc-Nwg" secondAttribute="leading" constant="5" id="MUJ-8S-eA6"/>
-                                    <constraint firstItem="NXU-e4-wFa" firstAttribute="height" secondItem="iIl-j9-7oa" secondAttribute="height" multiplier="1:2" id="Ont-ff-Yo7"/>
                                     <constraint firstItem="IFp-NK-v1o" firstAttribute="centerY" secondItem="TYb-wc-Nwg" secondAttribute="centerY" id="Q19-iJ-g2O"/>
                                     <constraint firstItem="IFp-NK-v1o" firstAttribute="centerY" secondItem="TYb-wc-Nwg" secondAttribute="centerY" id="Q19-iJ-g2O"/>
-                                    <constraint firstAttribute="trailing" secondItem="NXU-e4-wFa" secondAttribute="trailing" constant="5" id="XQd-lR-G3j"/>
+                                    <constraint firstAttribute="trailing" secondItem="3XI-3N-fFl" secondAttribute="trailing" constant="5" id="TUN-EY-Ybw"/>
                                     <constraint firstItem="0Al-V9-YKc" firstAttribute="centerY" secondItem="TYb-wc-Nwg" secondAttribute="centerY" id="fYu-3V-T4O"/>
                                     <constraint firstItem="0Al-V9-YKc" firstAttribute="centerY" secondItem="TYb-wc-Nwg" secondAttribute="centerY" id="fYu-3V-T4O"/>
-                                    <constraint firstItem="iIl-j9-7oa" firstAttribute="top" secondItem="NXU-e4-wFa" secondAttribute="bottom" constant="2" id="kfT-Li-zDm"/>
                                     <constraint firstItem="IFp-NK-v1o" firstAttribute="centerX" secondItem="TYb-wc-Nwg" secondAttribute="centerX" id="lcn-AL-YXN"/>
                                     <constraint firstItem="IFp-NK-v1o" firstAttribute="centerX" secondItem="TYb-wc-Nwg" secondAttribute="centerX" id="lcn-AL-YXN"/>
                                 </constraints>
                                 </constraints>
                             </view>
                             </view>
@@ -450,7 +451,7 @@
                         <outlet property="ShipContainer" destination="TYb-wc-Nwg" id="zGZ-eO-IiP"/>
                         <outlet property="ShipContainer" destination="TYb-wc-Nwg" id="zGZ-eO-IiP"/>
                         <outlet property="ShipLoading" destination="IFp-NK-v1o" id="2qd-dX-YqA"/>
                         <outlet property="ShipLoading" destination="IFp-NK-v1o" id="2qd-dX-YqA"/>
                         <outlet property="ShipNoDataBtn" destination="0Al-V9-YKc" id="1ZI-ki-vjV"/>
                         <outlet property="ShipNoDataBtn" destination="0Al-V9-YKc" id="1ZI-ki-vjV"/>
-                        <outlet property="mapView" destination="NXU-e4-wFa" id="n0h-vl-XSa"/>
+                        <outlet property="mapView" destination="3XI-3N-fFl" id="xxJ-xk-dWB"/>
                         <outlet property="segmentControl" destination="6ie-Rf-Nau" id="q6N-98-j6F"/>
                         <outlet property="segmentControl" destination="6ie-Rf-Nau" id="q6N-98-j6F"/>
                         <outlet property="shipTableView" destination="iIl-j9-7oa" id="vsk-WU-ScI"/>
                         <outlet property="shipTableView" destination="iIl-j9-7oa" id="vsk-WU-ScI"/>
                     </connections>
                     </connections>
@@ -1704,6 +1705,10 @@
                         <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                         <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                         <subviews>
                         <subviews>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="9wT-8n-8NB" customClass="AMShipMap">
+                                <rect key="frame" x="0.0" y="20" width="375" height="215"/>
+                                <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                            </view>
                             <activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" animating="YES" style="whiteLarge" translatesAutoresizingMaskIntoConstraints="NO" id="Cs2-5V-Ius">
                             <activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" animating="YES" style="whiteLarge" translatesAutoresizingMaskIntoConstraints="NO" id="Cs2-5V-Ius">
                                 <rect key="frame" x="169" y="315" width="37" height="37"/>
                                 <rect key="frame" x="169" y="315" width="37" height="37"/>
                                 <inset key="insetFor6xAndEarlier" minX="0.0" minY="64" maxX="0.0" maxY="-64"/>
                                 <inset key="insetFor6xAndEarlier" minX="0.0" minY="64" maxX="0.0" maxY="-64"/>
@@ -1718,7 +1723,7 @@
                                 <nil key="highlightedColor"/>
                                 <nil key="highlightedColor"/>
                             </label>
                             </label>
                             <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" allowsSelection="NO" rowHeight="-1" sectionHeaderHeight="-1" sectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="mia-XC-A8d">
                             <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" allowsSelection="NO" rowHeight="-1" sectionHeaderHeight="-1" sectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="mia-XC-A8d">
-                                <rect key="frame" x="0.0" y="20" width="375" height="647"/>
+                                <rect key="frame" x="0.0" y="237" width="375" height="430"/>
                                 <color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
                                 <color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
                                 <inset key="insetFor6xAndEarlier" minX="0.0" minY="64" maxX="0.0" maxY="44"/>
                                 <inset key="insetFor6xAndEarlier" minX="0.0" minY="64" maxX="0.0" maxY="44"/>
                                 <inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
                                 <inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
@@ -1873,17 +1878,22 @@
                         <constraints>
                         <constraints>
                             <constraint firstAttribute="trailing" secondItem="mia-XC-A8d" secondAttribute="trailing" id="2TB-C6-6NT"/>
                             <constraint firstAttribute="trailing" secondItem="mia-XC-A8d" secondAttribute="trailing" id="2TB-C6-6NT"/>
                             <constraint firstItem="Cs2-5V-Ius" firstAttribute="centerX" secondItem="Sml-Qx-H9e" secondAttribute="centerX" id="9Ve-qG-fYL"/>
                             <constraint firstItem="Cs2-5V-Ius" firstAttribute="centerX" secondItem="Sml-Qx-H9e" secondAttribute="centerX" id="9Ve-qG-fYL"/>
+                            <constraint firstAttribute="trailing" secondItem="9wT-8n-8NB" secondAttribute="trailing" id="Hi5-QQ-eXP"/>
                             <constraint firstItem="AKO-ni-aUG" firstAttribute="centerX" secondItem="Sml-Qx-H9e" secondAttribute="centerX" id="QUs-dy-CCo"/>
                             <constraint firstItem="AKO-ni-aUG" firstAttribute="centerX" secondItem="Sml-Qx-H9e" secondAttribute="centerX" id="QUs-dy-CCo"/>
-                            <constraint firstItem="mia-XC-A8d" firstAttribute="top" secondItem="gd4-2b-xmy" secondAttribute="bottom" id="Th9-Re-up1"/>
+                            <constraint firstItem="mia-XC-A8d" firstAttribute="top" secondItem="9wT-8n-8NB" secondAttribute="bottom" constant="2" id="TXm-fF-9tV"/>
                             <constraint firstItem="WfC-yf-L95" firstAttribute="top" secondItem="mia-XC-A8d" secondAttribute="bottom" id="VgT-0V-bY6"/>
                             <constraint firstItem="WfC-yf-L95" firstAttribute="top" secondItem="mia-XC-A8d" secondAttribute="bottom" id="VgT-0V-bY6"/>
                             <constraint firstItem="AKO-ni-aUG" firstAttribute="top" secondItem="gd4-2b-xmy" secondAttribute="bottom" id="ZdO-C0-uZy"/>
                             <constraint firstItem="AKO-ni-aUG" firstAttribute="top" secondItem="gd4-2b-xmy" secondAttribute="bottom" id="ZdO-C0-uZy"/>
                             <constraint firstItem="Cs2-5V-Ius" firstAttribute="centerY" secondItem="Sml-Qx-H9e" secondAttribute="centerY" id="b7w-Ch-uZo"/>
                             <constraint firstItem="Cs2-5V-Ius" firstAttribute="centerY" secondItem="Sml-Qx-H9e" secondAttribute="centerY" id="b7w-Ch-uZo"/>
+                            <constraint firstItem="9wT-8n-8NB" firstAttribute="top" secondItem="gd4-2b-xmy" secondAttribute="bottom" id="bmD-bG-2QS"/>
                             <constraint firstItem="mia-XC-A8d" firstAttribute="leading" secondItem="Sml-Qx-H9e" secondAttribute="leading" id="eJt-O9-kzA"/>
                             <constraint firstItem="mia-XC-A8d" firstAttribute="leading" secondItem="Sml-Qx-H9e" secondAttribute="leading" id="eJt-O9-kzA"/>
+                            <constraint firstItem="9wT-8n-8NB" firstAttribute="leading" secondItem="Sml-Qx-H9e" secondAttribute="leading" id="rTT-vG-wDX"/>
+                            <constraint firstItem="mia-XC-A8d" firstAttribute="height" secondItem="9wT-8n-8NB" secondAttribute="height" multiplier="2:1" id="uWa-dk-e6q"/>
                         </constraints>
                         </constraints>
                     </view>
                     </view>
                     <connections>
                     <connections>
                         <outlet property="mum" destination="Cs2-5V-Ius" id="vFR-HN-dsS"/>
                         <outlet property="mum" destination="Cs2-5V-Ius" id="vFR-HN-dsS"/>
                         <outlet property="norecordLabel" destination="AKO-ni-aUG" id="Th4-ki-ogc"/>
                         <outlet property="norecordLabel" destination="AKO-ni-aUG" id="Th4-ki-ogc"/>
+                        <outlet property="shipMap" destination="9wT-8n-8NB" id="7eJ-AJ-jEr"/>
                         <outlet property="table" destination="mia-XC-A8d" id="CDM-Ek-Tva"/>
                         <outlet property="table" destination="mia-XC-A8d" id="CDM-Ek-Tva"/>
                     </connections>
                     </connections>
                 </viewController>
                 </viewController>

+ 23 - 0
Apex Mobile/Apex Mobile/ShipMap/AMShipMap.h

@@ -0,0 +1,23 @@
+//
+//  AMShipMap.h
+//  Apex Mobile
+//
+//  Created by Jack on 2018/5/4.
+//  Copyright © 2018年 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface AMShipMap : UIView
+
+@property (nonatomic,assign) BOOL showPol;///< 默认YES
+@property (nonatomic,assign) BOOL showPoe;///< 默认NO
+@property (nonatomic,assign) BOOL showPor;///< 默认NO
+@property (nonatomic,assign) BOOL showPod;///< 默认YES
+@property (nonatomic,assign) BOOL showOrigin;///< 默认NO
+@property (nonatomic,assign) BOOL showDestination;///< 默认NO
+@property (nonatomic,assign) BOOL showCurrent;///< 默认YES
+
+- (void)showShipAnnotaion:(NSDictionary *)annotation;
+
+@end

+ 217 - 0
Apex Mobile/Apex Mobile/ShipMap/AMShipMap.m

@@ -0,0 +1,217 @@
+//
+//  AMShipMap.m
+//  Apex Mobile
+//
+//  Created by Jack on 2018/5/4.
+//  Copyright © 2018年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "AMShipMap.h"
+#import <MapKit/MapKit.h>
+#import "AMMapView.h"
+#import "AMAnnotationView.h"
+
+typedef enum {
+    
+    AMShipAnnotationPriorityRequired,
+    AMShipAnnotationPriorityHigh,
+    AMShipAnnotationPriorityLow
+    
+} AMShipAnnotationPriority;
+
+@interface AMShipAnnotation : MKPointAnnotation
+
+@property (nonatomic,assign) AMShipAnnotationPriority priority;
+
+@end
+
+@implementation AMShipAnnotation
+
+@end
+
+@interface AMShipMap () <MKMapViewDelegate>
+
+@property (nonatomic,strong) AMMapView *mapView;
+
+@end
+
+@implementation AMShipMap
+
+- (void)handleLoaction:(NSDictionary *)location Priority:(AMShipAnnotationPriority)priority {
+    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的委托设置回调方法来生成的)
+    AMShipAnnotation *ann = [[AMShipAnnotation alloc] init];
+    CLLocationCoordinate2D c2d = CLLocationCoordinate2DMake(latitude, longitude);
+    // 指定大头针的经纬度坐标(位置)以及附加的信息
+    ann.coordinate = c2d;
+    ann.title = name;
+    ann.subtitle = addr;
+    ann.priority = priority;
+    
+    // 将大头针数据模型添加到MKMapView上管理
+    [self.mapView addAnnotation:ann];
+    
+}
+
+- (void)showShipAnnotaion:(NSDictionary *)annotation {
+    
+    if (annotation == nil) {
+        return;
+    }
+    [self.mapView removeAnnotations:self.mapView.annotations];
+    NSDictionary *locationInfo = annotation;
+    
+    // pol,pod,poe,por,origin,destination,current
+    if (locationInfo) {
+        NSDictionary *pol = [locationInfo objectForKey:@"pol"];
+        if (self.showPol) {
+            [self handleLoaction:pol Priority:AMShipAnnotationPriorityHigh];
+        }
+        
+        NSDictionary *pod = [locationInfo objectForKey:@"pod"];
+        if (self.showPod) {
+            [self handleLoaction:pod Priority:AMShipAnnotationPriorityHigh];
+        }
+        
+        NSDictionary *poe = [locationInfo objectForKey:@"poe"];
+        if (self.showPoe) {
+            [self handleLoaction:poe Priority:AMShipAnnotationPriorityLow];
+        }
+        
+        NSDictionary *por = [locationInfo objectForKey:@"por"];
+        if (self.showPor) {
+            [self handleLoaction:por Priority:AMShipAnnotationPriorityLow];
+        }
+        
+        NSDictionary *origin = [locationInfo objectForKey:@"origin"];
+        if (self.showOrigin) {
+            [self handleLoaction:origin Priority:AMShipAnnotationPriorityLow];
+        }
+        
+        NSDictionary *destination = [locationInfo objectForKey:@"destination"];
+        if (self.showDestination) {
+            [self handleLoaction:destination Priority:AMShipAnnotationPriorityLow];
+        }
+        
+        NSDictionary *current = [locationInfo objectForKey:@"current"];
+        if (self.showCurrent) {
+            [self handleLoaction:current Priority:AMShipAnnotationPriorityRequired];
+        }
+    }
+}
+
+#pragma mark - Map Delegate
+
+// 当地图上添加了标注以后要执行的回调方法
+- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
+    
+    if ([annotation isKindOfClass:[AMShipAnnotation class]]) {
+        // 获取可复用的大头针视图
+        AMAnnotationView *pinView = (id)[mapView dequeueReusableAnnotationViewWithIdentifier:@"PIN"];
+        
+        if (!pinView) { // 如果没有可重用的大头针视图就创建并指定重用标识
+            pinView = [[AMAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"PIN"];
+        }
+        pinView.image = [UIImage imageNamed:@"ic_marker"];        
+        AMShipAnnotation *shipAnnotation = (AMShipAnnotation *)annotation;
+        if (@available(iOS 11,*)) {
+            if (shipAnnotation.priority == AMShipAnnotationPriorityRequired) {
+                pinView.displayPriority = MKFeatureDisplayPriorityRequired;
+            } else if (shipAnnotation.priority == AMShipAnnotationPriorityHigh) {
+                pinView.displayPriority = MKFeatureDisplayPriorityDefaultHigh;
+            } else {
+                pinView.displayPriority = MKFeatureDisplayPriorityDefaultLow;
+            }
+        }
+        
+        return pinView;
+    } else {
+        return nil;
+    }
+    
+//    return nil;
+}
+
+#pragma mark - Life
+
+- (void)setup {
+    
+    [self setupMap];
+    
+    self.showPol = YES;
+    self.showPod = YES;
+    self.showCurrent = YES;
+}
+
+- (void)setupMap {
+    
+    self.mapView = [[AMMapView alloc] init];
+    self.mapView.delegate = self;
+    self.mapView.translatesAutoresizingMaskIntoConstraints = NO;
+    [self addSubview:self.mapView];
+    self.mapView.rotateEnabled = NO;
+    // 显示比例尺
+    self.mapView.showsScale = YES;
+    // 显示用户的位置
+    //    self.mapView.showsUserLocation = YES;
+    
+    NSLayoutConstraint *top = [NSLayoutConstraint constraintWithItem:self.mapView
+                                                           attribute:NSLayoutAttributeTop
+                                                           relatedBy:NSLayoutRelationEqual
+                                                              toItem:self
+                                                           attribute:NSLayoutAttributeTop
+                                                          multiplier:1.0
+                                                            constant:0];
+    NSLayoutConstraint *left = [NSLayoutConstraint constraintWithItem:self.mapView
+                                                            attribute:NSLayoutAttributeLeft
+                                                            relatedBy:NSLayoutRelationEqual
+                                                               toItem:self
+                                                            attribute:NSLayoutAttributeLeft
+                                                           multiplier:1.0
+                                                             constant:0];
+    NSLayoutConstraint *bottom = [NSLayoutConstraint constraintWithItem:self.mapView
+                                                              attribute:NSLayoutAttributeBottom
+                                                              relatedBy:NSLayoutRelationEqual
+                                                                 toItem:self
+                                                              attribute:NSLayoutAttributeBottom
+                                                             multiplier:1.0
+                                                               constant:0];
+    NSLayoutConstraint *right = [NSLayoutConstraint constraintWithItem:self.mapView
+                                                             attribute:NSLayoutAttributeRight
+                                                             relatedBy:NSLayoutRelationEqual
+                                                                toItem:self
+                                                             attribute:NSLayoutAttributeRight
+                                                            multiplier:1.0
+                                                              constant:0];
+    [self addConstraints:@[top,left,bottom,right]];
+}
+
+- (instancetype)init {
+    if (self = [super init]) {
+        [self setup];
+    }
+    return self;
+}
+
+- (instancetype)initWithCoder:(NSCoder *)aDecoder {
+    if (self = [super initWithCoder:aDecoder]) {
+        [self setup];
+    }
+    return self;
+}
+
+- (instancetype)initWithFrame:(CGRect)frame {
+    if (self = [super initWithFrame:frame]) {
+        [self setup];
+    }
+    return self;
+}
+
+@end