Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
GeliBusinessPlatform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ljy
GeliBusinessPlatform
Commits
4ecc9c91
Commit
4ecc9c91
authored
Jul 28, 2020
by
lujunye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
补充高德转百度坐标方法
parent
b65cc90e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
22 deletions
+35
-22
GeliBusinessPlatform.xcworkspace/xcuserdata/junyelu.xcuserdatad/UserInterfaceState.xcuserstate
...erdata/junyelu.xcuserdatad/UserInterfaceState.xcuserstate
+0
-0
GeliBusinessPlatform/ViewController/货拉拉/收发货地址/ToAndFormSelectViewController.swift
...wController/货拉拉/收发货地址/ToAndFormSelectViewController.swift
+35
-22
No files found.
GeliBusinessPlatform.xcworkspace/xcuserdata/junyelu.xcuserdatad/UserInterfaceState.xcuserstate
View file @
4ecc9c91
No preview for this file type
GeliBusinessPlatform/ViewController/货拉拉/收发货地址/ToAndFormSelectViewController.swift
View file @
4ecc9c91
...
@@ -35,13 +35,13 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
...
@@ -35,13 +35,13 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
var
manger
:
CLLocationManager
=
CLLocationManager
()
var
manger
:
CLLocationManager
=
CLLocationManager
()
func
locationManager
(
_
manager
:
CLLocationManager
,
didUpdateLocations
locations
:
[
CLLocation
])
{
func
locationManager
(
_
manager
:
CLLocationManager
,
didUpdateLocations
locations
:
[
CLLocation
])
{
manger
.
stopUpdatingLocation
()
manger
.
stopUpdatingLocation
()
let
location
=
locations
.
last
let
location
=
locations
.
last
lat
=
location
?
.
coordinate
.
latitude
as!
CLLocationDegrees
lat
=
location
?
.
coordinate
.
latitude
as!
CLLocationDegrees
lng
=
location
?
.
coordinate
.
longitude
as!
CLLocationDegrees
lng
=
location
?
.
coordinate
.
longitude
as!
CLLocationDegrees
initMapView
(
lat
:
lat
,
lng
:
lng
)
initMapView
(
lat
:
lat
,
lng
:
lng
)
initSearch
()
initSearch
()
}
}
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
...
@@ -56,7 +56,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
...
@@ -56,7 +56,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
}
}
searchBr
.
placeholderStr
=
"从哪儿发货"
searchBr
.
placeholderStr
=
"从哪儿发货"
searchBr
.
cornerRadius
=
35
/
2.0
searchBr
.
cornerRadius
=
35
/
2.0
AMapServices
.
shared
()
.
apiKey
=
"ca417b43e3d031db9c29382cc09a174a"
AMapServices
.
shared
()
.
apiKey
=
"ca417b43e3d031db9c29382cc09a174a"
manger
.
delegate
=
self
manger
.
delegate
=
self
...
@@ -71,7 +71,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
...
@@ -71,7 +71,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
mapView
.
isZoomEnabled
=
true
mapView
.
isZoomEnabled
=
true
mapView
.
setCenter
(
CLLocationCoordinate2D
(
latitude
:
lat
,
longitude
:
lng
),
animated
:
false
)
mapView
.
setCenter
(
CLLocationCoordinate2D
(
latitude
:
lat
,
longitude
:
lng
),
animated
:
false
)
MapBgView
.
addSubview
(
mapView
!
)
MapBgView
.
addSubview
(
mapView
!
)
let
tap
=
UITapGestureRecognizer
(
target
:
self
,
action
:
#selector(
cancelKeyboard
)
)
let
tap
=
UITapGestureRecognizer
(
target
:
self
,
action
:
#selector(
cancelKeyboard
)
)
mapView
.
addGestureRecognizer
(
tap
)
mapView
.
addGestureRecognizer
(
tap
)
...
@@ -123,12 +123,12 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
...
@@ -123,12 +123,12 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
introView
?
.
addSubview
(
contentLbl
!
)
introView
?
.
addSubview
(
contentLbl
!
)
}
}
titleLbl
!.
text
=
response
.
pois
.
first
?
.
name
titleLbl
!.
text
=
response
.
pois
.
first
?
.
name
// contentLbl!.text = "contentLbl?.textColor = UIColor.lightGraycontentLbl?.font = UIFont.systemFont(ofSize: 11)contentLbl?.numberOfLines = 0introView?.addSubview(contentLbl!)"
// contentLbl!.text = "contentLbl?.textColor = UIColor.lightGraycontentLbl?.font = UIFont.systemFont(ofSize: 11)contentLbl?.numberOfLines = 0introView?.addSubview(contentLbl!)"
contentLbl
!.
text
=
"
\(
String
(
describing
:
response
.
pois
.
first
!.
province
!
)
)\(
String
(
describing
:
response
.
pois
.
first
!.
city
!
)
)\(
String
(
describing
:
response
.
pois
.
first
!.
district
!
)
)\(
String
(
describing
:
response
.
pois
.
first
!.
address
!
)
)
"
contentLbl
!.
text
=
"
\(
String
(
describing
:
response
.
pois
.
first
!.
province
!
)
)\(
String
(
describing
:
response
.
pois
.
first
!.
city
!
)
)\(
String
(
describing
:
response
.
pois
.
first
!.
district
!
)
)\(
String
(
describing
:
response
.
pois
.
first
!.
address
!
)
)
"
let
t
=
getStrHeight
(
str
:
titleLbl
!.
text
!
,
fontSize
:
13
)
let
t
=
getStrHeight
(
str
:
titleLbl
!.
text
!
,
fontSize
:
13
)
let
c
=
getStrHeight
(
str
:
contentLbl
!.
text
!
,
fontSize
:
11
)
let
c
=
getStrHeight
(
str
:
contentLbl
!.
text
!
,
fontSize
:
11
)
titleLbl
?
.
snp_updateConstraints
({
(
make
)
in
titleLbl
?
.
snp_updateConstraints
({
(
make
)
in
make
.
top
.
equalTo
(
7
)
make
.
top
.
equalTo
(
7
)
...
@@ -169,6 +169,9 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
...
@@ -169,6 +169,9 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
make
.
width
.
equalTo
(
w
)
make
.
width
.
equalTo
(
w
)
make
.
height
.
equalTo
(
t
+
c
+
20
)
make
.
height
.
equalTo
(
t
+
c
+
20
)
})
})
}
}
func
getStrHeight
(
str
:
String
,
fontSize
:
CGFloat
)
->
CGFloat
{
func
getStrHeight
(
str
:
String
,
fontSize
:
CGFloat
)
->
CGFloat
{
let
lbl
=
UILabel
()
let
lbl
=
UILabel
()
...
@@ -181,18 +184,18 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
...
@@ -181,18 +184,18 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
}
}
let
viewSize
=
CGSize
(
width
:
w
,
height
:
CGFloat
(
MAXFLOAT
))
let
viewSize
=
CGSize
(
width
:
w
,
height
:
CGFloat
(
MAXFLOAT
))
let
font
=
UIFont
.
systemFont
(
ofSize
:
13
)
let
font
=
UIFont
.
systemFont
(
ofSize
:
13
)
return
(
str
as
NSString
)
.
boundingRect
(
with
:
viewSize
,
options
:
[
.
usesLineFragmentOrigin
],
attributes
:
[
NSAttributedString
.
Key
.
font
:
font
],
context
:
nil
)
.
height
return
(
str
as
NSString
)
.
boundingRect
(
with
:
viewSize
,
options
:
[
.
usesLineFragmentOrigin
],
attributes
:
[
NSAttributedString
.
Key
.
font
:
font
],
context
:
nil
)
.
height
}
}
//移动后刷新
//移动后刷新
func
mapView
(
_
mapView
:
MAMapView
!
,
mapDidMoveByUser
wasUserAction
:
Bool
)
{
func
mapView
(
_
mapView
:
MAMapView
!
,
mapDidMoveByUser
wasUserAction
:
Bool
)
{
let
req
=
AMapPOIAroundSearchRequest
()
let
req
=
AMapPOIAroundSearchRequest
()
//地址
//地址
req
.
location
=
AMapGeoPoint
.
location
(
withLatitude
:
CGFloat
(
mapView
.
centerCoordinate
.
latitude
),
longitude
:
CGFloat
(
mapView
.
centerCoordinate
.
longitude
))
req
.
location
=
AMapGeoPoint
.
location
(
withLatitude
:
CGFloat
(
mapView
.
centerCoordinate
.
latitude
),
longitude
:
CGFloat
(
mapView
.
centerCoordinate
.
longitude
))
req
.
requireExtension
=
true
req
.
requireExtension
=
true
search
.
aMapPOIAroundSearch
(
req
)
search
.
aMapPOIAroundSearch
(
req
)
print
(
mapView
.
centerCoordinate
.
latitude
,
mapView
.
centerCoordinate
.
longitude
,
bd_encrypt
(
gg_lat
:
mapView
.
centerCoordinate
.
latitude
,
gg_lon
:
mapView
.
centerCoordinate
.
longitude
))
}
}
var
annotation
:
MAPointAnnotation
?
=
nil
var
annotation
:
MAPointAnnotation
?
=
nil
...
@@ -224,12 +227,22 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
...
@@ -224,12 +227,22 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
annotationView
!.
image
=
UIImage
(
named
:
"dingzhen"
)
annotationView
!.
image
=
UIImage
(
named
:
"dingzhen"
)
//设置中心点偏移,使得标注底部中间点成为经纬度对应点
//设置中心点偏移,使得标注底部中间点成为经纬度对应点
annotationView
!.
centerOffset
=
CGPoint
(
x
:
0
,
y
:
-
15
);
annotationView
!.
centerOffset
=
CGPoint
(
x
:
0
,
y
:
-
15
);
return
annotationView
!
return
annotationView
!
}
}
return
nil
return
nil
}
}
//火星坐标系 (GCJ-02)转百度坐标系 (BD-09)算法
func
bd_encrypt
(
gg_lat
:
Double
,
gg_lon
:
Double
)
->
(
bd_lat
:
Double
,
bd_lon
:
Double
)
{
let
x_pi
=
3.14159265358979
*
3000.0
/
180.0
let
x
=
gg_lon
let
y
=
gg_lat
let
z
=
sqrt
(
x
*
x
+
y
*
y
)
+
0.00002
*
sin
(
y
*
x_pi
)
let
theta
=
atan2
(
y
,
x
)
+
0.000003
*
cos
(
x
*
x_pi
)
let
bdlon
=
z
*
cos
(
theta
)
+
0.0065
let
bdlat
=
z
*
sin
(
theta
)
+
0.006
return
(
bdlat
,
bdlon
)
}
}
}
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