Commit b5aee91b authored by lmj_521aiau@163.com's avatar lmj_521aiau@163.com

no message

parent 99dad828
No preview for this file type
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "1150" LastUpgradeVersion = "1150"
version = "1.3"> version = "1.7">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"> buildImplicitDependencies = "YES">
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
ignoresPersistentStateOnLaunch = "NO" ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES" debugDocumentVersioning = "YES"
debugServiceExtension = "internal" debugServiceExtension = "internal"
allowLocationSimulation = "YES"> allowLocationSimulation = "NO">
<BuildableProductRunnable <BuildableProductRunnable
runnableDebuggingMode = "0"> runnableDebuggingMode = "0">
<BuildableReference <BuildableReference
...@@ -50,6 +50,10 @@ ...@@ -50,6 +50,10 @@
ReferencedContainer = "container:ZhiJi.xcodeproj"> ReferencedContainer = "container:ZhiJi.xcodeproj">
</BuildableReference> </BuildableReference>
</BuildableProductRunnable> </BuildableProductRunnable>
<LocationScenarioReference
identifier = "com.apple.dt.IDEFoundation.CurrentLocationScenarioIdentifier"
referenceType = "1">
</LocationScenarioReference>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
buildConfiguration = "Release" buildConfiguration = "Release"
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#import "ZJBaseMapViewController.h" #import "ZJBaseMapViewController.h"
#import <GoogleMaps/GoogleMaps.h> #import <GoogleMaps/GoogleMaps.h>
#import "ZJLocationManager.h"
@interface ZJBaseMapViewController ()<MAMapViewDelegate, XMPopupListViewDelegate, GMSMapViewDelegate> @interface ZJBaseMapViewController ()<MAMapViewDelegate, XMPopupListViewDelegate, GMSMapViewDelegate>
...@@ -20,7 +21,11 @@ ...@@ -20,7 +21,11 @@
@property (nonatomic, strong) ZJMapCardFriendSelectView *selectView; @property (nonatomic, strong) ZJMapCardFriendSelectView *selectView;
@property (nonatomic, strong) ZJFriendModel *selectFriendModel; @property (nonatomic, strong) ZJFriendModel *selectFriendModel;
@property (nonatomic, strong) GMSMapView *mapView; @property (nonatomic, strong) GMSMapView * mapView;
@property (nonatomic, strong) GMSMarker * selfMarker;
@property (nonatomic, assign) float zoom;
@property (nonatomic, assign) BOOL refershMyself;
@end @end
...@@ -43,6 +48,19 @@ ...@@ -43,6 +48,19 @@
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// [self getFriendList]; // [self getFriendList];
}); });
self.refershMyself = YES;
[[ZJLocationManager shared] initWithLocationUpdateInfo:^(ZJLocationModel * model, CLLocation * location) {
CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(model.latitude, model.longitude);
if (self.refershMyself) {
self.mapView.camera = [GMSCameraPosition cameraWithTarget:coord zoom:self.zoom];
self.refershMyself = NO;
}
[self setPoint:coord target:1];
}];
} }
- (void)viewWillAppear:(BOOL)animated{ - (void)viewWillAppear:(BOOL)animated{
...@@ -54,6 +72,8 @@ ...@@ -54,6 +72,8 @@
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.868 longitude:151.2086 zoom:12]; GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.868 longitude:151.2086 zoom:12];
_zoom = 14;
///初始化地图 ///初始化地图
// self.mapView = [[MAMapView alloc] initWithFrame:self.view.bounds]; // self.mapView = [[MAMapView alloc] initWithFrame:self.view.bounds];
self.mapView = [GMSMapView mapWithFrame:self.view.bounds camera:camera]; self.mapView = [GMSMapView mapWithFrame:self.view.bounds camera:camera];
...@@ -72,7 +92,7 @@ ...@@ -72,7 +92,7 @@
// [self.mapView performSelector:NSSelectorFromString(@"setMapLanguage:") withObject:@(1)]; // [self.mapView performSelector:NSSelectorFromString(@"setMapLanguage:") withObject:@(1)];
// } // }
// _mapView.delegate = self; _mapView.delegate = self;
// _mapView.zoomLevel = 14; // _mapView.zoomLevel = 14;
// _mapView.showsScale = false; // _mapView.showsScale = false;
// _mapView.showsCompass = false; // _mapView.showsCompass = false;
...@@ -132,11 +152,29 @@ ...@@ -132,11 +152,29 @@
}; };
} }
- (void)setPoint:(CLLocationCoordinate2D)point{ - (void)setPoint:(CLLocationCoordinate2D)point target:(NSInteger)target{
CLLocationCoordinate2D position = point; if (target == 1) {
GMSMarker *marker = [GMSMarker markerWithPosition:position]; CLLocationCoordinate2D position = point;
marker.title = @"Hello World"; _selfMarker.map = nil;
marker.map = _mapView; _selfMarker = [GMSMarker markerWithPosition:position];
// _selfMarker.appearAnimation = kGMSMarkerAnimationPop;
// _selfMarker.icon = [GMSMarker markerImageWithColor:[UIColor blackColor]];
_selfMarker.icon = [UIImage imageNamed:@"map_track_srart_end_icon"];
_selfMarker.tracksInfoWindowChanges = YES;
_selfMarker.title = @"Me";
_selfMarker.snippet = @"WTF";
_selfMarker.infoWindowAnchor = CGPointMake(0.5, 0.25);
_selfMarker.map = _mapView;
}else{
CLLocationCoordinate2D position = point;
GMSMarker *marker = [GMSMarker markerWithPosition:position];
marker.title = @"Hello World";
marker.map = _mapView;
}
}
-(void)mapView:(GMSMapView*)mapView idleAtCameraPosition:(GMSCameraPosition*)position{
_zoom = position.zoom;
} }
- (void)mapView:(UIView *)mapView regionDidChangeAnimated:(BOOL)animated { - (void)mapView:(UIView *)mapView regionDidChangeAnimated:(BOOL)animated {
......
...@@ -18,10 +18,12 @@ ...@@ -18,10 +18,12 @@
#import "AlertControllerTool.h" #import "AlertControllerTool.h"
#import <CoreLocation/CoreLocation.h> #import <CoreLocation/CoreLocation.h>
#import "BaseWebViewController.h" #import "BaseWebViewController.h"
#import <GoogleMaps/GoogleMaps.h>
#import "ZJLocationManager.h"
@interface ZJFriendTrackMapViewController () <MAMapViewDelegate> @interface ZJFriendTrackMapViewController () <MAMapViewDelegate, GMSMapViewDelegate>
@property (nonatomic, strong) MAMapView *mapView; //@property (nonatomic, strong) MAMapView *mapView;
@property (nonatomic, strong) UIButton *gpsButton; @property (nonatomic, strong) UIButton *gpsButton;
@property (nonatomic, strong) ZJUserTrackTimeView *trackTimeView; @property (nonatomic, strong) ZJUserTrackTimeView *trackTimeView;
@property (nonatomic, strong) NSMutableArray<ZJLocationModel *> *locations; @property (nonatomic, strong) NSMutableArray<ZJLocationModel *> *locations;
...@@ -36,6 +38,29 @@ ...@@ -36,6 +38,29 @@
@property (nonatomic, strong) NSArray *distanceArray; @property (nonatomic, strong) NSArray *distanceArray;
@property (nonatomic, assign) double sumDistance; @property (nonatomic, assign) double sumDistance;
@property (nonatomic, strong) ZJAlertView *alertView; @property (nonatomic, strong) ZJAlertView *alertView;
@property (nonatomic, strong) GMSMapView * mapView;
@property (nonatomic, strong) GMSCircle * selfCircle;
@property (nonatomic, strong) GMSMarker * selfMarker;
@property (nonatomic, assign) float __block zoom;
@property (nonatomic, assign) BOOL refershMyself;
@property (nonatomic, strong) GMSPolyline * initialPolyline;
@property (nonatomic, strong) GMSPolyline * actionPolyline;
@property (nonatomic, strong) NSMutableArray * arrayPolylineGreen;
@property (nonatomic, strong) GMSMutablePath * initiallinepath;
@property (nonatomic, strong) GMSMutablePath * actionlinepath;
@property (nonatomic, strong) GMSMarker * startMarker;
@property (nonatomic, strong) GMSMarker * endMarker;
@property (nonatomic, strong) GMSMarker * actionMarker;
@property (nonatomic, assign) NSInteger count;
@property(nonatomic, retain) NSTimer * timer;
@end @end
@implementation ZJFriendTrackMapViewController @implementation ZJFriendTrackMapViewController
...@@ -69,6 +94,23 @@ ...@@ -69,6 +94,23 @@
} }
} }
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
self.refershMyself = YES;
[[ZJLocationManager shared] initWithLocationUpdateInfo:^(ZJLocationModel * model, CLLocation * location) {
CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(model.latitude, model.longitude);
if (self.refershMyself) {
self.mapView.camera = [GMSCameraPosition cameraWithTarget:coord zoom:self.zoom];
self.refershMyself = NO;
}
[self setPoint:coord target:1];
}];
}
-(void)shareAction { -(void)shareAction {
//share //share
} }
...@@ -136,19 +178,24 @@ ...@@ -136,19 +178,24 @@
- (void)setupUI { - (void)setupUI {
_zoom = 20;
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.868 longitude:151.2086 zoom:_zoom];
///初始化地图 ///初始化地图
self.mapView = [[MAMapView alloc] initWithFrame:self.view.bounds]; // self.mapView = [[MAMapView alloc] initWithFrame:self.view.bounds];
self.mapView = [GMSMapView mapWithFrame:self.view.bounds camera:camera];
_mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; _mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
///把地图添加至view ///把地图添加至view
[self.view addSubview: _mapView]; [self.view addSubview: _mapView];
///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码 ///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码
_mapView.showsUserLocation = false; // _mapView.showsUserLocation = false;
_mapView.delegate = self; _mapView.delegate = self;
_mapView.zoomLevel = 14; // _mapView.zoomLevel = 14;
_mapView.showsScale = false; // _mapView.showsScale = false;
_mapView.showsCompass = false; // _mapView.showsCompass = false;
// 添加 card view // 添加 card view
self.trackTimeView = [[[NSBundle mainBundle] loadNibNamed:@"ZJUserTrackTimeView" owner:self options:nil] lastObject]; self.trackTimeView = [[[NSBundle mainBundle] loadNibNamed:@"ZJUserTrackTimeView" owner:self options:nil] lastObject];
...@@ -177,94 +224,293 @@ ...@@ -177,94 +224,293 @@
weakSelf.endDate = endDate; weakSelf.endDate = endDate;
}; };
self.track = [[MAAnimatedAnnotation alloc] init]; // self.track = [[MAAnimatedAnnotation alloc] init];
self.track.title = @"pointReuseIndetifier1"; // self.track.title = @"pointReuseIndetifier1";
[self.mapView addAnnotation:self.track]; // [self.mapView addAnnotation:self.track];
_initialPolyline = [[GMSPolyline alloc] init];
_initiallinepath = [GMSMutablePath path];
} }
- (void) drawLineAction { - (void)setPoint:(CLLocationCoordinate2D)point target:(NSInteger)target{
if (target == 1) {
if (self.isMyTrack) { CLLocationCoordinate2D position = point;
[MobClick event:@"mytrack_querybutton_click"]; _selfMarker.map = nil;
_selfMarker = [GMSMarker markerWithPosition:position];
// _selfMarker.appearAnimation = kGMSMarkerAnimationPop;
// _selfMarker.icon = [GMSMarker markerImageWithColor:[UIColor blackColor]];
_selfMarker.icon = [UIImage imageNamed:@"map_track_srart_end_icon"];
_selfMarker.tracksInfoWindowChanges = YES;
_selfMarker.title = @"Me";
_selfMarker.snippet = @"WTF";
_selfMarker.infoWindowAnchor = CGPointMake(0.5, 0.25);
_selfMarker.map = _mapView;
CLLocationDistance distance = 100;
self.selfCircle.map = nil;
self.selfCircle = [GMSCircle circleWithPosition:position radius:distance];
self.selfCircle.fillColor = [kColorWithRGBA(86, 142, 252, 0.15) colorWithAlphaComponent:0.5];
self.selfCircle.strokeColor = [kColorWithRGBA(86, 142, 252, 0.6) colorWithAlphaComponent:0.5];
self.selfCircle.strokeWidth = 1.0;
self.selfCircle.map = self.mapView;
}else{ }else{
[MobClick event:@"friendtrack_querybutton_click"]; CLLocationCoordinate2D position = point;
GMSMarker *marker = [GMSMarker markerWithPosition:position];
marker.title = @"Hello World";
marker.map = _mapView;
} }
}
[self.trackTimeView.trackButton setSelected:true]; -(void)mapView:(GMSMapView*)mapView idleAtCameraPosition:(GMSCameraPosition*)position{
[self.trackTimeView.trackButton setEnabled:false]; _zoom = position.zoom;
//移除 }
[self.mapView removeOverlay:self.commonPolyline];
//画线,使用轨迹回放
// need get user location info - (void)drawLineWithLocationArray:(NSArray *)locationArray{
if ([CLLocationManager locationServicesEnabled] && ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedWhenInUse || [CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined || [CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized)) {
// do nothing _initialPolyline.map = nil;
} else if ([CLLocationManager authorizationStatus] ==kCLAuthorizationStatusDenied) {
//定位不能用 _initialPolyline.strokeColor = [UIColor blueColor];
[AlertControllerTool alertControllerWithTitle:kLocalizedString(@"alert_location_switch") message:kLocalizedString(@"alert_location_service") cancelTitle:kLocalizedString(@"alert_cancel") cancelBlock:^{ _initialPolyline.strokeWidth = 2.f;
} confirm:kLocalizedString(@"alert_setting") confirmBlock:^(id s) {
NSURL * url = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; CLLocationCoordinate2D startCoordinate;
if([[UIApplication sharedApplication] canOpenURL:url]) { CLLocationCoordinate2D endCoordinate;
if (@available(iOS 10.0, *)) { for(int idx = 0; idx < locationArray.count; idx++)
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; {
}else{ ZJLocationModel * model = [locationArray objectAtIndex:idx];
[[UIApplication sharedApplication] openURL:url]; CLLocation *location = [[CLLocation alloc] initWithLatitude:model.latitude longitude:model.longitude];
} // CLLocation *location = [locationArray objectAtIndex:idx];
} CLLocationDegrees latitude = location.coordinate.latitude;
} finishBlock:nil]; CLLocationDegrees longitude = location.coordinate.longitude;
return;
// create our coordinate and add it to the correct spot in the array
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(latitude, longitude);
[_initiallinepath addCoordinate:coordinate];
if (idx == 0) {
startCoordinate = coordinate;
}
if (idx == locationArray.count-1){
endCoordinate = coordinate;
}
} }
MAPointAnnotation *pointAnnotation1 = [[MAPointAnnotation alloc] init]; _initialPolyline.path = _initiallinepath;
pointAnnotation1.coordinate = CLLocationCoordinate2DMake(self.locations.firstObject.latitude, self.locations.firstObject.longitude); _initialPolyline.map = _mapView;
pointAnnotation1.title = @"start";
[self.mapView addAnnotation:pointAnnotation1]; _startMarker.map = nil;
_startMarker = [GMSMarker markerWithPosition:startCoordinate];
_startMarker.appearAnimation = kGMSMarkerAnimationPop;
_startMarker.icon = [UIImage imageNamed:@"map_track_start_icon"];
_startMarker.title = @"start";
_startMarker.map = _mapView;
//构造折线数据对象 _endMarker.map = nil;
CLLocationCoordinate2D commonPolylineCoords[self.locations.count]; _endMarker = [GMSMarker markerWithPosition:endCoordinate];
_endMarker.appearAnimation = kGMSMarkerAnimationPop;
_endMarker.icon = [UIImage imageNamed:@"map_track_end_icon"];
_endMarker.title = @"end";
_endMarker.map = _mapView;
for (int i = 0 ; i < self.locations.count; i++) {
commonPolylineCoords[i].latitude = self.locations[i].latitude; for(int idx = 0; idx < self.initiallinepath.count; idx++){
commonPolylineCoords[i].longitude = self.locations[i].longitude;
} }
MAPointAnnotation *pointAnnotation2 = [[MAPointAnnotation alloc] init]; // self.actionMarker.map = nil;
pointAnnotation2.coordinate = CLLocationCoordinate2DMake(self.locations.lastObject.latitude, self.locations.lastObject.longitude); // self.actionMarker = [GMSMarker markerWithPosition:startCoordinate];
pointAnnotation2.title = @"end"; // self.actionMarker.icon = [UIImage imageNamed:@"map_track_move_icon"];
[self.mapView addAnnotation:pointAnnotation2]; // self.actionMarker.title = @"move";
// self.actionMarker.map = self.mapView;
//构造折线对象
MAPolyline *commonPolyline = [MAPolyline polylineWithCoordinates:commonPolylineCoords count:self.locations.count];
self.commonPolyline = commonPolyline;
// self.commonPolyline.boundingMapRect // [self.actionMarker.layer addSublayer: ];
//在地图上添加折线对象 // [self haha:[self hehe]];
[self.mapView addOverlay: commonPolyline];
int count = sizeof(commonPolylineCoords) / sizeof(commonPolylineCoords[0]); _actionlinepath = [GMSMutablePath path];
self.mapView.centerCoordinate = commonPolylineCoords[count/2]; _count = 0;
double sum = 0;
NSMutableArray *arr = [NSMutableArray arrayWithCapacity:count]; dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0));
for(int i = 0; i < count - 1; ++i) { dispatch_source_set_timer(timer, DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC, 0 * NSEC_PER_SEC);
CLLocation *begin = [[CLLocation alloc] initWithLatitude:commonPolylineCoords[i].latitude longitude:commonPolylineCoords[i].longitude]; dispatch_source_set_event_handler(timer, ^{
CLLocation *end = [[CLLocation alloc] initWithLatitude:commonPolylineCoords[i+1].latitude longitude:commonPolylineCoords[i+1].longitude];
CLLocationDistance distance = [end distanceFromLocation:begin]; if (self.count < self.initiallinepath.count) {
[arr addObject:[NSNumber numberWithDouble:distance]];
sum += distance; CLLocationCoordinate2D coordinate = [self.initiallinepath coordinateAtIndex:self.count];
[self.actionlinepath addCoordinate:coordinate];
self.actionPolyline = [GMSPolyline polylineWithPath:self.actionlinepath];
self.actionPolyline.strokeColor = [UIColor greenColor];
self.actionPolyline.strokeWidth = 2;
// [CATransaction begin];
// [CATransaction setAnimationDuration:0.1];
self.actionPolyline.map = self.mapView;
// [CATransaction commit];
self.count++;
}else{
dispatch_source_cancel(timer);
}
});
dispatch_resume(timer);
}
-(void)addMarkers:(GMSPath *)path{
}
- (CAShapeLayer *)hehe{
UIBezierPath *breizerPath = [UIBezierPath bezierPath];
for(int i = 0; i < self.initiallinepath.count; i++){
CLLocationCoordinate2D coordinate = [self.initiallinepath coordinateAtIndex:i];
[breizerPath addLineToPoint:[_mapView.projection pointForCoordinate:coordinate]];
} }
self.distanceArray = arr; CAShapeLayer *shapeLayer = [CAShapeLayer layer];
self.sumDistance = sum; shapeLayer.path = [[breizerPath bezierPathByReversingPath] CGPath];
shapeLayer.strokeColor = [[UIColor redColor] CGColor];
shapeLayer.lineWidth = 1.0;
shapeLayer.fillColor = [[UIColor redColor] CGColor];
shapeLayer.lineJoin = kCALineJoinRound;
shapeLayer.lineCap = kCALineCapRound;
shapeLayer.cornerRadius = 5;
double speed_car1 = self.sumDistance / 12; //80 km/h return shapeLayer;
// int count1 = sizeof(commonPolylineCoords) / sizeof(commonPolylineCoords[0]); }
[self.track setCoordinate:commonPolylineCoords[0]];
__weak typeof(self) weakSelf = self; - (void)haha:(CAShapeLayer *)layer{
[self.track addMoveAnimationWithKeyCoordinates:commonPolylineCoords count:count withDuration:self.sumDistance / speed_car1 withName:nil completeCallback:^(BOOL isFinished) { CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
[weakSelf.trackTimeView.trackButton setEnabled:true]; pathAnimation.duration = 10;
[weakSelf.trackTimeView.trackButton setSelected:false]; // pathAnimation.delegate = self;
}]; [pathAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
[self.mapView setVisibleMapRect:self.commonPolyline.boundingMapRect edgePadding:UIEdgeInsetsMake(250, 50, 50, 50) animated:true]; pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
pathAnimation.toValue = [NSNumber numberWithFloat:1.0f];
pathAnimation.repeatCount = 100;
[layer addAnimation:pathAnimation forKey:@"strokeEnd"];
[self.mapView.layer addSublayer:layer];
}
-(void)animate:(GMSPath *)path {
// for(int idx = 0; idx < path.count; idx++){
//
// }
dispatch_async(dispatch_get_main_queue(), ^{
if (self.count < path.count) {
[self.actionlinepath addCoordinate:[path coordinateAtIndex:self.count]];
self.actionPolyline = [GMSPolyline polylineWithPath:self.actionlinepath];
self.actionPolyline.strokeColor = [UIColor greenColor];
self.actionPolyline.strokeWidth = 2;
self.actionPolyline.map = self.mapView;
[self.arrayPolylineGreen addObject:self.actionPolyline];
self.count++;
// self.actionMarker.map = nil;
// self.actionMarker = [GMSMarker markerWithPosition:[path coordinateAtIndex:self.count]];
// self.actionMarker.icon = [UIImage imageNamed:@"map_track_move_icon"];
// self.actionMarker.title = @"move";
// self.actionMarker.map = self.mapView;
}else {
self.count = 0;
self.actionMarker.map = nil;
self.actionlinepath = [[GMSMutablePath alloc] init];
for (GMSPolyline *line in self.arrayPolylineGreen) {
line.map = nil;
}
}
});
} }
//- (void) drawLineAction {
//
// if (self.isMyTrack) {
// [MobClick event:@"mytrack_querybutton_click"];
// }else{
// [MobClick event:@"friendtrack_querybutton_click"];
// }
//
// [self.trackTimeView.trackButton setSelected:true];
// [self.trackTimeView.trackButton setEnabled:false];
// //移除
// [self.mapView removeOverlay:self.commonPolyline];
//
// // need get user location info
// if ([CLLocationManager locationServicesEnabled] && ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedWhenInUse || [CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined || [CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized)) {
// // do nothing
// } else if ([CLLocationManager authorizationStatus] ==kCLAuthorizationStatusDenied) {
// //定位不能用
// [AlertControllerTool alertControllerWithTitle:kLocalizedString(@"alert_location_switch") message:kLocalizedString(@"alert_location_service") cancelTitle:kLocalizedString(@"alert_cancel") cancelBlock:^{
// } confirm:kLocalizedString(@"alert_setting") confirmBlock:^(id s) {
// NSURL * url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
// if([[UIApplication sharedApplication] canOpenURL:url]) {
// if (@available(iOS 10.0, *)) {
// [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
// }else{
// [[UIApplication sharedApplication] openURL:url];
// }
// }
// } finishBlock:nil];
// return;
// }
// MAPointAnnotation *pointAnnotation1 = [[MAPointAnnotation alloc] init];
// pointAnnotation1.coordinate = CLLocationCoordinate2DMake(self.locations.firstObject.latitude, self.locations.firstObject.longitude);
// pointAnnotation1.title = @"start";
// [self.mapView addAnnotation:pointAnnotation1];
//
// //构造折线数据对象
// CLLocationCoordinate2D commonPolylineCoords[self.locations.count];
//
// for (int i = 0 ; i < self.locations.count; i++) {
// commonPolylineCoords[i].latitude = self.locations[i].latitude;
// commonPolylineCoords[i].longitude = self.locations[i].longitude;
// }
//
// MAPointAnnotation *pointAnnotation2 = [[MAPointAnnotation alloc] init];
// pointAnnotation2.coordinate = CLLocationCoordinate2DMake(self.locations.lastObject.latitude, self.locations.lastObject.longitude);
// pointAnnotation2.title = @"end";
// [self.mapView addAnnotation:pointAnnotation2];
//
// //构造折线对象
// MAPolyline *commonPolyline = [MAPolyline polylineWithCoordinates:commonPolylineCoords count:self.locations.count];
// self.commonPolyline = commonPolyline;
//// self.commonPolyline.boundingMapRect
// //在地图上添加折线对象
// [self.mapView addOverlay: commonPolyline];
//
// int count = sizeof(commonPolylineCoords) / sizeof(commonPolylineCoords[0]);
// self.mapView.centerCoordinate = commonPolylineCoords[count/2];
// double sum = 0;
// NSMutableArray *arr = [NSMutableArray arrayWithCapacity:count];
// for(int i = 0; i < count - 1; ++i) {
// CLLocation *begin = [[CLLocation alloc] initWithLatitude:commonPolylineCoords[i].latitude longitude:commonPolylineCoords[i].longitude];
// CLLocation *end = [[CLLocation alloc] initWithLatitude:commonPolylineCoords[i+1].latitude longitude:commonPolylineCoords[i+1].longitude];
// CLLocationDistance distance = [end distanceFromLocation:begin];
// [arr addObject:[NSNumber numberWithDouble:distance]];
// sum += distance;
// }
//
// self.distanceArray = arr;
// self.sumDistance = sum;
//
// double speed_car1 = self.sumDistance / 12; //80 km/h
// // int count1 = sizeof(commonPolylineCoords) / sizeof(commonPolylineCoords[0]);
// [self.track setCoordinate:commonPolylineCoords[0]];
// __weak typeof(self) weakSelf = self;
// [self.track addMoveAnimationWithKeyCoordinates:commonPolylineCoords count:count withDuration:self.sumDistance / speed_car1 withName:nil completeCallback:^(BOOL isFinished) {
// [weakSelf.trackTimeView.trackButton setEnabled:true];
// [weakSelf.trackTimeView.trackButton setSelected:false];
// }];
// [self.mapView setVisibleMapRect:self.commonPolyline.boundingMapRect edgePadding:UIEdgeInsetsMake(250, 50, 50, 50) animated:true];
//
//}
- (ZJAlertView *)getAlertView:(NSString *)title subtitle:(NSString *)subtitle leftButtonTitle:(NSString *)leftButtonTitle rightButtonTitle:(NSString *)rightButtonTitle { - (ZJAlertView *)getAlertView:(NSString *)title subtitle:(NSString *)subtitle leftButtonTitle:(NSString *)leftButtonTitle rightButtonTitle:(NSString *)rightButtonTitle {
ZJAlertView* alertView = [[[NSBundle mainBundle]loadNibNamed:@"ZJAlertView" owner:self options:nil]lastObject]; ZJAlertView* alertView = [[[NSBundle mainBundle]loadNibNamed:@"ZJAlertView" owner:self options:nil]lastObject];
alertView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); alertView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
...@@ -372,14 +618,14 @@ ...@@ -372,14 +618,14 @@
if ([ZJUserInfoManager shared].uid.length <= 0) { if ([ZJUserInfoManager shared].uid.length <= 0) {
///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码 ///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码
self.mapView.showsUserLocation = YES; // self.mapView.showsUserLocation = YES;
self.mapView.userTrackingMode = MAUserTrackingModeFollow; // self.mapView.userTrackingMode = MAUserTrackingModeFollow;
return; return;
} }
if ([ZJUserInfoManager shared].token.length <= 0) { if ([ZJUserInfoManager shared].token.length <= 0) {
///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码 ///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码
self.mapView.showsUserLocation = YES; // self.mapView.showsUserLocation = YES;
self.mapView.userTrackingMode = MAUserTrackingModeFollow; // self.mapView.userTrackingMode = MAUserTrackingModeFollow;
return; return;
} }
...@@ -425,7 +671,8 @@ ...@@ -425,7 +671,8 @@
// [MBProgressHUD showMessage:kLocalizedString(@"track_friend_timeWithin_no_location")]; // [MBProgressHUD showMessage:kLocalizedString(@"track_friend_timeWithin_no_location")];
return; return;
} }
[_self drawLineAction]; // [_self drawLineAction];
[_self drawLineWithLocationArray:_self.locations];
}else if ([[response objectForKey:@"status"] integerValue] == 105) { }else if ([[response objectForKey:@"status"] integerValue] == 105) {
[MBProgressHUD showError:[response objectForKey:@"msg"] toView:self.view]; [MBProgressHUD showError:[response objectForKey:@"msg"] toView:self.view];
} }
...@@ -433,7 +680,6 @@ ...@@ -433,7 +680,6 @@
} failure:^(NSError * _Nonnull error) { } failure:^(NSError * _Nonnull error) {
NSLog(@"失败"); NSLog(@"失败");
}]; }];
} }
#pragma mark 获取最后一次位置 #pragma mark 获取最后一次位置
...@@ -442,8 +688,8 @@ ...@@ -442,8 +688,8 @@
NSLog(@"%@", [ZJUserInfoManager shared].uid); NSLog(@"%@", [ZJUserInfoManager shared].uid);
if ([ZJUserInfoManager shared].uid.length <= 0 || ![ZJUserInfoManager shared].isMember) { if ([ZJUserInfoManager shared].uid.length <= 0 || ![ZJUserInfoManager shared].isMember) {
///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码 ///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码
self.mapView.showsUserLocation = YES; // self.mapView.showsUserLocation = YES;
self.mapView.userTrackingMode = MAUserTrackingModeFollow; // self.mapView.userTrackingMode = MAUserTrackingModeFollow;
return; return;
} }
__weak typeof(self) _self = self; __weak typeof(self) _self = self;
...@@ -451,8 +697,8 @@ ...@@ -451,8 +697,8 @@
NSString *uid = self.model.friendUid; NSString *uid = self.model.friendUid;
if (uid.length <= 0) { if (uid.length <= 0) {
///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码 ///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码
self.mapView.showsUserLocation = YES; // self.mapView.showsUserLocation = YES;
self.mapView.userTrackingMode = MAUserTrackingModeFollow; // self.mapView.userTrackingMode = MAUserTrackingModeFollow;
uid = [ZJUserInfoManager shared].uid; uid = [ZJUserInfoManager shared].uid;
} }
[[TQNetworkTools shared] getWithAction:getLocationDataLast parameters:@{@"tid": uid} success:^(id _Nonnull response) { [[TQNetworkTools shared] getWithAction:getLocationDataLast parameters:@{@"tid": uid} success:^(id _Nonnull response) {
...@@ -470,8 +716,8 @@ ...@@ -470,8 +716,8 @@
MAPointAnnotation *pointAnnotation = [[MAPointAnnotation alloc] init]; MAPointAnnotation *pointAnnotation = [[MAPointAnnotation alloc] init];
pointAnnotation.coordinate = CLLocationCoordinate2DMake(lat, lon); pointAnnotation.coordinate = CLLocationCoordinate2DMake(lat, lon);
pointAnnotation.title = @"latestLocation"; pointAnnotation.title = @"latestLocation";
[_self.mapView addAnnotation:pointAnnotation]; // [_self.mapView addAnnotation:pointAnnotation];
[_self.mapView setCenterCoordinate:pointAnnotation.coordinate animated:false]; // [_self.mapView setCenterCoordinate:pointAnnotation.coordinate animated:false];
}else if ([[response objectForKey:@"status"] integerValue] == 105) { }else if ([[response objectForKey:@"status"] integerValue] == 105) {
[MBProgressHUD showError:[response objectForKey:@"msg"] toView:self.view]; [MBProgressHUD showError:[response objectForKey:@"msg"] toView:self.view];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment