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
1251bd05
Commit
1251bd05
authored
Jul 28, 2020
by
lmj_521aiau@163.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
4c5ea2b7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
38 deletions
+34
-38
ZJFriendTrackMapViewController.m
...i/Classes/Map/Controller/ZJFriendTrackMapViewController.m
+34
-38
No files found.
ZhiJi/Classes/Map/Controller/ZJFriendTrackMapViewController.m
View file @
1251bd05
...
...
@@ -139,7 +139,9 @@
///初始化地图
self
.
mapView
=
[[
MKMapView
alloc
]
initWithFrame
:
self
.
view
.
bounds
];
///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码
_mapView
.
showsUserLocation
=
false
;
// _mapView.showsUserLocation = false;
_mapView
.
showsUserLocation
=
YES
;
_mapView
.
userTrackingMode
=
MAUserTrackingModeFollow
;
_mapView
.
delegate
=
self
;
_mapView
.
showsScale
=
false
;
_mapView
.
showsCompass
=
false
;
...
...
@@ -179,18 +181,21 @@
mapPaddle
=
YES
;
}
-
(
void
)
drawLineAction
1
{
-
(
void
)
drawLineAction
{
//重制
// _endAnnotationView = nil;
// _startAnnotationView = nil;
[
self
.
mapView
removeOverlays
:
self
.
mapView
.
overlays
];
[
self
.
mapView
removeAnnotations
:
self
.
mapView
.
annotations
];
_trackAnimation
=
YES
;
//动画行动点
endAnnotation
=
[[
ZJCustomAnnotation
alloc
]
init
];
[
_mapView
addAnnotation
:
endAnnotation
];
//动画 路径 数据处理
_smoothTrackCount
=
_locations
.
count
;
_smoothTrackPoints
=
malloc
(
sizeof
(
CLLocationCoordinate2D
)
*
_smoothTrackCount
);
velocity
=
malloc
(
sizeof
(
float
)
*
_smoothTrackCount
);
...
...
@@ -206,8 +211,31 @@
_smoothTrackPoints
[
i
]
=
coordinate
;
}
}
//构造折线数据对象
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
;
}
//构造折线对象
MKPolyline
*
commonPolyline
=
[
MKPolyline
polylineWithCoordinates
:
commonPolylineCoords
count
:
self
.
locations
.
count
];
self
.
commonPolyline
=
commonPolyline
;
//在地图上添加折线对象
[
self
.
mapView
addOverlay
:
self
.
commonPolyline
];
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
];
if
(
!
mapPaddle
)
{
[
self
addAnimation
];
}
}
//开始动画
-
(
void
)
addAnimation
{
_container
=
(
UIView
*
)[
self
.
mapView
.
subviews
firstObject
].
subviews
.
lastObject
;
...
...
@@ -247,7 +275,7 @@
_trackAnimation
=
NO
;
mapPaddle
=
NO
;
}
//动画结束
-
(
void
)
removeLayer
{
_mapView
.
userInteractionEnabled
=
YES
;
[
self
.
trackTimeView
.
trackButton
setSelected
:
false
];
...
...
@@ -261,40 +289,9 @@
[
self
.
mapView
addAnnotation
:(
id
<
MKAnnotation
>
)
_startAnnotation
];
}
-
(
void
)
drawLineAction
{
[
self
.
mapView
removeOverlays
:
self
.
mapView
.
overlays
];
//构造折线数据对象
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
;
}
//构造折线对象
MKPolyline
*
commonPolyline
=
[
MKPolyline
polylineWithCoordinates
:
commonPolylineCoords
count
:
self
.
locations
.
count
];
self
.
commonPolyline
=
commonPolyline
;
//在地图上添加折线对象
[
self
.
mapView
addOverlay
:
self
.
commonPolyline
];
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
];
if
(
!
mapPaddle
)
{
[
self
addAnimation
];
}
}
#pragma mark - Map Delegate
-
(
void
)
mapView
:
(
MKMapView
*
)
mapView
regionDidChangeAnimated
:
(
BOOL
)
animated
{
mapPaddle
=
YES
;
}
-
(
void
)
mapViewDidFinishRenderingMap
:
(
MKMapView
*
)
mapView
fullyRendered
:
(
BOOL
)
fullyRendered
{
if
(
_trackAnimation
)
{
[
self
addAnimation
];
}
...
...
@@ -418,14 +415,13 @@
}
}
}
NSLog
(
@"%@"
,
self
.
locations
);
if
(
_self
.
locations
.
count
<
=
0
)
{
if
(
_self
.
locations
.
count
=
=
0
)
{
[
_self
showAlertView
];
return
;
}
[
_self
drawLineAction
];
[
_self
drawLineAction1
];
}
else
{
[
MBProgressHUD
showError
:[
response
objectForKey
:
@"msg"
]
toView
:
self
.
view
];
}
...
...
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