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
ab66a73f
Commit
ab66a73f
authored
Jul 24, 2020
by
lmj_521aiau@163.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
2902f9e4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
125 additions
and
132 deletions
+125
-132
ZJBaseMapViewController.m
ZhiJi/Classes/Map/Controller/ZJBaseMapViewController.m
+124
-129
ZJFriendTrackMapViewController.m
...i/Classes/Map/Controller/ZJFriendTrackMapViewController.m
+1
-3
No files found.
ZhiJi/Classes/Map/Controller/ZJBaseMapViewController.m
View file @
ab66a73f
...
...
@@ -12,20 +12,40 @@
@interface
ZJBaseMapViewController
()
<
MAMapViewDelegate
,
XMPopupListViewDelegate
,
GMSMapViewDelegate
>
//@property (nonatomic, strong) MAMapView *mapView;
@property
(
nonatomic
,
strong
)
UIButton
*
gpsButton
;
@property
(
nonatomic
,
strong
)
ZJMapViewPersonCardView
*
cardView
;
@property
(
nonatomic
,
strong
)
NSMutableArray
<
ZJFriendModel
*>
*
friendDataSource
;
@property
(
nonatomic
,
strong
)
ZJMapCardFriendSelectView
*
selectView
;
@property
(
nonatomic
,
strong
)
ZJFriendModel
*
selectFriendModel
;
@property
(
nonatomic
,
strong
)
GMSMapView
*
mapView
;
@property
(
nonatomic
,
assign
)
ZJMapType
mapType
;
/********************/
@property
(
nonatomic
,
strong
)
MAMapView
*
GDMapView
;
///全轨迹overlay
@property
(
strong
,
nonatomic
)
MAPolyline
*
commonPolyline
;
///车头方向跟随转动
@property
(
nonatomic
,
strong
)
NSArray
*
distanceArray
;
@property
(
nonatomic
,
assign
)
double
sumDistance
;
/********************/
@property
(
nonatomic
,
strong
)
GMSMapView
*
GGMapView
;
@property
(
nonatomic
,
strong
)
GMSCircle
*
selfCircle
;
@property
(
nonatomic
,
strong
)
GMSMarker
*
selfMarker
;
@property
(
nonatomic
,
assign
)
float
zoom
;
@property
(
nonatomic
,
assign
)
float
__block
zoom
;
@property
(
nonatomic
,
assign
)
float
__block
animationZoom
;
@property
(
nonatomic
,
assign
)
NSTimer
*
ttt
;
@property
(
nonatomic
,
assign
)
NSInteger
tttCount
;
@property
(
nonatomic
,
strong
)
GMSPolyline
*
initialPolyline
;
@property
(
nonatomic
,
strong
)
GMSPolyline
*
actionPolyline
;
@property
(
nonatomic
,
strong
)
GMSMutablePath
*
initiallinepath
;
@property
(
nonatomic
,
strong
)
GMSMutablePath
*
actionlinepath
;
@property
(
nonatomic
,
strong
)
GMSMarker
*
startMarker
;
@property
(
nonatomic
,
strong
)
GMSMarker
*
endMarker
;
@property
(
nonatomic
,
strong
)
GMSMarker
*
actionMarker
;
@property
(
nonatomic
,
assign
)
BOOL
refershMyself
;
@end
...
...
@@ -35,36 +55,17 @@
[
super
viewDidLoad
];
// Do any additional setup after loading the view.
[
self
setupUI
];
self
.
friendDataSource
=
[
NSMutableArray
array
];
//
[self getFriendList];
[
self
setupUI
];
[
self
getFriendList
];
}
-
(
void
)
viewDidAppear
:
(
BOOL
)
animated
{
[
super
viewDidAppear
:
animated
];
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
(
int64_t
)(
2
*
NSEC_PER_SEC
)),
dispatch_get_main_queue
(),
^
{
//
[self getFriendList];
[
self
getFriendList
];
});
self
.
refershMyself
=
YES
;
[[
ZJLocationManager
shared
]
initWithLocationUpdateInfo
:
^
(
ZJLocationModel
*
model
,
CLLocation
*
location
,
ZJMapType
mapType
)
{
if
(
!
model
){
return
;
}
CLLocationCoordinate2D
coord
=
CLLocationCoordinate2DMake
(
model
.
latitude
,
model
.
longitude
);
if
(
self
.
refershMyself
)
{
self
.
mapView
.
camera
=
[
GMSCameraPosition
cameraWithTarget
:
coord
zoom
:
self
.
zoom
];
self
.
refershMyself
=
NO
;
}
[
self
setPoint
:
coord
target
:
1
];
}];
}
-
(
void
)
viewWillAppear
:
(
BOOL
)
animated
{
...
...
@@ -72,39 +73,52 @@
[
self
.
navigationController
setNavigationBarHidden
:
true
animated
:
true
];
}
-
(
void
)
setMapType
:
(
ZJMapType
)
mapType
{
_mapType
=
ZJ_GMSMapType
;
if
(
_mapType
==
ZJ_GMSMapType
)
{
_GGMapView
.
hidden
=
NO
;
_GDMapView
.
hidden
=
YES
;
}
else
{
_GGMapView
.
hidden
=
YES
;
_GDMapView
.
hidden
=
NO
;
}
}
-
(
void
)
setupUI
{
GMSCameraPosition
*
camera
=
[
GMSCameraPosition
cameraWithLatitude
:
-
33
.
868
longitude
:
151
.
2086
zoom
:
12
];
_zoom
=
14
;
_zoom
=
18
;
GMSCameraPosition
*
camera
=
[
GMSCameraPosition
cameraWithLatitude
:[[[
self
.
data
Read
]
objectForKey
:
@"latitude"
]
doubleValue
]
longitude
:[[[
self
.
data
Read
]
objectForKey
:
@"longitude"
]
doubleValue
]
zoom
:
_zoom
];
///初始化地图
// self.mapView = [[MAMapView alloc] initWithFrame:self.view.bounds];
self
.
mapView
=
[
GMSMapView
mapWithFrame
:
self
.
view
.
bounds
camera
:
camera
];
_mapView
.
autoresizingMask
=
UIViewAutoresizingFlexibleWidth
|
UIViewAutoresizingFlexibleHeight
;
///把地图添加至view
[
self
.
view
addSubview
:
_mapView
];
self
.
GGMapView
=
[
GMSMapView
mapWithFrame
:
self
.
view
.
bounds
camera
:
camera
];
_GGMapView
.
delegate
=
self
;
[
self
.
view
addSubview
:
_GGMapView
];
_GGMapView
.
autoresizingMask
=
UIViewAutoresizingFlexibleWidth
|
UIViewAutoresizingFlexibleHeight
;
_GGMapView
.
hidden
=
YES
;
// self.mapView.mapType = 0;
// _mapView.showsWorldMap = @YES;
// [self.mapView performSelector:@selector(setShowsWorldMap:) withObject:@(YES)];
// if ([ZJUserInfoManager CNLanguage]) {
// self.mapView.mapLanguage = @0;
// [self.mapView performSelector:NSSelectorFromString(@"setMapLanguage:") withObject:@(0)];
// }else{
// self.mapView.mapLanguage = @1;
// [self.mapView performSelector:NSSelectorFromString(@"setMapLanguage:") withObject:@(1)];
// }
_mapView
.
delegate
=
self
;
// _mapView.zoomLevel = 14;
// _mapView.showsScale = false;
// _mapView.showsCompass = false;
_mapView
.
settings
.
compassButton
=
YES
;
_mapView
.
settings
.
myLocationButton
=
YES
;
// _mapView.settings.scrollGestures = NO;
// _mapView.settings.zoomGestures = NO;
self
.
GDMapView
=
[[
MAMapView
alloc
]
initWithFrame
:
self
.
view
.
bounds
];
_GDMapView
.
delegate
=
self
;
_GDMapView
.
zoomLevel
=
14
;
_GDMapView
.
showsScale
=
false
;
_GDMapView
.
showsCompass
=
false
;
//如果您需要进入地图就显示定位小蓝点,则需要下面两行代码
_GDMapView
.
showsUserLocation
=
false
;
_GDMapView
.
mapType
=
0
;
_GDMapView
.
showsWorldMap
=
@YES
;
[
_GDMapView
performSelector
:
@selector
(
setShowsWorldMap
:)
withObject
:
@
(
YES
)];
if
([
ZJUserInfoManager
CNLanguage
])
{
_GDMapView
.
mapLanguage
=
@0
;
[
_GDMapView
performSelector
:
NSSelectorFromString
(
@"setMapLanguage:"
)
withObject
:
@
(
0
)];
}
else
{
_GDMapView
.
mapLanguage
=
@1
;
[
_GDMapView
performSelector
:
NSSelectorFromString
(
@"setMapLanguage:"
)
withObject
:
@
(
1
)];
}
[
self
.
view
addSubview
:
_GDMapView
];
_GDMapView
.
autoresizingMask
=
UIViewAutoresizingFlexibleWidth
|
UIViewAutoresizingFlexibleHeight
;
_GDMapView
.
hidden
=
YES
;
self
.
mapType
=
[[[
self
.
data
Read
]
objectForKey
:
@"mapType"
]
intValue
];
// 添加 card view
self
.
cardView
=
[[[
NSBundle
mainBundle
]
loadNibNamed
:
@"ZJMapViewPersonCardView"
owner
:
self
options
:
nil
]
lastObject
];
...
...
@@ -156,63 +170,20 @@
};
}
-
(
void
)
setPoint
:
(
CLLocationCoordinate2D
)
point
target
:
(
NSInteger
)
target
{
if
(
target
==
1
)
{
CLLocationCoordinate2D
position
=
point
;
_selfMarker
.
map
=
nil
;
_selfMarker
=
[
GMSMarker
markerWithPosition
:
position
];
// _selfMarker.appearAnimation = kGMSMarkerAnimationPop;
// _selfMarker.icon = [GMSMarker markerImageWithColor:[UIColor blackColor]];
_selfMarker
.
icon
=
[
UIImage
imageNamed
:
@"map_track_srart_end_icon"
];
_selfMarker
.
tracksInfoWindowChanges
=
YES
;
_selfMarker
.
title
=
@"Me"
;
_selfMarker
.
snippet
=
@"WTF"
;
_selfMarker
.
infoWindowAnchor
=
CGPointMake
(
0
.
5
,
0
.
25
);
_selfMarker
.
map
=
_mapView
;
}
else
{
CLLocationCoordinate2D
position
=
point
;
GMSMarker
*
marker
=
[
GMSMarker
markerWithPosition
:
position
];
marker
.
title
=
@"Hello World"
;
marker
.
map
=
_mapView
;
}
}
-
(
void
)
mapView
:
(
GMSMapView
*
)
mapView
idleAtCameraPosition
:
(
GMSCameraPosition
*
)
position
{
_zoom
=
position
.
zoom
;
}
-
(
void
)
mapView
:
(
UIView
*
)
mapView
regionDidChangeAnimated
:
(
BOOL
)
animated
{
// if(mapView.isHidden) {
// return;
// }
//
// if(self.isSwitching) {
// self.isSwitching = NO;
// return;
// }
// [self.mapView performSelector:NSSelectorFromString(@"setMapLanguage:") withObject:@(1)];
// [self.mapView performSelector:NSSelectorFromString(@"setMapLanguage:") withObject:@(0)];
// if([mapView isKindOfClass:[MAMapView class]]) {
// if(!AMapDataAvailableForCoordinate(self.mapView.centerCoordinate)) {
//
// }
// } else {
// if(AMapDataAvailableForCoordinate(self.mapView.centerCoordinate)) {
//
// }
// }
}
#pragma mark 好友列表
-
(
void
)
getFriendList
{
if
(
!
[
ZJUserInfoManager
shared
].
isLogin
)
{
//未登录
///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码
// _mapView.showsUserLocation = YES;
// _mapView.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
;
}
[
self
.
friendDataSource
removeAllObjects
];
...
...
@@ -232,19 +203,12 @@
[
weakSelf
.
addCareButton
setHidden
:
false
];
[
weakSelf
.
style2BgImV
setHidden
:
false
];
///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码
// weakSelf.m
apView.showsUserLocation = YES;
// weakSelf.m
apView.userTrackingMode = MAUserTrackingModeFollow;
weakSelf
.
GDM
apView
.
showsUserLocation
=
YES
;
weakSelf
.
GDM
apView
.
userTrackingMode
=
MAUserTrackingModeFollow
;
}
else
{
[
weakSelf
.
cardView
setHidden
:
false
];
[
weakSelf
.
addCareButton
setHidden
:
true
];
[
weakSelf
.
style2BgImV
setHidden
:
true
];
// ZJFriendModel *model = weakSelf.friendDataSource.firstObject;
//
// MAPointAnnotation *pointAnnotation2 = [[MAPointAnnotation alloc] init];
// pointAnnotation2.coordinate = CLLocationCoordinate2DMake([model.lat doubleValue], [model.lon doubleValue]);
// pointAnnotation2.title = @"location";
// [self.mapView addAnnotation:pointAnnotation2];
// [self.mapView setCenterCoordinate:pointAnnotation2.coordinate animated:false];
}
ZJFriendModel
*
model
=
self
.
friendDataSource
.
firstObject
;
...
...
@@ -257,9 +221,15 @@
if
([[
response
objectForKey
:
@"status"
]
integerValue
]
==
105
)
{
[
MBProgressHUD
showError
:[
response
objectForKey
:
@"msg"
]
toView
:
self
.
view
];
}
///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码
// weakSelf.mapView.showsUserLocation = YES;
// weakSelf.mapView.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
;
}
// [MBProgressHUD showError:[NSString stringWithFormat:@"获取好友列表失败\n%@", [response objectForKey:@"msg"]] toView:self.view];
}
...
...
@@ -268,12 +238,6 @@
}];
}
#pragma mark - Action Handlers
-
(
void
)
returnAction
{
[
self
.
navigationController
popViewControllerAnimated
:
YES
];
}
/**
选中cell后回调
@param indexPath 返回选中的indexPath
...
...
@@ -313,8 +277,8 @@
MAPointAnnotation
*
pointAnnotation
=
[[
MAPointAnnotation
alloc
]
init
];
pointAnnotation
.
coordinate
=
CLLocationCoordinate2DMake
(
lat
,
lon
);
pointAnnotation
.
title
=
@"latestLocation"
;
// [_self.m
apView addAnnotation:pointAnnotation];
// [_self.m
apView setCenterCoordinate:pointAnnotation.coordinate animated:false];
[
self
.
GDM
apView
addAnnotation
:
pointAnnotation
];
[
self
.
GDM
apView
setCenterCoordinate
:
pointAnnotation
.
coordinate
animated
:
false
];
}
else
if
([[
response
objectForKey
:
@"status"
]
integerValue
]
==
105
)
{
[
MBProgressHUD
showError
:[
response
objectForKey
:
@"msg"
]
toView
:
self
.
view
];
...
...
@@ -323,10 +287,9 @@
}
failure
:^
(
NSError
*
_Nonnull
error
)
{
NSLog
(
@"失败"
);
}];
}
#pragma mark -
Map Delegate
#pragma mark -
AMap Delegate 高德
-
(
MAAnnotationView
*
)
mapView
:
(
MAMapView
*
)
mapView
viewForAnnotation
:
(
id
<
MAAnnotation
>
)
annotation
{
if
([
annotation
isKindOfClass
:[
MAPointAnnotation
class
]])
{
...
...
@@ -344,4 +307,36 @@
return
nil
;
}
#pragma mark - GMSMap Function google
-
(
void
)
setPoint
:
(
CLLocationCoordinate2D
)
point
target
:
(
NSInteger
)
target
{
if
(
target
==
1
)
{
CLLocationCoordinate2D
position
=
point
;
_selfMarker
.
map
=
nil
;
_selfMarker
=
[
GMSMarker
markerWithPosition
:
position
];
// _selfMarker.appearAnimation = kGMSMarkerAnimationPop;
// _selfMarker.icon = [GMSMarker markerImageWithColor:[UIColor blackColor]];
_selfMarker
.
icon
=
[
UIImage
imageNamed
:
@"userPosition"
];
_selfMarker
.
tracksInfoWindowChanges
=
YES
;
_selfMarker
.
title
=
@"Me"
;
_selfMarker
.
snippet
=
@"WTF"
;
_selfMarker
.
infoWindowAnchor
=
CGPointMake
(
0
.
5
,
0
.
25
);
_selfMarker
.
map
=
_GGMapView
;
CLLocationDistance
distance
=
50
;
_selfCircle
.
map
=
nil
;
_selfCircle
=
[
GMSCircle
circleWithPosition
:
position
radius
:
distance
];
_selfCircle
.
fillColor
=
[
kColorWithRGBA
(
86
,
142
,
252
,
0
.
15
)
colorWithAlphaComponent
:
0
.
5
];
_selfCircle
.
strokeColor
=
[
kColorWithRGBA
(
86
,
142
,
252
,
0
.
6
)
colorWithAlphaComponent
:
0
.
5
];
_selfCircle
.
strokeWidth
=
1
.
0
;
_selfCircle
.
map
=
_GGMapView
;
}
else
{
CLLocationCoordinate2D
position
=
point
;
GMSMarker
*
marker
=
[
GMSMarker
markerWithPosition
:
position
];
marker
.
title
=
@"Hello World"
;
marker
.
map
=
_GGMapView
;
}
}
@end
ZhiJi/Classes/Map/Controller/ZJFriendTrackMapViewController.m
View file @
ab66a73f
...
...
@@ -23,8 +23,6 @@
@interface
ZJFriendTrackMapViewController
()
<
MAMapViewDelegate
,
GMSMapViewDelegate
>
//@property (nonatomic, strong) MAMapView *mapView;
@property
(
nonatomic
,
strong
)
UIButton
*
gpsButton
;
@property
(
nonatomic
,
strong
)
ZJUserTrackTimeView
*
trackTimeView
;
@property
(
nonatomic
,
strong
)
NSMutableArray
<
ZJLocationModel
*>
*
locations
;
...
...
@@ -665,12 +663,12 @@
self
.
actionMarker
.
map
=
self
.
GGMapView
;
_actionlinepath
=
[
GMSMutablePath
path
];
__block
NSInteger
count
=
0
;
[
self
.
trackTimeView
.
trackButton
setSelected
:
true
];
[
self
.
trackTimeView
.
trackButton
setEnabled
:
false
];
//路径动画1
// __block NSInteger count = 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.15 * NSEC_PER_SEC, 0 * NSEC_PER_SEC);
// dispatch_source_set_event_handler(timer, ^{
...
...
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