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
c7f26015
Commit
c7f26015
authored
Jul 23, 2020
by
lmj_521aiau@163.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
track gmsmap mamap
parent
c4c6f713
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
89 additions
and
44 deletions
+89
-44
.DS_Store
.DS_Store
+0
-0
ZhiJi.xcscheme
ZhiJi.xcodeproj/xcshareddata/xcschemes/ZhiJi.xcscheme
+2
-2
ZJFriendTrackMapViewController.h
...i/Classes/Map/Controller/ZJFriendTrackMapViewController.h
+2
-2
ZJFriendTrackMapViewController.m
...i/Classes/Map/Controller/ZJFriendTrackMapViewController.m
+78
-39
ZJLocationManager.h
ZhiJi/Classes/Tools/UserInfoManager/ZJLocationManager.h
+1
-1
ZJLocationManager.m
ZhiJi/Classes/Tools/UserInfoManager/ZJLocationManager.m
+6
-0
No files found.
.DS_Store
View file @
c7f26015
No preview for this file type
ZhiJi.xcodeproj/xcshareddata/xcschemes/ZhiJi.xcscheme
View file @
c7f26015
...
...
@@ -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>
...
...
ZhiJi/Classes/Map/Controller/ZJFriendTrackMapViewController.h
View file @
c7f26015
...
...
@@ -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
:
UI
ViewController
@interface
ZJFriendTrackMapViewController
:
Base
ViewController
@property
(
nonatomic
,
strong
)
ZJFriendModel
*
model
;
@property
(
nonatomic
,
assign
)
BOOL
autoTrack
;
...
...
ZhiJi/Classes/Map/Controller/ZJFriendTrackMapViewController.m
View file @
c7f26015
...
...
@@ -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
)
{
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
)
{
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
];
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
)
{
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
)
{
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
];
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
];
}
}
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
=
10
0
;
CLLocationDistance
distance
=
5
0
;
_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
);
}
});
...
...
ZhiJi/Classes/Tools/UserInfoManager/ZJLocationManager.h
View file @
c7f26015
...
...
@@ -12,7 +12,7 @@
NS_ASSUME_NONNULL_BEGIN
typedef
enum
:
NSUInteger
{
ZJ_GMSMapType
,
ZJ_GMSMapType
=
1
,
ZJ_MAMapType
}
ZJMapType
;
...
...
ZhiJi/Classes/Tools/UserInfoManager/ZJLocationManager.m
View file @
c7f26015
...
...
@@ -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
);
}
...
...
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