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