Procházet zdrojové kódy

1.修改iOS Apex Mobile Location地址详细标签。
2.修改iOS Apex Mobile Recent添加地图。

Pen Li před 8 roky
rodič
revize
9fafcea856

+ 12 - 0
Apex Mobile/Apex Mobile.xcodeproj/project.pbxproj

@@ -45,6 +45,8 @@
 		42BB740720846B4500B9B6E4 /* KPITableCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 42BB740520846B4500B9B6E4 /* KPITableCell.xib */; };
 		42BB740720846B4500B9B6E4 /* KPITableCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 42BB740520846B4500B9B6E4 /* KPITableCell.xib */; };
 		42BB74092084732D00B9B6E4 /* KPICell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 42BB74082084732D00B9B6E4 /* KPICell.xib */; };
 		42BB74092084732D00B9B6E4 /* KPICell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 42BB74082084732D00B9B6E4 /* KPICell.xib */; };
 		42BB740B2084737800B9B6E4 /* KPILegendCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 42BB740A2084737800B9B6E4 /* KPILegendCell.xib */; };
 		42BB740B2084737800B9B6E4 /* KPILegendCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 42BB740A2084737800B9B6E4 /* KPILegendCell.xib */; };
+		42BCACCA209AE243009DDA43 /* AMAnnotationView.m in Sources */ = {isa = PBXBuildFile; fileRef = 42BCACC9209AE243009DDA43 /* AMAnnotationView.m */; };
+		42BCACCD209AE342009DDA43 /* AMMapAnnotaion.m in Sources */ = {isa = PBXBuildFile; fileRef = 42BCACCC209AE342009DDA43 /* AMMapAnnotaion.m */; };
 		42BFD2D2207B697800DA9038 /* KPICell.m in Sources */ = {isa = PBXBuildFile; fileRef = 42BFD2D1207B697800DA9038 /* KPICell.m */; };
 		42BFD2D2207B697800DA9038 /* KPICell.m in Sources */ = {isa = PBXBuildFile; fileRef = 42BFD2D1207B697800DA9038 /* KPICell.m */; };
 		7101BEC82031389A00CC6E3A /* DetailCellKVNew.m in Sources */ = {isa = PBXBuildFile; fileRef = 7101BEC72031389A00CC6E3A /* DetailCellKVNew.m */; };
 		7101BEC82031389A00CC6E3A /* DetailCellKVNew.m in Sources */ = {isa = PBXBuildFile; fileRef = 7101BEC72031389A00CC6E3A /* DetailCellKVNew.m */; };
 		711BA6C1191E0525002EDE6F /* MessageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 711BA6C0191E0525002EDE6F /* MessageViewController.m */; };
 		711BA6C1191E0525002EDE6F /* MessageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 711BA6C0191E0525002EDE6F /* MessageViewController.m */; };
@@ -248,6 +250,10 @@
 		42BB740520846B4500B9B6E4 /* KPITableCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KPITableCell.xib; sourceTree = "<group>"; };
 		42BB740520846B4500B9B6E4 /* KPITableCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KPITableCell.xib; sourceTree = "<group>"; };
 		42BB74082084732D00B9B6E4 /* KPICell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KPICell.xib; sourceTree = "<group>"; };
 		42BB74082084732D00B9B6E4 /* KPICell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KPICell.xib; sourceTree = "<group>"; };
 		42BB740A2084737800B9B6E4 /* KPILegendCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KPILegendCell.xib; sourceTree = "<group>"; };
 		42BB740A2084737800B9B6E4 /* KPILegendCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KPILegendCell.xib; sourceTree = "<group>"; };
+		42BCACC8209AE243009DDA43 /* AMAnnotationView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AMAnnotationView.h; sourceTree = "<group>"; };
+		42BCACC9209AE243009DDA43 /* AMAnnotationView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AMAnnotationView.m; sourceTree = "<group>"; };
+		42BCACCB209AE342009DDA43 /* AMMapAnnotaion.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AMMapAnnotaion.h; sourceTree = "<group>"; };
+		42BCACCC209AE342009DDA43 /* AMMapAnnotaion.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AMMapAnnotaion.m; sourceTree = "<group>"; };
 		42BFD2D0207B697800DA9038 /* KPICell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KPICell.h; sourceTree = "<group>"; };
 		42BFD2D0207B697800DA9038 /* KPICell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KPICell.h; sourceTree = "<group>"; };
 		42BFD2D1207B697800DA9038 /* KPICell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KPICell.m; sourceTree = "<group>"; };
 		42BFD2D1207B697800DA9038 /* KPICell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KPICell.m; sourceTree = "<group>"; };
 		7101BEC62031389A00CC6E3A /* DetailCellKVNew.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DetailCellKVNew.h; sourceTree = "<group>"; };
 		7101BEC62031389A00CC6E3A /* DetailCellKVNew.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DetailCellKVNew.h; sourceTree = "<group>"; };
@@ -872,6 +878,10 @@
 			children = (
 			children = (
 				7120DD0218BE273900E7546F /* LocationViewController.h */,
 				7120DD0218BE273900E7546F /* LocationViewController.h */,
 				7120DD0318BE273900E7546F /* LocationViewController.m */,
 				7120DD0318BE273900E7546F /* LocationViewController.m */,
+				42BCACC8209AE243009DDA43 /* AMAnnotationView.h */,
+				42BCACC9209AE243009DDA43 /* AMAnnotationView.m */,
+				42BCACCB209AE342009DDA43 /* AMMapAnnotaion.h */,
+				42BCACCC209AE342009DDA43 /* AMMapAnnotaion.m */,
 			);
 			);
 			name = Location;
 			name = Location;
 			sourceTree = "<group>";
 			sourceTree = "<group>";
@@ -1379,6 +1389,7 @@
 				719A51B418C5A8100080C075 /* GridResultViewController.m in Sources */,
 				719A51B418C5A8100080C075 /* GridResultViewController.m in Sources */,
 				71B7999B2021B22D00F8685E /* AMResultViewController.m in Sources */,
 				71B7999B2021B22D00F8685E /* AMResultViewController.m in Sources */,
 				425CF097201EB2B500750E32 /* JLRefreshHeader.m in Sources */,
 				425CF097201EB2B500750E32 /* JLRefreshHeader.m in Sources */,
+				42BCACCD209AE342009DDA43 /* AMMapAnnotaion.m in Sources */,
 				711DC6B218C30A4800FB1749 /* TableCellEdit.m in Sources */,
 				711DC6B218C30A4800FB1749 /* TableCellEdit.m in Sources */,
 				716027D1204D334A003CA085 /* DetailShareItemProvider.m in Sources */,
 				716027D1204D334A003CA085 /* DetailShareItemProvider.m in Sources */,
 				71A01D8218C9BA67003307A9 /* DetailContent.m in Sources */,
 				71A01D8218C9BA67003307A9 /* DetailContent.m in Sources */,
@@ -1402,6 +1413,7 @@
 				713AA7A1191736E600B44092 /* DocumentsViewController.m in Sources */,
 				713AA7A1191736E600B44092 /* DocumentsViewController.m in Sources */,
 				716FF7951904FBC600ED6C3D /* NewsTableViewCell.m in Sources */,
 				716FF7951904FBC600ED6C3D /* NewsTableViewCell.m in Sources */,
 				715709AB20215B6200EFE5C5 /* ZipArchive.mm in Sources */,
 				715709AB20215B6200EFE5C5 /* ZipArchive.mm in Sources */,
+				42BCACCA209AE243009DDA43 /* AMAnnotationView.m in Sources */,
 				425CF09A201EB2B500750E32 /* UIView+JLExtension.m in Sources */,
 				425CF09A201EB2B500750E32 /* UIView+JLExtension.m in Sources */,
 				71A01D7918C9AE77003307A9 /* DetailCellKV.m in Sources */,
 				71A01D7918C9AE77003307A9 /* DetailCellKV.m in Sources */,
 				42604127201C578B002374A8 /* ShipSearchController.m in Sources */,
 				42604127201C578B002374A8 /* ShipSearchController.m in Sources */,

+ 23 - 0
Apex Mobile/Apex Mobile/AMAnnotationView.h

@@ -0,0 +1,23 @@
+//
+//  AMAnnotationView.h
+//  Apex Mobile
+//
+//  Created by Jack on 2018/5/3.
+//  Copyright © 2018年 United Software Applications, Inc. All rights reserved.
+//
+
+#import <MapKit/MapKit.h>
+
+@class AMMapAnnotaion;
+
+@protocol AMAnnotationDelegate <NSObject>
+
+- (void)mapView:(MKMapView *)mapView didTapAnnotaionCallout:(AMMapAnnotaion *)annotation;
+
+@end
+
+@interface AMAnnotationView : MKAnnotationView
+
+@property (nonatomic,weak) id<AMAnnotationDelegate> delegate;
+
+@end

+ 240 - 0
Apex Mobile/Apex Mobile/AMAnnotationView.m

@@ -0,0 +1,240 @@
+//
+//  AMAnnotationView.m
+//  Apex Mobile
+//
+//  Created by Jack on 2018/5/3.
+//  Copyright © 2018年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "AMAnnotationView.h"
+#import "AMMapAnnotaion.h"
+
+@interface AMAnnotationView ()
+
+@property (strong,nonatomic) UIView *calloutView;
+@property (strong,nonatomic) AMMapAnnotaion *myAnnotation;
+@property (nonatomic,strong) UILabel *titleLabel;
+@property (nonatomic,strong) UILabel *detailLabel;
+@property (nonatomic,assign) BOOL tapedCallout;
+
+@end
+
+@implementation AMAnnotationView
+
+- (instancetype)initWithAnnotation:(id<MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier {
+    
+    if (self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier]) {
+        
+        self.opaque = NO;
+        self.canShowCallout = NO;
+
+        self.myAnnotation = (AMMapAnnotaion *)annotation;
+        self.calloutView = [[UIView alloc] init];
+        self.calloutView.backgroundColor = [UIColor whiteColor];
+    }
+    return self;
+}
+
+- (UILabel *)titleLabel {
+    if (!_titleLabel) {
+        _titleLabel = [[UILabel alloc] init];
+        _titleLabel.font = [UIFont boldSystemFontOfSize:16.0f];
+        _titleLabel.textColor = [UIColor blackColor];
+        _titleLabel.textAlignment = NSTextAlignmentLeft;
+        _titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
+        _titleLabel.numberOfLines = 1;
+    }
+    return _titleLabel;
+}
+
+- (UILabel *)detailLabel {
+    if (!_detailLabel) {
+        _detailLabel = [[UILabel alloc] init];
+        _detailLabel.font = [UIFont systemFontOfSize:14.0f];
+        _detailLabel.textColor = [UIColor blackColor];
+        _detailLabel.textAlignment = NSTextAlignmentLeft;
+        _detailLabel.lineBreakMode = NSLineBreakByTruncatingTail;
+        _detailLabel.numberOfLines = 0;
+    }
+    return _detailLabel;
+}
+
+- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
+    
+    UIView *hitView = [super hitTest:point withEvent:event];
+    self.tapedCallout = NO;
+    if (self.isSelected) {
+
+        if (hitView) {
+//            self.canDeselected = NO;
+            return self;
+        }
+
+        if (CGRectContainsPoint(self.calloutView.frame, point)) {
+//            hitView = self.calloutView;
+            self.tapedCallout = YES;
+
+            return self.calloutView;
+        }
+
+    }
+
+    return hitView;
+}
+
+- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
+    if (self.isSelected && self.tapedCallout) {
+        if (self.delegate && [self.delegate respondsToSelector:@selector(mapView:didTapAnnotaionCallout:)]) {
+            [self.delegate mapView:[self findMap:self] didTapAnnotaionCallout:self.myAnnotation];
+        }
+    }
+    [super setSelected:selected animated:YES];
+
+    // Get the custom callout view.
+    UIView *calloutView = self.calloutView;
+    if (selected) {
+
+        NSString *title = self.myAnnotation.title;
+        NSString *detail = self.myAnnotation.subtitle;
+
+        CGFloat maxWidth = [UIScreen mainScreen].bounds.size.width * 0.8f;
+
+        CGFloat w0 = maxWidth;
+
+        CGRect frame = CGRectZero;
+        self.titleLabel.text = title;
+        [self.titleLabel sizeToFit];
+        frame = self.titleLabel.bounds;
+        frame.origin = CGPointMake(5, 5);
+        w0 = CGRectGetWidth(frame);
+        if (w0 > maxWidth) {
+            w0 = maxWidth;
+            frame.size.width = w0;
+        }
+        self.titleLabel.frame = frame;
+        [self.calloutView addSubview:self.titleLabel];
+
+        CGFloat w1 = maxWidth;
+        self.detailLabel.text = detail;
+        [self.detailLabel sizeToFit];
+        frame.origin.y = CGRectGetMaxY(frame) + 5;
+        frame.size = self.detailLabel.bounds.size;
+        w1 = CGRectGetWidth(frame);
+        if (w1 > maxWidth) {
+            w1 = maxWidth;
+            frame.size.width = w1;
+        }
+        self.detailLabel.frame = frame;
+        [self.calloutView addSubview:self.detailLabel];
+
+        CGFloat h = CGRectGetMaxY(frame) + 5 + 10;
+
+        MKMapView *map = [self findMap:self];
+
+//        frame = self.frame;
+//
+//        // 将左右边距小于30的移动30
+//        if (frame.origin.x < 30) {
+//
+//            if (map != nil) {
+//                MKCoordinateRegion region = map.region;
+//                CGPoint center = map.center;
+//                center.x -= 30;
+//                region.center = [map convertPoint:center toCoordinateFromView:map];
+//                [map setRegion:region animated:NO];
+//            }
+//        }
+//        if (CGRectGetMaxX(frame) > CGRectGetWidth(map.bounds) - 30) {
+//            if (map != nil) {
+//                MKCoordinateRegion region = map.region;
+//                CGPoint center = map.center;
+//                center.x += 30;
+//                region.center = [map convertPoint:center toCoordinateFromView:map];
+//                [map setRegion:region animated:NO];
+//            }
+//
+//        }
+//
+//        if (CGRectGetMinY(frame) < h) {
+//            if (map != nil) {
+//
+//                MKCoordinateRegion region = map.region;
+//                CGPoint center = map.center;
+//                center.y += h + CGRectGetHeight(frame);
+//                region.center = [map convertPoint:center toCoordinateFromView:map];
+//                [map setRegion:region animated:NO];
+//
+//            }
+//        }
+
+        CGPoint center = self.center;
+        MKCoordinateRegion region = map.region;
+        region.center = [map convertPoint:center toCoordinateFromView:map];
+        [map setRegion:region animated:NO];
+
+        frame = self.frame;
+
+
+        CGFloat w = MAX(w0, w1) + 5 * 2;
+
+        self.calloutView.frame = CGRectMake((CGRectGetWidth(frame) - w) * 0.5, -h, w, h);
+
+        UIBezierPath *path = [self pathForCalloutWithWidth:w Height:h Anchor:CGPointMake(w * 0.5, h)];
+
+        CAShapeLayer *mask = [CAShapeLayer layer];
+        mask.fillColor = [UIColor blackColor].CGColor;
+        mask.shadowColor = [UIColor blackColor].CGColor;
+        mask.shadowOffset = CGSizeMake(2, 2);
+        mask.path = path.CGPath;
+        self.calloutView.layer.mask = mask;
+
+        [self addSubview:calloutView];
+    } else {
+        [calloutView removeFromSuperview];
+    }
+}
+
+- (MKMapView *)findMap:(UIView *)view {
+    if (view == nil) {
+        return nil;
+    }
+    if (view.superview == nil) {
+        if ([view isKindOfClass:[MKMapView class]]) {
+            return (MKMapView *)view;
+        } else {
+            return nil;
+        }
+    }
+    if (view.superview && [view.superview isKindOfClass:[MKMapView class]]) {
+        return (MKMapView *)view.superview;
+    } else {
+        return [self findMap:view.superview];
+    }
+}
+
+- (UIBezierPath *)pathForCalloutWithWidth:(CGFloat)w Height:(CGFloat)h Anchor:(CGPoint)anchor {
+    
+    UIBezierPath *path = [UIBezierPath bezierPath];
+    [path moveToPoint:CGPointMake(w * 0.5, 0)];
+    [path addLineToPoint:CGPointMake(w - 5, 0)];
+    [path addQuadCurveToPoint:CGPointMake(w, 5) controlPoint:CGPointMake(w, 0)];
+    [path addLineToPoint:CGPointMake(w, h - 15)];
+    [path addQuadCurveToPoint:CGPointMake(w - 5, h - 10) controlPoint:CGPointMake(w, h - 10)];
+    
+//    [path addLineToPoint:CGPointMake(anchor.x + 10, h - 10)];
+//    [path addQuadCurveToPoint:anchor controlPoint:CGPointMake(anchor.x + 5, h - 10)];
+//    [path addQuadCurveToPoint:CGPointMake(anchor.x - 10, h - 10) controlPoint:CGPointMake(anchor.x - 5, h - 10)];
+    
+    [path addLineToPoint:CGPointMake(anchor.x + 6, h - 10)];
+    [path addLineToPoint:anchor];
+    [path addLineToPoint:CGPointMake(anchor.x - 6, h - 10)];
+    
+    [path addLineToPoint:CGPointMake(5, h - 10)];
+    [path addQuadCurveToPoint:CGPointMake(0, h - 15) controlPoint:CGPointMake(0, h - 10)];
+    [path addLineToPoint:CGPointMake(0, 5)];
+    [path addQuadCurveToPoint:CGPointMake(5, 0) controlPoint:CGPointMake(0, 0)];
+    [path addLineToPoint:CGPointMake(w * 0.5, 0)];
+    return path;
+}
+
+@end

+ 16 - 0
Apex Mobile/Apex Mobile/AMMapAnnotaion.h

@@ -0,0 +1,16 @@
+//
+//  AMMapAnnotaion.h
+//  Apex Mobile
+//
+//  Created by Jack on 2018/5/3.
+//  Copyright © 2018年 United Software Applications, Inc. All rights reserved.
+//
+
+#import <MapKit/MapKit.h>
+
+
+@interface AMMapAnnotaion : MKPointAnnotation
+
+@property (nonatomic,strong) NSDictionary *params;
+
+@end

+ 13 - 0
Apex Mobile/Apex Mobile/AMMapAnnotaion.m

@@ -0,0 +1,13 @@
+//
+//  AMMapAnnotaion.m
+//  Apex Mobile
+//
+//  Created by Jack on 2018/5/3.
+//  Copyright © 2018年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "AMMapAnnotaion.h"
+
+@implementation AMMapAnnotaion
+
+@end

+ 3 - 0
Apex Mobile/Apex Mobile/HomeViewController.m

@@ -15,6 +15,7 @@
 #import "KPICell.h"
 #import "KPICell.h"
 #import "KPITableCell.h"
 #import "KPITableCell.h"
 #import "AMResultViewController.h"
 #import "AMResultViewController.h"
+#import <MapKit/MapKit.h>
 
 
 #define SHIP_CELL_IDENTIFIER @"ShippingStatusCell"
 #define SHIP_CELL_IDENTIFIER @"ShippingStatusCell"
 #define KPI_CELL_IDENTIFIER @"KPITableCell"
 #define KPI_CELL_IDENTIFIER @"KPITableCell"
@@ -52,6 +53,8 @@ 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;
+
 @end
 @end
 
 
 @implementation HomeViewController
 @implementation HomeViewController

+ 69 - 62
Apex Mobile/Apex Mobile/LocationViewController.m

@@ -11,19 +11,8 @@
 #import <Contacts/Contacts.h>
 #import <Contacts/Contacts.h>
 #import <ContactsUI/ContactsUI.h>
 #import <ContactsUI/ContactsUI.h>
 #import <MapKit/MapKit.h>
 #import <MapKit/MapKit.h>
-
-
-#pragma mark - Annotation
-
-@interface AMMapAnnotaion : MKPointAnnotation
-
-@property (nonatomic,strong) NSDictionary *params;
-
-@end
-
-@implementation AMMapAnnotaion
-
-@end
+#import "AMMapAnnotaion.h"
+#import "AMAnnotationView.h"
 
 
 #pragma mark - Button
 #pragma mark - Button
 
 
@@ -39,7 +28,7 @@
 
 
 #pragma mark - Location
 #pragma mark - Location
 
 
-@interface LocationViewController () <MKMapViewDelegate>
+@interface LocationViewController () <MKMapViewDelegate,CLLocationManagerDelegate,AMAnnotationDelegate>
 //@property (strong,nonatomic) NSString* locations ;
 //@property (strong,nonatomic) NSString* locations ;
 
 
 @property (nonatomic,assign) BOOL useGoogleMap;
 @property (nonatomic,assign) BOOL useGoogleMap;
@@ -51,6 +40,8 @@
     
     
     // 苹果原生的地图视图
     // 苹果原生的地图视图
     MKMapView *myMapView;
     MKMapView *myMapView;
+    // 定位服务管理器
+    CLLocationManager *myLocManager;
 }
 }
 - (BOOL)shouldAutorotate
 - (BOOL)shouldAutorotate
 {
 {
@@ -573,26 +564,29 @@ didTapInfoWindowOfMarker:(GMSMarker *)marker
     // 为MKMapView绑定委托
     // 为MKMapView绑定委托
     myMapView.delegate = self;
     myMapView.delegate = self;
     
     
+    myMapView.translatesAutoresizingMaskIntoConstraints = NO;
     [self.view addSubview:myMapView];
     [self.view addSubview:myMapView];
     
     
+    myMapView.rotateEnabled = NO;
     // 创建经纬度坐标的结构体变量
     // 创建经纬度坐标的结构体变量
     // CLLocationCoordinate2DMake函数的第一个参数是纬度第二个参数是经度
     // CLLocationCoordinate2DMake函数的第一个参数是纬度第二个参数是经度
     CLLocationCoordinate2D c2d = CLLocationCoordinate2DMake(39.833333 , -98.3583333);
     CLLocationCoordinate2D c2d = CLLocationCoordinate2DMake(39.833333 , -98.3583333);
-    
+
     MKCoordinateSpan span = MKCoordinateSpanMake(180, 360);
     MKCoordinateSpan span = MKCoordinateSpanMake(180, 360);
     // 创建一个区域结构体变量
     // 创建一个区域结构体变量
     MKCoordinateRegion region = MKCoordinateRegionMake(c2d, span);
     MKCoordinateRegion region = MKCoordinateRegionMake(c2d, span);
     // 设置地图中心为指定区域
     // 设置地图中心为指定区域
     [myMapView setRegion:region animated:YES];
     [myMapView setRegion:region animated:YES];
     
     
-//    // 创建定位服务管理器对象
-//    myLocManager = [[CLLocationManager alloc] init];
-//    myLocManager.delegate = self;
-//    [myLocManager requestWhenInUseAuthorization];
-//    [myLocManager startUpdatingLocation];
-//
-//    // 显示用户的位置
-//    myMapView.showsUserLocation = YES;
+    // 创建定位服务管理器对象
+    myLocManager = [[CLLocationManager alloc] init];
+    myLocManager.delegate = self;
+    [myLocManager requestWhenInUseAuthorization];
+    [myLocManager startUpdatingLocation];
+
+    // 显示用户的位置
+    myMapView.showsUserLocation = YES;
+//    myMapView.userTrackingMode = MKUserTrackingModeFollow;
     
     
     NSLayoutConstraint *top = [NSLayoutConstraint constraintWithItem:myMapView
     NSLayoutConstraint *top = [NSLayoutConstraint constraintWithItem:myMapView
                                                            attribute:NSLayoutAttributeTop
                                                            attribute:NSLayoutAttributeTop
@@ -654,6 +648,7 @@ didTapInfoWindowOfMarker:(GMSMarker *)marker
         
         
         // 将大头针数据模型添加到MKMapView上管理
         // 将大头针数据模型添加到MKMapView上管理
         [myMapView addAnnotation:ann];
         [myMapView addAnnotation:ann];
+        break;
     }
     }
 }
 }
 
 
@@ -661,39 +656,46 @@ didTapInfoWindowOfMarker:(GMSMarker *)marker
 
 
 // 当地图上添加了标注以后要执行的回调方法
 // 当地图上添加了标注以后要执行的回调方法
 - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
 - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
-    // 获取可复用的大头针视图
-    MKAnnotationView *pinView = (id)[mapView dequeueReusableAnnotationViewWithIdentifier:@"PIN"];
-    
-    if (!pinView) { // 如果没有可重用的大头针视图就创建并指定重用标识
-        pinView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"PIN"];
+    if ([annotation isKindOfClass:[AMMapAnnotaion class]]) {
+        // 获取可复用的大头针视图
+        AMAnnotationView *pinView = (id)[mapView dequeueReusableAnnotationViewWithIdentifier:@"PIN"];
+        
+        if (!pinView) { // 如果没有可重用的大头针视图就创建并指定重用标识
+            pinView = [[AMAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"PIN"];
+        }
+        pinView.delegate = self;
+        pinView.image = [UIImage imageNamed:@"ic_marker"];
+        
+//        // 以气泡方式显示大头针的信息
+//        pinView.canShowCallout = YES;
+//        // 启用大头针掉下动画
+//        //        pinView.animatesDrop = YES;
+//
+//        //    UIImageView *headerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
+//        //    headerImageView.layer.cornerRadius = 20;
+//        //    headerImageView.layer.masksToBounds = YES;
+//        //    headerImageView.image = [UIImage imageNamed:@"7.jpg"];
+//        //    headerImageView.userInteractionEnabled = YES;
+//        //    // 定制大头针气泡信息的左侧附加视图
+//        //    pinView.leftCalloutAccessoryView = headerImageView;
+//
+//
+//
+//        MapAccessoryButton *goButton = [MapAccessoryButton buttonWithType:UIButtonTypeCustom];
+//        if ([annotation isKindOfClass:[AMMapAnnotaion class]]) {
+//            AMMapAnnotaion *ann = annotation;
+//            goButton.params = ann.params;
+//        }
+//        goButton.frame = CGRectMake(0, 0, 40, 40);
+//        [goButton setImage:[UIImage imageNamed:@"Forward"] forState:UIControlStateNormal];
+//        [goButton addTarget:self action:@selector(goButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
+//        // 定制大头针气泡信息的右侧附加视图
+//        pinView.rightCalloutAccessoryView = goButton;
+        
+        return pinView;
+    } else {
+        return nil; // 返回nil,系统使用蓝色圆点标识当前位置
     }
     }
-    
-    pinView.image = [UIImage imageNamed:@"ic_marker"];
-    
-    // 以气泡方式显示大头针的信息
-    pinView.canShowCallout = YES;
-    // 启用大头针掉下动画
-    //        pinView.animatesDrop = YES;
-    
-    //    UIImageView *headerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
-    //    headerImageView.layer.cornerRadius = 20;
-    //    headerImageView.layer.masksToBounds = YES;
-    //    headerImageView.image = [UIImage imageNamed:@"7.jpg"];
-    //    headerImageView.userInteractionEnabled = YES;
-    //    // 定制大头针气泡信息的左侧附加视图
-    //    pinView.leftCalloutAccessoryView = headerImageView;
-    
-    AMMapAnnotaion *ann = annotation;
-    
-    MapAccessoryButton *goButton = [MapAccessoryButton buttonWithType:UIButtonTypeCustom];
-    goButton.params = ann.params;
-    goButton.frame = CGRectMake(0, 0, 40, 40);
-    [goButton setImage:[UIImage imageNamed:@"Forward"] forState:UIControlStateNormal];
-    [goButton addTarget:self action:@selector(goButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
-    // 定制大头针气泡信息的右侧附加视图
-    pinView.rightCalloutAccessoryView = goButton;
-    
-    return pinView;
 }
 }
 
 
 - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
 - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
@@ -706,7 +708,12 @@ didTapInfoWindowOfMarker:(GMSMarker *)marker
 
 
 - (void) goButtonClicked:(MapAccessoryButton *) sender {
 - (void) goButtonClicked:(MapAccessoryButton *) sender {
 
 
-    self.params = sender.params;
+    self.params = [sender.params mutableCopy];
+    [self showUnknown];
+}
+
+- (void)mapView:(MKMapView *)mapView didTapAnnotaionCallout:(AMMapAnnotaion *)annotation {
+    self.params = [annotation.params mutableCopy];
     [self showUnknown];
     [self showUnknown];
 }
 }
 
 
@@ -716,12 +723,12 @@ didTapInfoWindowOfMarker:(GMSMarker *)marker
 
 
 // 定位的位置发生改变后的回调方法
 // 定位的位置发生改变后的回调方法
 - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
 - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
-    // 从数组中取出第一个元素(包括当前的定位信息[经纬度、海拔、速度、方向等])
-    CLLocation *location = [locations firstObject];
-    // 创建一个新的区域
-    MKCoordinateRegion newRegion = MKCoordinateRegionMake(location.coordinate, MKCoordinateSpanMake(0.1, 0.1));
-    // 将地图位置设置到新的区域
-    [myMapView setRegion:newRegion animated:YES];
+//    // 从数组中取出第一个元素(包括当前的定位信息[经纬度、海拔、速度、方向等])
+//    CLLocation *location = [locations firstObject];
+//    // 创建一个新的区域
+//    MKCoordinateRegion newRegion = MKCoordinateRegionMake(location.coordinate, MKCoordinateSpanMake(180, 360));
+//    // 将地图位置设置到新的区域
+//    [myMapView setRegion:newRegion animated:YES];
 }
 }
 
 
 -(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {
 -(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {

+ 12 - 2
Apex Mobile/Apex Mobile/Main.storyboard

@@ -342,8 +342,14 @@
                             <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="0.0" y="0.0" width="375" height="150"/>
+                                        <constraints>
+                                            <constraint firstAttribute="height" constant="150" id="eAC-LI-n8J"/>
+                                        </constraints>
+                                    </mapView>
                                     <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="0.0" width="375" height="514"/>
+                                        <rect key="frame" x="0.0" y="150" width="375" height="514"/>
                                         <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,11 +391,14 @@
                                 <constraints>
                                 <constraints>
                                     <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 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" id="DQD-M7-57a"/>
                                     <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" id="MUJ-8S-eA6"/>
                                     <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" id="XQd-lR-G3j"/>
                                     <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" 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"/>
-                                    <constraint firstItem="iIl-j9-7oa" firstAttribute="centerY" secondItem="TYb-wc-Nwg" secondAttribute="centerY" id="u2T-Xe-eO1"/>
                                     <constraint firstItem="iIl-j9-7oa" firstAttribute="height" secondItem="TYb-wc-Nwg" secondAttribute="height" id="whL-aN-51R"/>
                                     <constraint firstItem="iIl-j9-7oa" firstAttribute="height" secondItem="TYb-wc-Nwg" secondAttribute="height" id="whL-aN-51R"/>
                                 </constraints>
                                 </constraints>
                             </view>
                             </view>
@@ -442,6 +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="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>