Commit 4ecc9c91 authored by lujunye's avatar lujunye

补充高德转百度坐标方法

parent b65cc90e
......@@ -123,7 +123,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
introView?.addSubview(contentLbl!)
}
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!))"
let t = getStrHeight(str: titleLbl!.text!, fontSize: 13)
......@@ -169,6 +169,9 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
make.width.equalTo(w)
make.height.equalTo(t+c+20)
})
}
func getStrHeight(str:String,fontSize:CGFloat) -> CGFloat{
let lbl = UILabel()
......@@ -192,7 +195,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
req.location = AMapGeoPoint.location(withLatitude: CGFloat(mapView.centerCoordinate.latitude), longitude: CGFloat(mapView.centerCoordinate.longitude))
req.requireExtension = true
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
......@@ -227,9 +230,19 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
return annotationView!
}
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)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment