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
e15f2a20
Commit
e15f2a20
authored
Jul 28, 2020
by
lmj_521aiau@163.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
b657a210
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
22 deletions
+47
-22
ZJLocationRemindSelectController.m
...sses/LocationAttention/ZJLocationRemindSelectController.m
+47
-22
No files found.
ZhiJi/Classes/LocationAttention/ZJLocationRemindSelectController.m
View file @
e15f2a20
...
...
@@ -41,7 +41,7 @@
@property
(
nonatomic
,
strong
)
AMapLocationManager
*
locationManager
;
@property
(
nonatomic
,
strong
)
M
A
Circle
*
circle
;
@property
(
nonatomic
,
strong
)
M
K
Circle
*
circle
;
@property
(
nonatomic
,
strong
)
SJSlider
*
slider
;
...
...
@@ -98,7 +98,7 @@
_mapView
.
showsCompass
=
false
;
// _mapView.zoomLevel = 15.5;
// _mapView.customizeUserLocationAccuracyCircleRepresentation = true;
self
.
circle
=
[
M
A
Circle
circleWithCenterCoordinate
:
self
.
mapView
.
centerCoordinate
radius
:
500
];
self
.
circle
=
[
M
K
Circle
circleWithCenterCoordinate
:
self
.
mapView
.
centerCoordinate
radius
:
500
];
[
self
.
mapView
addOverlay
:
self
.
circle
];
[
AMapServices
sharedServices
].
apiKey
=
@"501f8a894329f4b57bbfee208a11676f"
;
...
...
@@ -130,32 +130,56 @@
self
.
addressMainTitleLabel
.
text
=
_editModel
.
address
;
self
.
addressSubTitleLabel
.
text
=
_editModel
.
addressName
;
// ZJCustomAnnotation *annotation = [[ZJCustomAnnotation alloc] init];
// annotation.coordinate = self.mapView.centerCoordinate;
// annotation.title = @"北京";
// annotation.subtitle = @"默认显示的为首都北京";
// [self.mapView addAnnotation:annotation];
}
-
(
void
)
mapView
:
(
MKMapView
*
)
mapView
regionWillChangeAnimated
:
(
BOOL
)
animated
{
[
mapView
removeAnnotations
:
self
.
mapView
.
annotations
];
ZJCustomAnnotation
*
annotation
=
[[
ZJCustomAnnotation
alloc
]
init
];
annotation
.
coordinate
=
self
.
mapView
.
centerCoordinate
;
annotation
.
title
=
@"北京"
;
annotation
.
subtitle
=
@"默认显示的为首都北京"
;
[
self
.
mapView
addAnnotation
:
annotation
];
}
-
(
void
)
mapView
:
(
MKMapView
*
)
mapView
regionDidChangeAnimated
:
(
BOOL
)
animated
{
[
self
.
mapView
removeAnnotations
:
self
.
mapView
.
annotations
];
[
self
.
mapView
removeOverlays
:
self
.
mapView
.
overlays
];
ZJCustomAnnotation
*
annotation
=
[[
ZJCustomAnnotation
alloc
]
init
];
annotation
.
coordinate
=
self
.
mapView
.
centerCoordinate
;
annotation
.
title
=
@"北京"
;
annotation
.
subtitle
=
@"默认显示的为首都北京"
;
[
self
.
mapView
addAnnotation
:
annotation
];
self
.
circle
=
[
MKCircle
circleWithCenterCoordinate
:
self
.
mapView
.
centerCoordinate
radius
:
500
];
[
self
.
mapView
addOverlay
:
self
.
circle
];
self
.
location
=
[[
CLLocation
alloc
]
initWithLatitude
:
mapView
.
centerCoordinate
.
latitude
longitude
:
mapView
.
centerCoordinate
.
longitude
];
[
self
centerLocation
:
self
.
location
];
}
-
(
void
)
centerLocation
:
(
CLLocation
*
)
location
{
//创建地理编码对象
CLGeocoder
*
geocoder
=
[[
CLGeocoder
alloc
]
init
];
//反地理编码
[
geocoder
reverseGeocodeLocation
:
location
completionHandler
:
^
(
NSArray
<
CLPlacemark
*>
*
_Nullable
placemarks
,
NSError
*
_Nullable
error
)
{
//判断是否有错误或者placemarks是否为空
if
(
error
!=
nil
||
placemarks
.
count
==
0
)
{
NSLog
(
@"%@"
,
error
);
return
;
}
CLPlacemark
*
placemark
=
[
placemarks
firstObject
];
if
(
placemark
)
{
//获取城市
NSString
*
city
=
placemark
.
locality
;
if
(
!
city
)
{
//四大直辖市的城市信息无法通过locality获得,只能通过获取省份的方法来获得(如果city为空,则可知为直辖市)
city
=
placemark
.
administrativeArea
;
}
self
.
addressMainTitleLabel
.
text
=
placemark
.
name
;
self
.
addressSubTitleLabel
.
text
=
[
NSString
stringWithFormat
:
@"%@%@%@"
,
placemark
.
subLocality
?:
@""
,
placemark
.
thoroughfare
?:
@""
,
placemark
.
subThoroughfare
?:
@""
];
}
}];
}
//添加固定
-
(
void
)
addPointAnnotation
:
(
CLLocationCoordinate2D
)
oordinate
{
self
.
pointAnnotation
=
[[
MAPointAnnotation
alloc
]
init
];
...
...
@@ -255,7 +279,7 @@
/// Description
/// @param mapView mapView description
-
(
void
)
mapViewRegionChanged
:
(
MAMapView
*
)
mapView
{
[
self
.
circle
setCoordinate
:
mapView
.
centerCoordinate
];
//
[self.circle setCoordinate:mapView.centerCoordinate];
}
-
(
void
)
reverseGeocodeLocation
:
(
CLLocation
*
)
location
{
...
...
@@ -326,7 +350,8 @@
-
(
void
)
sliderDidDrag
:
(
SJSlider
*
)
slider
{
NSLog
(
@"%f"
,
slider
.
value
);
CGFloat
ss
=
(
slider
.
value
*
800
)
+
200
;
[
self
.
circle
setCircleWithCenterCoordinate
:
self
.
mapView
.
centerCoordinate
radius
:
ss
];
// [self.circle setCircleWithCenterCoordinate:self.mapView.centerCoordinate radius: ss];
self
.
distanceTipLabel
.
text
=
[
NSString
stringWithFormat
:
@"%0.fm"
,
ss
];
}
...
...
@@ -334,7 +359,7 @@
sliderDrag
=
YES
;
/// 缩放级别, [3, 20]// [20, 10] [0, 1] [200 , 1000]
CGFloat
ss
=
(
slider
.
value
*
800
)
+
200
;
[
self
.
circle
setCircleWithCenterCoordinate
:
self
.
mapView
.
centerCoordinate
radius
:
ss
];
//
[self.circle setCircleWithCenterCoordinate:self.mapView.centerCoordinate radius: ss];
self
.
distanceTipLabel
.
text
=
[
NSString
stringWithFormat
:
@"%0.fm"
,
ss
];
}
...
...
@@ -358,9 +383,9 @@
-
(
MKOverlayRenderer
*
)
mapView
:
(
MKMapView
*
)
mapView
rendererForOverlay
:
(
id
<
MKOverlay
>
)
overlay
{
if
([
overlay
isKindOfClass
:[
MK
Polylin
e
class
]]){
MK
PolylineRenderer
*
circleRenderer
=
[[
MKPolylin
eRenderer
alloc
]
initWithOverlay
:
overlay
];
if
([
overlay
isKindOfClass
:[
MK
Circl
e
class
]]){
MK
CircleRenderer
*
circleRenderer
=
[[
MKCircl
eRenderer
alloc
]
initWithOverlay
:
overlay
];
circleRenderer
.
lineWidth
=
2
.
f
;
circleRenderer
.
strokeColor
=
[
UIColor
colorWithHex
:
0x4299f9
];
circleRenderer
.
fillColor
=
[[
UIColor
colorWithHex
:
0x4299f9
]
colorWithAlphaComponent
:
0
.
3
];
...
...
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