Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
Z
ZhiJi-Overseas
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lmj
ZhiJi-Overseas
Commits
e3d8716d
Commit
e3d8716d
authored
Jul 27, 2020
by
lmj_521aiau@163.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
5a276689
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
309 additions
and
216 deletions
+309
-216
project.pbxproj
ZhiJi.xcodeproj/project.pbxproj
+16
-10
ZJCustomAnnotation.h
ZhiJi/Classes/Map/Controller/ZJCustomAnnotation.h
+22
-0
ZJCustomAnnotation.m
ZhiJi/Classes/Map/Controller/ZJCustomAnnotation.m
+13
-0
ZJFriendTrackMapViewController.m
...i/Classes/Map/Controller/ZJFriendTrackMapViewController.m
+252
-200
ResourceHeader.pch
ZhiJi/Classes/Tools/PCH/ResourceHeader.pch
+6
-6
No files found.
ZhiJi.xcodeproj/project.pbxproj
View file @
e3d8716d
...
...
@@ -157,6 +157,7 @@
A96696E424AF5E7700CF6992
/* AMap.bundle in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
A96696E324AF5E7700CF6992
/* AMap.bundle */
;
};
A9764A522490EAC600463B78
/* CoreGraphics.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
A9764A512490EAC600463B78
/* CoreGraphics.framework */
;
};
A9764A5C2492380D00463B78
/* ZJImagePickerManager.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
A9764A5B2492380D00463B78
/* ZJImagePickerManager.m */
;
};
A9C2B61F24CEC0DC00010EAE
/* ZJCustomAnnotation.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
A9C2B61E24CEC0DC00010EAE
/* ZJCustomAnnotation.m */
;
};
A9F91E28249CCA4B006157BF
/* ZJUpgradeAlertView.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
A9F91E27249CCA4B006157BF
/* ZJUpgradeAlertView.m */
;
};
A9F91E3E249DFC53006157BF
/* BaseWebViewController.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
A9F91E3D249DFC53006157BF
/* BaseWebViewController.m */
;
};
D5167D5B2490C87400A79CB6
/* ZJSheZhiView.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
D5167D592490C87400A79CB6
/* ZJSheZhiView.m */
;
};
...
...
@@ -467,6 +468,8 @@
A9764A5A2492380D00463B78
/* ZJImagePickerManager.h */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
ZJImagePickerManager.h
;
sourceTree
=
"<group>"
;
};
A9764A5B2492380D00463B78
/* ZJImagePickerManager.m */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
ZJImagePickerManager.m
;
sourceTree
=
"<group>"
;
};
A9850D6E2490B9F500810B7D
/* PrefixHeader.pch */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
name
=
PrefixHeader.pch
;
path
=
ZhiJi/Classes/Tools/PCH/PrefixHeader.pch
;
sourceTree
=
SOURCE_ROOT
;
};
A9C2B61D24CEC0DC00010EAE
/* ZJCustomAnnotation.h */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
ZJCustomAnnotation.h
;
sourceTree
=
"<group>"
;
};
A9C2B61E24CEC0DC00010EAE
/* ZJCustomAnnotation.m */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
ZJCustomAnnotation.m
;
sourceTree
=
"<group>"
;
};
A9F91E26249CCA4B006157BF
/* ZJUpgradeAlertView.h */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
ZJUpgradeAlertView.h
;
sourceTree
=
"<group>"
;
};
A9F91E27249CCA4B006157BF
/* ZJUpgradeAlertView.m */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
ZJUpgradeAlertView.m
;
sourceTree
=
"<group>"
;
};
A9F91E3C249DFC53006157BF
/* BaseWebViewController.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
BaseWebViewController.h
;
sourceTree
=
"<group>"
;
};
...
...
@@ -1027,6 +1030,8 @@
A9619E7F24AAE2A8009A2012
/* ZJMapStyle2ViewController.m */
,
64F52440248F34DB0032BCA2
/* ZJFriendTrackMapViewController.h */
,
64F52441248F34DB0032BCA2
/* ZJFriendTrackMapViewController.m */
,
A9C2B61D24CEC0DC00010EAE
/* ZJCustomAnnotation.h */
,
A9C2B61E24CEC0DC00010EAE
/* ZJCustomAnnotation.m */
,
);
path
=
Controller
;
sourceTree
=
"<group>"
;
...
...
@@ -1582,6 +1587,7 @@
6453732124978FF800FD4C07
/* SJLabelSlider.m in Sources */
,
A95F5C73248DDE81001DB97E
/* ZJJinJiViewController.m in Sources */
,
A95F5C59248DDE81001DB97E
/* NSArray+Category.m in Sources */
,
A9C2B61F24CEC0DC00010EAE
/* ZJCustomAnnotation.m in Sources */
,
647F2DE2249CB37E00C696E0
/* JZLocationConverter.m in Sources */
,
A95F5CC62490A37F001DB97E
/* UILabel+FontAppearance.m in Sources */
,
A948C4C82497122B00C22D69
/* ZJUserTrackTimeView.m in Sources */
,
...
...
@@ -1762,10 +1768,10 @@
ASSETCATALOG_COMPILER_APPICON_NAME
=
AppIcon
;
CLANG_ENABLE_MODULES
=
YES
;
CODE_SIGN_ENTITLEMENTS
=
ZhiJi/ZhiJi.entitlements
;
CODE_SIGN_IDENTITY
=
"
iPhone Developer
"
;
CODE_SIGN_STYLE
=
Manual
;
CODE_SIGN_IDENTITY
=
"
Apple Development
"
;
CODE_SIGN_STYLE
=
Automatic
;
CURRENT_PROJECT_VERSION
=
100
;
DEVELOPMENT_TEAM
=
KQ4CS767WC
;
DEVELOPMENT_TEAM
=
3VFFTBZ496
;
FRAMEWORK_SEARCH_PATHS
=
(
"$(inherited)"
,
"$(PROJECT_DIR)/ZhiJi/Classes/Tools"
,
...
...
@@ -1842,9 +1848,9 @@
"-ObjC"
,
"-all_load"
,
);
PRODUCT_BUNDLE_IDENTIFIER
=
com.app.familymapp
;
PRODUCT_BUNDLE_IDENTIFIER
=
com.
ishin
app.familymapp
;
PRODUCT_NAME
=
"Family Mapp"
;
PROVISIONING_PROFILE_SPECIFIER
=
family_map_develop
;
PROVISIONING_PROFILE_SPECIFIER
=
""
;
SWIFT_OBJC_BRIDGING_HEADER
=
"$(SRCROOT)/ZhiJi/Classes/Main/Base/ZhiJi-Bridging-Header.h"
;
SWIFT_OBJC_INTERFACE_HEADER_NAME
=
"ZhiJi-Swift.h"
;
SWIFT_OPTIMIZATION_LEVEL
=
"-Onone"
;
...
...
@@ -1860,12 +1866,12 @@
ASSETCATALOG_COMPILER_APPICON_NAME
=
AppIcon
;
CLANG_ENABLE_MODULES
=
YES
;
CODE_SIGN_ENTITLEMENTS
=
ZhiJi/ZhiJi.entitlements
;
CODE_SIGN_IDENTITY
=
"
iPhone Developer
"
;
CODE_SIGN_STYLE
=
Manual
;
CODE_SIGN_IDENTITY
=
"
Apple Development
"
;
CODE_SIGN_STYLE
=
Automatic
;
CURRENT_PROJECT_VERSION
=
100
;
DEBUG_INFORMATION_FORMAT
=
dwarf
;
DEFINES_MODULE
=
YES
;
DEVELOPMENT_TEAM
=
KQ4CS767WC
;
DEVELOPMENT_TEAM
=
3VFFTBZ496
;
FRAMEWORK_SEARCH_PATHS
=
(
"$(inherited)"
,
"$(PROJECT_DIR)/ZhiJi/Classes/Tools"
,
...
...
@@ -1942,9 +1948,9 @@
"-ObjC"
,
"-all_load"
,
);
PRODUCT_BUNDLE_IDENTIFIER
=
com.app.familymapp
;
PRODUCT_BUNDLE_IDENTIFIER
=
com.
ishin
app.familymapp
;
PRODUCT_NAME
=
"Family Mapp"
;
PROVISIONING_PROFILE_SPECIFIER
=
family_map_develop
;
PROVISIONING_PROFILE_SPECIFIER
=
""
;
SWIFT_OBJC_BRIDGING_HEADER
=
"$(SRCROOT)/ZhiJi/Classes/Main/Base/ZhiJi-Bridging-Header.h"
;
SWIFT_OBJC_INTERFACE_HEADER_NAME
=
"ZhiJi-Swift.h"
;
SWIFT_VERSION
=
5.0
;
...
...
ZhiJi/Classes/Map/Controller/ZJCustomAnnotation.h
0 → 100644
View file @
e3d8716d
//
// ZJCustomAnnotation.h
// ZhiJi
//
// Created by 明津李 on 2020/7/27.
// Copyright © 2020 Company. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface
ZJCustomAnnotation
:
NSObject
<
MKAnnotation
>
@property
(
nonatomic
)
CLLocationCoordinate2D
coordinate
;
@property
(
nonatomic
,
copy
)
NSString
*
title
;
@property
(
nonatomic
,
copy
)
NSString
*
subtitle
;
@end
NS_ASSUME_NONNULL_END
ZhiJi/Classes/Map/Controller/ZJCustomAnnotation.m
0 → 100644
View file @
e3d8716d
//
// ZJCustomAnnotation.m
// ZhiJi
//
// Created by 明津李 on 2020/7/27.
// Copyright © 2020 Company. All rights reserved.
//
#import "ZJCustomAnnotation.h"
@implementation
ZJCustomAnnotation
@end
ZhiJi/Classes/Map/Controller/ZJFriendTrackMapViewController.m
View file @
e3d8716d
...
...
@@ -19,30 +19,40 @@
#import <CoreLocation/CoreLocation.h>
#import "BaseWebViewController.h"
#import <MapKit/MapKit.h>
#import "ZJCustomAnnotation.h"
@interface
ZJFriendTrackMapViewController
()
<
MAMapViewDelegate
,
MKMapViewDelegate
,
CAAnimationDelegate
>
@interface
ZJFriendTrackMapViewController
()
<
MAMapViewDelegate
,
MKMapViewDelegate
,
CAAnimationDelegate
>
{
float
*
hues
;
float
*
velocity
;
ZJCustomAnnotation
*
startAnnotation
;
UIView
*
container
;
}
@property
(
nonatomic
,
strong
)
MKMapView
*
mapView
;
//@property (nonatomic, strong) MAMapView *mapView;
@property
(
nonatomic
,
strong
)
UIButton
*
gpsButton
;
@property
(
nonatomic
,
strong
)
ZJUserTrackTimeView
*
trackTimeView
;
@property
(
nonatomic
,
strong
)
NSMutableArray
<
ZJLocationModel
*>
*
locations
;
@property
(
strong
,
nonatomic
)
NSDate
*
stratDate
;
@property
(
strong
,
nonatomic
)
NSDate
*
endDate
;
@property
(
nonatomic
,
strong
)
MKMapView
*
mapView
;
@property
(
nonatomic
,
strong
)
NSMutableArray
<
ZJLocationModel
*>
*
locations
;
///全轨迹overlay
@property
(
strong
,
nonatomic
)
MKPolyline
*
commonPolyline
;
///车头方向跟随转动
@property
(
nonatomic
,
strong
)
MAAnimatedAnnotation
*
track
;
@property
(
nonatomic
,
strong
)
NSArray
*
distanceArray
;
@property
(
nonatomic
,
assign
)
double
sumDistance
;
@property
(
nonatomic
,
strong
)
ZJAlertView
*
alertView
;
@property
(
nonatomic
,
strong
)
ZJAlertView
*
alertView
;
@property
(
nonatomic
,
strong
)
CAShapeLayer
*
shapeLayer
;
@property
(
nonatomic
,
assign
)
NSInteger
smoothTrackCount
;
@property
(
nonatomic
,
assign
)
BOOL
trackAnimation
;
@property
(
nonatomic
,
assign
)
CLLocationCoordinate2D
*
smoothTrackPoints
;
@property
(
nonatomic
,
strong
)
CALayer
*
gradientLayer
;
@property
(
nonatomic
,
strong
)
NSMutableArray
*
gradientColors
;
/**
大头针 - 移动的大头针视图
*/
@property
(
nonatomic
,
weak
)
MKAnnotationView
*
annotationView
;
@end
...
...
@@ -123,39 +133,22 @@
}];
}
-
(
void
)
mapView
:
(
MKMapView
*
)
mapView
regionDidChangeAnimated
:
(
BOOL
)
animated
{
if
(
animated
){
CAAnimation
*
shapeLayerAnimation
=
[
self
constructShapeLayerAnimation
];
shapeLayerAnimation
.
delegate
=
self
;
shapeLayerAnimation
.
removedOnCompletion
=
NO
;
shapeLayerAnimation
.
fillMode
=
kCAFillModeForwards
;
[
self
.
shapeLayer
addAnimation
:
shapeLayerAnimation
forKey
:
@"shape"
];
[
self
.
mapView
.
layer
addSublayer
:
self
.
shapeLayer
];
}
}
-
(
void
)
setupUI
{
///初始化地图
// self.mapView = [[MAMapView alloc] initWithFrame:self.view.bounds];
self
.
mapView
=
[[
MKMapView
alloc
]
initWithFrame
:
self
.
view
.
bounds
];
///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码
_mapView
.
showsUserLocation
=
YES
;
_mapView
.
delegate
=
self
;
_mapView
.
showsScale
=
false
;
_mapView
.
showsCompass
=
false
;
_mapView
.
autoresizingMask
=
UIViewAutoresizingFlexibleWidth
|
UIViewAutoresizingFlexibleHeight
;
///把地图添加至view
[
self
.
view
addSubview
:
_mapView
];
MKCircle
*
transparentCircle
=
[
MKCircle
circleWithCenterCoordinate
:
CLLocationCoordinate2DMake
(
39
.
905
,
116
.
398
)
radius
:
100000000
];
[
self
.
mapView
addOverlay
:
transparentCircle
level
:
1
];
///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码
_mapView
.
showsUserLocation
=
false
;
_mapView
.
delegate
=
self
;
// _mapView.zoomLevel = 14;
_mapView
.
showsScale
=
false
;
_mapView
.
showsCompass
=
false
;
// 添加 card view
self
.
trackTimeView
=
[[[
NSBundle
mainBundle
]
loadNibNamed
:
@"ZJUserTrackTimeView"
owner
:
self
options
:
nil
]
lastObject
];
[
self
.
view
addSubview
:
_trackTimeView
];
...
...
@@ -182,12 +175,29 @@
weakSelf
.
stratDate
=
beginDate
;
weakSelf
.
endDate
=
endDate
;
};
startAnnotation
=
[[
ZJCustomAnnotation
alloc
]
init
];
[
_mapView
addAnnotation
:
startAnnotation
];
}
-
(
void
)
drawLineAction1
{
self
.
track
=
[[
MAAnimatedAnnotation
alloc
]
init
];
self
.
track
.
title
=
@"pointReuseIndetifier1"
;
// self.track = [[MKPointAnnotation alloc] init];
// self.track.title = @"pointReuseIndetifier1";
[
self
.
mapView
addAnnotation
:(
id
<
MKAnnotation
>
)
self
.
track
];
_smoothTrackCount
=
_locations
.
count
;
_smoothTrackPoints
=
malloc
(
sizeof
(
CLLocationCoordinate2D
)
*
_smoothTrackCount
);
velocity
=
malloc
(
sizeof
(
float
)
*
_smoothTrackCount
);
for
(
int
i
=
0
;
i
<
_smoothTrackCount
;
i
++
){
@autoreleasepool
{
ZJLocationModel
*
model
=
[
self
.
locations
objectAtIndex
:
i
];
CLLocationDegrees
latitude
=
model
.
latitude
;
CLLocationDegrees
longitude
=
model
.
longitude
;
CLLocationCoordinate2D
coordinate
=
CLLocationCoordinate2DMake
(
latitude
,
longitude
);
// velocity[i] = [dic[@"speed"] doubleValue];
velocity
[
i
]
=
0
.
1
;
_smoothTrackPoints
[
i
]
=
coordinate
;
}
}
_trackAnimation
=
YES
;
}
-
(
void
)
drawLineAction
{
...
...
@@ -195,46 +205,26 @@
[
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:@"打开定位开关" 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
:(
id
<
MKAnnotation
>
)
pointAnnotation1
];
// MAPointAnnotation *pointAnnotation1 = [[MAPointAnnotation alloc] init];
// pointAnnotation1.coordinate = CLLocationCoordinate2DMake(self.locations.firstObject.latitude, self.locations.firstObject.longitude);
// pointAnnotation1.title = @"start";
// [self.mapView addAnnotation:(id<MKAnnotation>)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
:(
id
<
MKAnnotation
>
)
pointAnnotation2
];
//
MAPointAnnotation *pointAnnotation2 = [[MAPointAnnotation alloc] init];
//
pointAnnotation2.coordinate = CLLocationCoordinate2DMake(self.locations.lastObject.latitude, self.locations.lastObject.longitude);
//
pointAnnotation2.title = @"end";
//
[self.mapView addAnnotation:(id<MKAnnotation>)pointAnnotation2];
//构造折线对象
// MAPolyline *commonPolyline = [MAPolyline polylineWithCoordinates:commonPolylineCoords count:self.locations.count];
// self.commonPolyline = commonPolyline;
MKPolyline
*
commonPolyline
=
[
MKPolyline
polylineWithCoordinates
:
commonPolylineCoords
count
:
self
.
locations
.
count
];
self
.
commonPolyline
=
commonPolyline
;
...
...
@@ -253,88 +243,76 @@
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];
// }];
MKMapRect
rect
=
MKMapRectMake
(
self
.
commonPolyline
.
boundingMapRect
.
origin
.
x
,
self
.
commonPolyline
.
boundingMapRect
.
origin
.
y
,
self
.
commonPolyline
.
boundingMapRect
.
size
.
width
,
self
.
commonPolyline
.
boundingMapRect
.
size
.
height
);
[
self
.
mapView
setVisibleMapRect
:
rect
edgePadding
:
UIEdgeInsetsMake
(
250
,
50
,
50
,
50
)
animated
:
true
];
//
CGPoint
*
points
=
[
self
pointsForCoordinates
:
commonPolylineCoords
count
:
count
];
CGPathRef
path
=
[
self
pathForPoints
:
points
count
:
count
];
[
self
initShapeLayerWithPath
:
path
];
// self.shapeLayer.frame = self.mapView.bounds;
// CAAnimation *shapeLayerAnimation = [self constructShapeLayerAnimation];
// shapeLayerAnimation.delegate = self;
// shapeLayerAnimation.removedOnCompletion = NO;
// shapeLayerAnimation.fillMode = kCAFillModeForwards;
//
// [self.shapeLayer addAnimation:shapeLayerAnimation forKey:@"shape"];
//
// [self.mapView.layer addSublayer:self.shapeLayer];
}
-
(
ZJAlertView
*
)
getAlertView
:
(
NSString
*
)
title
subtitle
:
(
NSString
*
)
subtitle
leftButtonTitle
:
(
NSString
*
)
leftButtonTitle
rightButtonTitle
:
(
NSString
*
)
rightButtonTitle
{
ZJAlertView
*
alertView
=
[[[
NSBundle
mainBundle
]
loadNibNamed
:
@"ZJAlertView"
owner
:
self
options
:
nil
]
lastObject
];
alertView
.
frame
=
CGRectMake
(
0
,
0
,
SCREEN_WIDTH
,
SCREEN_HEIGHT
);
alertView
.
alertTitle
.
text
=
title
;
alertView
.
alertSubtitle
.
text
=
subtitle
;
[
alertView
.
leftButton
setTitle
:
leftButtonTitle
forState
:
UIControlStateNormal
];
[
alertView
.
rightButton
setTitle
:
rightButtonTitle
forState
:
UIControlStateNormal
];
alertView
.
backgroundColor
=
[
UIColor
colorWithHex
:
000000
alpha
:
0
.
5
];
__weak
typeof
(
alertView
)
weakAlertView
=
alertView
;
[
alertView
addTapBlock
:
^
(
UITapGestureRecognizer
*
tap
)
{
[
weakAlertView
removeFromSuperview
];
}];
UIView
*
window
=
[
UIApplication
sharedApplication
].
keyWindow
.
rootViewController
.
view
;
[
window
addSubview
:
alertView
];
return
alertView
;
}
#pragma mark - Map Delegate
-
(
MKAnnotationView
*
)
mapView
:
(
MKMapView
*
)
mapView
viewForAnnotation
:
(
id
<
MKAnnotation
>
)
annotation
{
-
(
void
)
mapViewDidFinishRenderingMap
:
(
MKMapView
*
)
mapView
fullyRendered
:
(
BOOL
)
fullyRendered
{
if
(
annotation
==
(
id
<
MKAnnotation
>
)
self
.
track
)
{
NSString
*
pointReuseIndetifier
=
@"pointReuseIndetifier1"
;
if
(
_trackAnimation
)
{
// MAAnnotationView *annotationView = (MAAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:pointReuseIndetifier];
// if(!annotationView) {
// annotationView = [[MAAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:pointReuseIndetifier];
//
// annotationView.canShowCallout = YES;
//
// UIImage *imge = [UIImage imageNamed:@"map_track_move_icon"];
// annotationView.image = imge;
//
// }
container
=
(
UIView
*
)[
mapView
.
subviews
firstObject
].
subviews
.
lastObject
;
MKAnnotationView
*
annotationView
=
(
MKAnnotationView
*
)[
mapView
dequeueReusableAnnotationViewWithIdentifier
:
pointReuseIndetifier
];
if
(
!
annotationView
)
{
annotationView
=
[[
MKAnnotationView
alloc
]
initWithAnnotation
:(
id
<
MKAnnotation
>
)
annotation
reuseIdentifier
:
pointReuseIndetifier
];
CGPoint
*
points
=
[
self
pointsForCoordinates
:
_smoothTrackPoints
count
:
_smoothTrackCount
];
CGPathRef
path
=
[
self
pathForPoints
:
points
count
:
_smoothTrackCount
];
[
self
initShapeLayerWithPath
:
path
];
self
.
shapeLayer
.
frame
=
self
.
mapView
.
bounds
;
CAAnimation
*
shapeLayerAnimation
=
[
self
constructShapeLayerAnimation
];
shapeLayerAnimation
.
delegate
=
self
;
shapeLayerAnimation
.
removedOnCompletion
=
NO
;
shapeLayerAnimation
.
fillMode
=
kCAFillModeForwards
;
[
self
.
shapeLayer
addAnimation
:
shapeLayerAnimation
forKey
:
@"shape"
];
[
self
.
mapView
.
layer
addSublayer
:
self
.
shapeLayer
];
[
self
initGradientLayerWithPoints
:
points
Count
:
_smoothTrackCount
];
ZJLocationModel
*
model
=
self
.
locations
[
0
];
[
startAnnotation
setCoordinate
:
CLLocationCoordinate2DMake
(
model
.
latitude
,
model
.
longitude
)];
MKAnnotationView
*
annotationView
=
[
self
.
mapView
viewForAnnotation
:
startAnnotation
];
CAAnimation
*
annotationAnimation
=
[
self
constructAnnotationAnimationWithPath
:
path
];
annotationView
.
image
=
[
UIImage
imageNamed
:
@"map_track_start_icon"
];
[
annotationView
.
layer
addAnimation
:
annotationAnimation
forKey
:
@"annotation"
];
[
annotationView
.
annotation
setCoordinate
:
_smoothTrackPoints
[
_smoothTrackCount
-
1
]];
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
(
int64_t
)(
3
.
3
*
NSEC_PER_SEC
)),
dispatch_get_main_queue
(),
^
{
annotationView
.
canShowCallout
=
YES
;
// [self.gradientLayer removeFromSuperlayer];
// [self.shapeLayer removeFromSuperlayer];
// UIImage *imge = [UIImage imageNamed:@"map_track_move_icon"];
// annotationView.image = imge;
}
// MAPointAnnotation *pointAnnotation2 = [[MAPointAnnotation alloc] init];
// pointAnnotation2.coordinate = CLLocationCoordinate2DMake(self.locations.lastObject.latitude, self.locations.lastObject.longitude);
// pointAnnotation2.title = @"end";
// [self.mapView addAnnotation:(id<MKAnnotation>)pointAnnotation2];
});
(
void
)(
free
(
points
)),
points
=
NULL
;
(
void
)(
CGPathRelease
(
path
)),
path
=
NULL
;
_trackAnimation
=
NO
;
}
}
-
(
MKAnnotationView
*
)
mapView
:
(
MKMapView
*
)
mapView
viewForAnnotation
:
(
id
<
MKAnnotation
>
)
annotation
{
if
([
annotation
isKindOfClass
:[
ZJCustomAnnotation
class
]])
{
static
NSString
*
key
=
@"startAnnotation"
;
MKAnnotationView
*
annotationView
=
[
mapView
dequeueReusableAnnotationViewWithIdentifier
:
key
];
if
(
!
annotationView
)
{
annotationView
=
[[
MKAnnotationView
alloc
]
initWithAnnotation
:
annotation
reuseIdentifier
:
key
];
annotationView
.
canShowCallout
=
true
;
//允许交互点击
annotationView
.
calloutOffset
=
CGPointMake
(
0
,
0
);
//定义详情视图偏移量
}
annotationView
.
annotation
=
annotation
;
return
annotationView
;
}
else
if
([
annotation
isKindOfClass
:[
MAPointAnnotation
class
]])
{
NSString
*
pointReuseIndetifier
=
@"pointReuseIndetifier2"
;
MKAnnotationView
*
annotationView
=
(
MKAnnotationView
*
)[
mapView
dequeueReusableAnnotationViewWithIdentifier
:
pointReuseIndetifier
];
if
(
annotationView
==
nil
)
{
...
...
@@ -349,11 +327,6 @@
annotationView
.
enabled
=
NO
;
annotationView
.
image
=
[
UIImage
imageNamed
:
kLocalizedString
(
@"map_track_end_icon"
)];
}
// else {
// annotationView.enabled = NO;
// annotationView.image = [UIImage imageNamed:@"userPosition"];
// }
return
(
MKAnnotationView
*
)
annotationView
;
}
else
if
([
annotation
isKindOfClass
:[
MKUserLocation
class
]]){
...
...
@@ -366,46 +339,17 @@
}
annotationView
.
enabled
=
NO
;
annotationView
.
image
=
[
UIImage
imageNamed
:
@"userPosition"
];
//
annotationView.image = [UIImage imageNamed:@"userPosition"];
return
annotationView
;
}
// else{
//
// NSString *pointReuseIndetifier = @"pointReuseIndetifier3";
// MKAnnotationView *annotationView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:pointReuseIndetifier];
// if (annotationView == nil) {
// annotationView = [[MKAnnotationView alloc] initWithAnnotation:(id<MKAnnotation>)annotation reuseIdentifier:pointReuseIndetifier];
// annotationView.canShowCallout = YES;
// }
//
// if ([annotation.title isEqualToString:@"start"]) {
// annotationView.enabled = NO;
// annotationView.image = [UIImage imageNamed:kLocalizedString(@"map_track_start_icon")];
// } else if ([annotation.title isEqualToString:@"end"]) {
// annotationView.enabled = NO;
// annotationView.image = [UIImage imageNamed:kLocalizedString(@"map_track_end_icon")];
// }
// return annotationView;
// }
return
nil
;
}
/// 设置折线的样式
-
(
MKOverlayRenderer
*
)
mapView
:
(
MKMapView
*
)
mapView
rendererForOverlay
:
(
id
<
MKOverlay
>
)
overlay
{
if
([
overlay
isKindOfClass
:[
MAPolyline
class
]])
{
MAPolylineRenderer
*
polylineRenderer
=
[[
MAPolylineRenderer
alloc
]
initWithPolyline
:(
MAPolyline
*
)
overlay
];
polylineRenderer
.
lineWidth
=
4
.
f
;
polylineRenderer
.
strokeColor
=
[
UIColor
colorWithHex
:
0x568EFC
];
polylineRenderer
.
lineJoinType
=
kMALineJoinRound
;
polylineRenderer
.
lineCapType
=
kMALineCapRound
;
return
(
MKOverlayRenderer
*
)
polylineRenderer
;
}
else
if
([
overlay
isKindOfClass
:[
MKPolyline
class
]]){
-
(
MKOverlayRenderer
*
)
mapView
:
(
MKMapView
*
)
mapView
rendererForOverlay
:
(
id
<
MKOverlay
>
)
overlay
{
if
([
overlay
isKindOfClass
:[
MKPolyline
class
]]){
MKPolylineRenderer
*
render
=
[[
MKPolylineRenderer
alloc
]
initWithOverlay
:
overlay
];
render
.
lineWidth
=
4
.
f
;
render
.
strokeColor
=
[
UIColor
colorWithHex
:
0x568EFC
];
...
...
@@ -417,25 +361,6 @@
return
nil
;
}
//- (MAAnnotationView *)mapView:(MAMapView *)mapView viewForAnnotation:(id<MAAnnotation>)annotation
//{
// if ([annotation isKindOfClass:[MAPointAnnotation class]])
// {
// static NSString *reuseIndetifier = @"annotationReuseIndetifier";
// MAAnnotationView *annotationView = (MAAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:reuseIndetifier];
// if (annotationView == nil)
// {
// annotationView = [[MAAnnotationView alloc] initWithAnnotation:annotation
//reuseIdentifier:reuseIndetifier];
// }
//// annotationView.image = [UIImage imageNamed:@"gpsStat2"];
// //设置中心点偏移,使得标注底部中间点成为经纬度对应点
//// annotationView.centerOffset = CGPointMake(0, -18);
// return annotationView;
// }
// return nil;
//}
#pragma mark 查询轨迹
-
(
void
)
queryLocationList
:
(
ZJFriendModel
*
)
model
{
...
...
@@ -490,17 +415,14 @@
}
}
}
// [self.locations sortUsingComparator:^NSComparisonResult(ZJLocationModel *obj1, ZJLocationModel *obj2) {
// return (obj1.latitude < obj2.latitude);
// }];
NSLog
(
@"%@"
,
self
.
locations
);
if
(
_self
.
locations
.
count
<=
0
)
{
[
_self
showAlertView
];
// [MBProgressHUD showMessage:kLocalizedString(@"track_friend_timeWithin_no_location")];
return
;
}
[
_self
drawLineAction
];
[
_self
drawLineAction1
];
}
else
{
[
MBProgressHUD
showError
:[
response
objectForKey
:
@"msg"
]
toView
:
self
.
view
];
}
...
...
@@ -563,6 +485,7 @@
self
.
shapeLayer
.
strokeColor
=
[
UIColor
greenColor
].
CGColor
;
self
.
shapeLayer
.
fillColor
=
[
UIColor
clearColor
].
CGColor
;
self
.
shapeLayer
.
lineJoin
=
kCALineCapRound
;
self
.
shapeLayer
.
lineWidth
=
3
;
self
.
shapeLayer
.
path
=
path
;
}
...
...
@@ -607,4 +530,133 @@
return
theStrokeAnimation
;
}
#pragma mark - 构建Annotation动画
-
(
CAAnimation
*
)
constructAnnotationAnimationWithPath
:
(
CGPathRef
)
path
{
if
(
path
==
NULL
){
return
nil
;
}
CAKeyframeAnimation
*
keyFrameAnimation
=
[
CAKeyframeAnimation
animationWithKeyPath
:
@"position"
];
keyFrameAnimation
.
duration
=
3
;
keyFrameAnimation
.
timingFunction
=
[
CAMediaTimingFunction
functionWithName
:
kCAMediaTimingFunctionEaseInEaseOut
];
keyFrameAnimation
.
path
=
path
;
keyFrameAnimation
.
calculationMode
=
kCAAnimationPaced
;
return
keyFrameAnimation
;
}
#pragma mark - 构造gradientLayer
-
(
void
)
initGradientLayerWithPoints
:
(
CGPoint
*
)
points
Count
:
(
NSUInteger
)
count
{
if
(
count
<
1
){
return
;
}
self
.
gradientLayer
=
[[
CALayer
alloc
]
init
];
[
self
velocity
:
velocity
ToHue
:
&
hues
count
:
(
int
)
count
];
for
(
int
i
=
0
;
i
<
count
-
1
;
i
++
){
@autoreleasepool
{
CGPoint
point1
=
points
[
i
];
CGPoint
point2
=
points
[
i
+
1
];
double
xDiff
=
point2
.
x
-
point1
.
x
;
double
yDiff
=
point2
.
y
-
point1
.
y
;
CGPoint
startPoint
,
endPoint
;
double
offset
=
0
.;
CAGradientLayer
*
gradientLayer
=
[[
CAGradientLayer
alloc
]
init
];
//相邻两个最标点 构造一个渐变图层
[
gradientLayer
setFrame
:
CGRectMake
(
MIN
(
point1
.
x
,
point2
.
x
)
-
3
,
MIN
(
point1
.
y
,
point2
.
y
)
-
3
,
fabs
(
xDiff
)
+
6
,
fabs
(
yDiff
)
+
6
)];
//渐变方向
if
(
xDiff
>
0
.){
if
(
yDiff
>
0
.){
if
(
xDiff
>
yDiff
){
offset
=
yDiff
/
xDiff
;
startPoint
=
CGPointMake
(
0
,
0
);
endPoint
=
CGPointMake
(
offset
,
1
);
}
else
{
offset
=
xDiff
/
yDiff
;
startPoint
=
CGPointMake
(
0
,
0
);
endPoint
=
CGPointMake
(
1
,
offset
);
}
}
else
{
if
(
xDiff
>
fabs
(
yDiff
)){
offset
=
fabs
(
yDiff
)
/
xDiff
;
startPoint
=
CGPointMake
(
1
,
0
);
endPoint
=
CGPointMake
(
1
,
offset
);
}
else
{
offset
=
xDiff
/
fabs
(
yDiff
);
startPoint
=
CGPointMake
(
1
,
0
);
endPoint
=
CGPointMake
(
0
,
offset
);
}
}
}
else
{
if
(
yDiff
>
0
.){
if
(
fabs
(
xDiff
)
>
yDiff
){
offset
=
yDiff
/
fabs
(
xDiff
);
startPoint
=
CGPointMake
(
0
,
1
);
endPoint
=
CGPointMake
(
offset
,
0
);
}
else
{
offset
=
fabs
(
xDiff
)
/
yDiff
;
startPoint
=
CGPointMake
(
1
,
0
);
endPoint
=
CGPointMake
(
1
-
offset
,
1
);
}
}
else
{
if
(
fabs
(
xDiff
)
>
fabs
(
yDiff
)){
offset
=
fabs
(
yDiff
)
/
fabs
(
xDiff
);
startPoint
=
CGPointMake
(
1
,
1
);
endPoint
=
CGPointMake
(
1
-
offset
,
0
);
}
else
{
offset
=
fabs
(
xDiff
)
/
fabs
(
yDiff
);
startPoint
=
CGPointMake
(
1
,
1
);
endPoint
=
CGPointMake
(
0
,
1
-
offset
);
}
}
}
gradientLayer
.
cornerRadius
=
6
;
gradientLayer
.
startPoint
=
startPoint
;
gradientLayer
.
endPoint
=
endPoint
;
gradientLayer
.
colors
=
@[[
_gradientColors
objectAtIndex
:
i
],
[
_gradientColors
objectAtIndex
:
i
+
1
]];
// gradientLayer.colors = @[(__bridge id)[UIColor redColor].CGColor,
// (__bridge id)[UIColor blueColor].CGColor,
// (__bridge id)[UIColor greenColor].CGColor];
[
self
.
gradientLayer
addSublayer
:
gradientLayer
];
}
}
[
self
.
gradientLayer
setMask
:
self
.
shapeLayer
];
[
self
.
mapView
.
layer
addSublayer
:
self
.
gradientLayer
];
}
#define V_MAX 4.5
#define V_MIN 1.0
#define H_MAX 0.33
#define H_MIN 0.03
-
(
void
)
velocity
:
(
float
*
)
velocity
ToHue
:
(
float
**
)
_hue
count
:
(
int
)
count
{
_gradientColors
=
[
NSMutableArray
new
];
*
_hue
=
malloc
(
sizeof
(
float
)
*
count
);
for
(
int
i
=
0
;
i
<
count
;
i
++
){
float
curVelo
=
velocity
[
i
];
if
(
curVelo
>
0
.){
curVelo
=
((
curVelo
<
V_MIN
)
?
V_MIN
:
(
curVelo
>
V_MAX
)
?
V_MAX
:
curVelo
);
(
*
_hue
)[
i
]
=
H_MIN
+
((
curVelo
-
V_MIN
)
*
(
H_MAX
-
H_MIN
))
/
(
V_MAX
-
V_MIN
);
}
else
if
(
curVelo
==
0
){
//暂停颜色
(
*
_hue
)[
i
]
=
0
.
5
;
}
else
{
//超速颜色
(
*
_hue
)[
i
]
=
0
.;
}
//填充轨迹渐变数组
UIColor
*
color
;
if
(
curVelo
>
0
.){
// color = [UIColor colorWithHue:(*_hue)[i] saturation:1.0f brightness:1.0f alpha:1.0f];
color
=
[
UIColor
greenColor
];
}
else
{
// color = [UIColor colorWithHue:(*_hue)[i] saturation:1.0f brightness:1.0f alpha:0.0f];
color
=
[
UIColor
greenColor
];
}
[
_gradientColors
addObject
:(
__bridge
id
)
color
.
CGColor
];
}
}
@end
ZhiJi/Classes/Tools/PCH/ResourceHeader.pch
View file @
e3d8716d
...
...
@@ -22,14 +22,14 @@
//#if DEBUG
//
#define ServerReport @"http://report.zhangxinhulian.com"
#define ServerHost @"https://feedapitest.zhangxinhulian.com"
#define ServerHostFeed @"https://feedapitest.zhangxinhulian.com"
//
#define ServerReport @"http://report.zhangxinhulian.com"
//
#define ServerHost @"https://feedapitest.zhangxinhulian.com"
//
#define ServerHostFeed @"https://feedapitest.zhangxinhulian.com"
//
//#else
//
#define ServerReport @"http://report.zhangxinhulian.com"
//
#define ServerHost @"https://feedapi.zhangxinhulian.com"
//
#define ServerHostFeed @"https://feedapi.zhangxinhulian.com"
#define ServerReport @"http://report.zhangxinhulian.com"
#define ServerHost @"https://feedapi.zhangxinhulian.com"
#define ServerHostFeed @"https://feedapi.zhangxinhulian.com"
//#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment