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

track gmsmap mamap

parent c4c6f713
No preview for this file type
...@@ -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
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
</BuildableReference> </BuildableReference>
</BuildableProductRunnable> </BuildableProductRunnable>
<LocationScenarioReference <LocationScenarioReference
identifier = "Hong Kong, China" identifier = "London, England"
referenceType = "1"> referenceType = "1">
</LocationScenarioReference> </LocationScenarioReference>
</LaunchAction> </LaunchAction>
......
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
// Copyright © 2020 Company. All rights reserved. // Copyright © 2020 Company. All rights reserved.
// //
#import <UIKit/UIKit.h> #import "BaseViewController.h"
#import "ZJFriendModel.h" #import "ZJFriendModel.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@interface ZJFriendTrackMapViewController : UIViewController @interface ZJFriendTrackMapViewController : BaseViewController
@property (nonatomic, strong) ZJFriendModel * model; @property (nonatomic, strong) ZJFriendModel * model;
@property (nonatomic, assign) BOOL autoTrack; @property (nonatomic, assign) BOOL autoTrack;
......
...@@ -100,10 +100,11 @@ ...@@ -100,10 +100,11 @@
self.refershMyself = YES; self.refershMyself = YES;
[[ZJLocationManager shared] initWithLocationUpdateInfo:^(ZJLocationModel * model, CLLocation * location, ZJMapType mapType) { [[ZJLocationManager shared] initWithLocationUpdateInfo:^(ZJLocationModel * model, CLLocation * location, ZJMapType mapType) {
if(!model){
return;
}
self.mapType = mapType; self.mapType = mapType;
// if(!model){
// return;
// }
// //
// CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(model.latitude, model.longitude); // CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(model.latitude, model.longitude);
// //
...@@ -183,7 +184,7 @@ ...@@ -183,7 +184,7 @@
- (void)setupUI { - (void)setupUI {
_zoom = 18; _zoom = 18;
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:+40.75921100 longitude:-73.98463800 zoom:_zoom]; GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:[[[self.data Read] objectForKey:@"latitude"] doubleValue] longitude:[[[self.data Read] objectForKey:@"longitude"] doubleValue] zoom:_zoom];
///初始化地图 ///初始化地图
self.GGMapView = [GMSMapView mapWithFrame:self.view.bounds camera:camera]; self.GGMapView = [GMSMapView mapWithFrame:self.view.bounds camera:camera];
_GGMapView.delegate = self; _GGMapView.delegate = self;
...@@ -209,12 +210,14 @@ ...@@ -209,12 +210,14 @@
self.track.title = @"pointReuseIndetifier1"; self.track.title = @"pointReuseIndetifier1";
[_GDMapView addAnnotation:self.track]; [_GDMapView addAnnotation:self.track];
self.mapType = [[[self.data Read] objectForKey:@"mapType"] intValue];
// 添加 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];
[self.view addSubview: _trackTimeView]; [self.view addSubview: _trackTimeView];
[_trackTimeView mas_makeConstraints:^(MASConstraintMaker *make) { [_trackTimeView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self.view); make.left.right.equalTo(self.view);
make.top.mas_equalTo(kNavigationBarHeight);//..offset(10); make.top.mas_equalTo(10);//..offset(10);
make.height.equalTo(@130); make.height.equalTo(@130);
}]; }];
...@@ -264,15 +267,25 @@ ...@@ -264,15 +267,25 @@
NSString *endTimeString = [NSString stringWithFormat:@"%.0f", endTimeInterval]; NSString *endTimeString = [NSString stringWithFormat:@"%.0f", endTimeInterval];
if ([ZJUserInfoManager shared].uid.length <= 0) { if ([ZJUserInfoManager shared].uid.length <= 0) {
if (self.mapType == ZJ_GMSMapType){
CLLocationCoordinate2D coord = CLLocationCoordinate2DMake([[[self.data Read] objectForKey:@"latitude"] doubleValue], [[[self.data Read] objectForKey:@"longitude"] doubleValue]);
[self setPoint:coord target:1];
}else{
///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码 ///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码
self.GDMapView.showsUserLocation = YES; self.GDMapView.showsUserLocation = YES;
self.GDMapView.userTrackingMode = MAUserTrackingModeFollow; self.GDMapView.userTrackingMode = MAUserTrackingModeFollow;
}
return; return;
} }
if ([ZJUserInfoManager shared].token.length <= 0) { if ([ZJUserInfoManager shared].token.length <= 0) {
if (self.mapType == ZJ_GMSMapType){
CLLocationCoordinate2D coord = CLLocationCoordinate2DMake([[[self.data Read] objectForKey:@"latitude"] doubleValue], [[[self.data Read] objectForKey:@"longitude"] doubleValue]);
[self setPoint:coord target:1];
}else{
///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码 ///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码
self.GDMapView.showsUserLocation = YES; self.GDMapView.showsUserLocation = YES;
self.GDMapView.userTrackingMode = MAUserTrackingModeFollow; self.GDMapView.userTrackingMode = MAUserTrackingModeFollow;
}
return; return;
} }
...@@ -318,8 +331,13 @@ ...@@ -318,8 +331,13 @@
// [MBProgressHUD showMessage:kLocalizedString(@"track_friend_timeWithin_no_location")]; // [MBProgressHUD showMessage:kLocalizedString(@"track_friend_timeWithin_no_location")];
return; return;
} }
[_self drawLineAction];
if (self.mapType == ZJ_GMSMapType){
[_self drawLineWithLocationArray:_self.locations]; [_self drawLineWithLocationArray:_self.locations];
}else{
[_self drawLineAction];
}
}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];
} }
...@@ -334,18 +352,29 @@ ...@@ -334,18 +352,29 @@
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) {
if (self.mapType == ZJ_GMSMapType){
CLLocationCoordinate2D coord = CLLocationCoordinate2DMake([[[self.data Read] objectForKey:@"latitude"] doubleValue], [[[self.data Read] objectForKey:@"longitude"] doubleValue]);
[self setPoint:coord target:1];
}else{
///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码 ///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码
self.GDMapView.showsUserLocation = YES; self.GDMapView.showsUserLocation = YES;
self.GDMapView.userTrackingMode = MAUserTrackingModeFollow; self.GDMapView.userTrackingMode = MAUserTrackingModeFollow;
}
return; return;
} }
__weak typeof(self) _self = self; __weak typeof(self) _self = self;
NSString *uid = self.model.friendUid; NSString *uid = self.model.friendUid;
if (uid.length <= 0) { if (uid.length <= 0) {
if (self.mapType == ZJ_GMSMapType){
CLLocationCoordinate2D coord = CLLocationCoordinate2DMake([[[self.data Read] objectForKey:@"latitude"] doubleValue], [[[self.data Read] objectForKey:@"longitude"] doubleValue]);
[self setPoint:coord target:1];
}else{
///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码 ///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码
self.GDMapView.showsUserLocation = YES; self.GDMapView.showsUserLocation = YES;
self.GDMapView.userTrackingMode = MAUserTrackingModeFollow; self.GDMapView.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) {
...@@ -361,20 +390,20 @@ ...@@ -361,20 +390,20 @@
double lat = [response[@"result"][@"data"][@"lat"] doubleValue]; double lat = [response[@"result"][@"data"][@"lat"] doubleValue];
double lon = [response[@"result"][@"data"][@"lon"] doubleValue]; double lon = [response[@"result"][@"data"][@"lon"] doubleValue];
MAPointAnnotation *pointAnnotation = [[MAPointAnnotation alloc] init]; if (self.mapType == ZJ_GMSMapType){
pointAnnotation.coordinate = CLLocationCoordinate2DMake(lat, lon);
pointAnnotation.title = @"latestLocation";
[_self.GDMapView addAnnotation:pointAnnotation];
[_self.GDMapView setCenterCoordinate:pointAnnotation.coordinate animated:false];
CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(lat, lon); CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(lat, lon);
if (self.refershMyself) { if (self.refershMyself) {
self.GGMapView.camera = [GMSCameraPosition cameraWithTarget:coord zoom:self.zoom]; self.GGMapView.camera = [GMSCameraPosition cameraWithTarget:coord zoom:self.zoom];
self.refershMyself = NO; self.refershMyself = NO;
} }
[self setPoint:coord target:1]; [self setPoint:coord target:1];
}else{
MAPointAnnotation *pointAnnotation = [[MAPointAnnotation alloc] init];
pointAnnotation.coordinate = CLLocationCoordinate2DMake(lat, lon);
pointAnnotation.title = @"latestLocation";
[_self.GDMapView addAnnotation:pointAnnotation];
[_self.GDMapView 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];
...@@ -542,7 +571,7 @@ ...@@ -542,7 +571,7 @@
_selfMarker.infoWindowAnchor = CGPointMake(0.5, 0.25); _selfMarker.infoWindowAnchor = CGPointMake(0.5, 0.25);
_selfMarker.map = _GGMapView; _selfMarker.map = _GGMapView;
CLLocationDistance distance = 100; CLLocationDistance distance = 50;
_selfCircle.map = nil; _selfCircle.map = nil;
_selfCircle = [GMSCircle circleWithPosition:position radius:distance]; _selfCircle = [GMSCircle circleWithPosition:position radius:distance];
_selfCircle.fillColor = [kColorWithRGBA(86, 142, 252, 0.15) colorWithAlphaComponent:0.5]; _selfCircle.fillColor = [kColorWithRGBA(86, 142, 252, 0.15) colorWithAlphaComponent:0.5];
...@@ -626,8 +655,11 @@ ...@@ -626,8 +655,11 @@
_actionlinepath = [GMSMutablePath path]; _actionlinepath = [GMSMutablePath path];
__block NSInteger count = 0; __block NSInteger count = 0;
[self.trackTimeView.trackButton setSelected:true];
[self.trackTimeView.trackButton setEnabled:false];
dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)); dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0));
dispatch_source_set_timer(timer, DISPATCH_TIME_NOW, 0.16 * NSEC_PER_SEC, 0 * NSEC_PER_SEC); dispatch_source_set_timer(timer, DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC, 0 * NSEC_PER_SEC);
dispatch_source_set_event_handler(timer, ^{ dispatch_source_set_event_handler(timer, ^{
if (count < self.initiallinepath.count) { if (count < self.initiallinepath.count) {
...@@ -635,15 +667,15 @@ ...@@ -635,15 +667,15 @@
CLLocationCoordinate2D coordinate = [self.initiallinepath coordinateAtIndex:count]; CLLocationCoordinate2D coordinate = [self.initiallinepath coordinateAtIndex:count];
[self.actionlinepath addCoordinate:coordinate]; [self.actionlinepath addCoordinate:coordinate];
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:coordinate.latitude longitude:coordinate.longitude zoom:20];
self.actionPolyline = [GMSPolyline polylineWithPath:self.actionlinepath]; self.actionPolyline = [GMSPolyline polylineWithPath:self.actionlinepath];
self.actionPolyline.strokeColor = [UIColor greenColor]; self.actionPolyline.strokeColor = [UIColor greenColor];
self.actionPolyline.strokeWidth = 2; self.actionPolyline.strokeWidth = 2;
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:coordinate.latitude longitude:coordinate.longitude zoom:20];
[CATransaction begin]; [CATransaction begin];
[CATransaction setAnimationDuration:0.15]; [CATransaction setAnimationDuration:0.19];
self.actionMarker.position = coordinate; self.actionMarker.position = coordinate;
// self.actionMarker.rotation = location.course // self.actionMarker.rotation = location.course
[self.GGMapView animateToCameraPosition:camera]; [self.GGMapView animateToCameraPosition:camera];
...@@ -651,6 +683,13 @@ ...@@ -651,6 +683,13 @@
[CATransaction commit]; [CATransaction commit];
count++; count++;
}else{ }else{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
dispatch_async(dispatch_get_main_queue(), ^{
[self.trackTimeView.trackButton setEnabled:true];
[self.trackTimeView.trackButton setSelected:false];
});
});
dispatch_source_cancel(timer); dispatch_source_cancel(timer);
} }
}); });
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
typedef enum : NSUInteger { typedef enum : NSUInteger {
ZJ_GMSMapType, ZJ_GMSMapType = 1,
ZJ_MAMapType ZJ_MAMapType
} ZJMapType; } ZJMapType;
......
...@@ -134,11 +134,13 @@ static ZJLocationManager * manager; ...@@ -134,11 +134,13 @@ static ZJLocationManager * manager;
}else if (error == nil && [placemarks count] == 0) { }else if (error == nil && [placemarks count] == 0) {
NSLog(@"No results were returned."); NSLog(@"No results were returned.");
[self.data WirteDic:@(ZJ_GMSMapType) Key:@"mapType"];
if (self.callBack) { if (self.callBack) {
self.callBack(nil, nil, ZJ_GMSMapType); self.callBack(nil, nil, ZJ_GMSMapType);
} }
} else if (error != nil){ } else if (error != nil){
NSLog(@"An error occurred = %@", error); NSLog(@"An error occurred = %@", error);
[self.data WirteDic:@(ZJ_GMSMapType) Key:@"mapType"];
if (self.callBack) { if (self.callBack) {
self.callBack(nil, nil, ZJ_GMSMapType); self.callBack(nil, nil, ZJ_GMSMapType);
} }
...@@ -169,6 +171,10 @@ static ZJLocationManager * manager; ...@@ -169,6 +171,10 @@ static ZJLocationManager * manager;
isChina = [placemark.ISOcountryCode isEqualToString:@"CN"]; isChina = [placemark.ISOcountryCode isEqualToString:@"CN"];
_mapType = isChina ? ZJ_MAMapType : ZJ_GMSMapType; _mapType = isChina ? ZJ_MAMapType : ZJ_GMSMapType;
[self.data WirteDic:@(_mapType) Key:@"mapType"];
[self.data WirteDic:@(coord.latitude) Key:@"latitude"];
[self.data WirteDic:@(coord.longitude) Key:@"longitude"];
if (_callBack) { if (_callBack) {
_callBack(model, location, _mapType); _callBack(model, location, _mapType);
} }
......
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