Commit f1875c7f authored by lujunye's avatar lujunye

调整地图

parent 8beca19e
...@@ -284,6 +284,8 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -284,6 +284,8 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
} }
var carModel:cityCartDataModel? var carModel:cityCartDataModel?
fileprivate func extractedFunc() { fileprivate func extractedFunc() {
HUD.flash(.progress) HUD.flash(.progress)
cityCart(["user_token":UserToken as Any,"nonce_str":String.randomStr(len:30) as Any,"city_id":city_id as Any], success: { (data) in cityCart(["user_token":UserToken as Any,"nonce_str":String.randomStr(len:30) as Any,"city_id":city_id as Any], success: { (data) in
...@@ -296,8 +298,13 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -296,8 +298,13 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
} }
if self.carTypesArr.count == 0 { if self.carTypesArr.count == 0 {
HUD.flash(.label("暂无车型可供选择"), delay: 1.2) HUD.flash(.label("暂无车型可供选择"), delay: 1.2)
return
} }
let cell = self.hListView.cellForRow(at: IndexPath(row: 0, section: 0)) as! HLLTopCell
cell.idx = 0
cell.scrollView?.setContentOffset(CGPoint(x: 0, y: 0), animated: false)
cell.tjLbl.text = "--"
cell.sizeLbl.text = "--"
cell.weightLbl.text = "--"
let view = self.hListView.footerView(forSection: 0) let view = self.hListView.footerView(forSection: 0)
view?.layoutIfNeeded() view?.layoutIfNeeded()
self.setBtnUI(carTypesArr: self.carTypesArr,view: self.topCarBtnSelectView) self.setBtnUI(carTypesArr: self.carTypesArr,view: self.topCarBtnSelectView)
...@@ -422,10 +429,9 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -422,10 +429,9 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
make.height.equalTo(30) make.height.equalTo(30)
make.width.equalTo(self.locBtn.bounds.size.width) make.width.equalTo(self.locBtn.bounds.size.width)
}) })
print("abc == ",adrArr.count)
if adrArr.count == 0 { if adrArr.count == 0 {
city_id = loc.city_id! city_id = loc.city_id!
print("abc == ")
extractedFunc() extractedFunc()
return return
} }
...@@ -734,7 +740,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -734,7 +740,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
let model = data as! cityListModel let model = data as! cityListModel
self.adrDatas.removeAll() self.adrDatas.removeAll()
for item in model.data! { for item in model.data! {
if self.selectLoc.contains("\(item.name!)") || self.selectLoc.localizedLowercase.contains("\(item.name_en!)") { if self.setCityId(name1: item.name!, name2: item.name_en!) {
self.loc = item self.loc = item
} }
self.adrDatas.append(item) self.adrDatas.append(item)
...@@ -764,7 +770,13 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -764,7 +770,13 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
} }
} }
func setCityId(name1:String,name2:String)->Bool{
if selectLoc.contains(name1) || selectLoc.localizedLowercase.contains(name2){
return true
}else{
return false
}
}
func getUICarList(){ func getUICarList(){
rightBtn.isSelected = true rightBtn.isSelected = true
leftBtn.isSelected = false leftBtn.isSelected = false
...@@ -773,7 +785,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -773,7 +785,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
locBtn.isUserInteractionEnabled = true locBtn.isUserInteractionEnabled = true
for item in adrDatas { for item in adrDatas {
if selectLoc.contains("\(item.name!)") || selectLoc.localizedLowercase.contains("\(item.name_en!)"){ if setCityId(name1: item.name!, name2: item.name_en!){
city_id = item.city_id! city_id = item.city_id!
} }
} }
...@@ -803,7 +815,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -803,7 +815,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
self.adrDatas.removeAll() self.adrDatas.removeAll()
for item in model.data! { for item in model.data! {
if self.selectLoc.contains("\(item.name!)") || self.selectLoc.localizedLowercase.contains("\(item.name_en!)") { if self.setCityId(name1: item.name!, name2: item.name_en!){
self.loc = item self.loc = item
} }
self.adrDatas.append(item) self.adrDatas.append(item)
...@@ -1199,7 +1211,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -1199,7 +1211,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
self.adrDatas.removeAll() self.adrDatas.removeAll()
for item in model.data! { for item in model.data! {
if self.selectLoc.contains("\(item.name!)") || self.selectLoc.localizedLowercase.contains("\(item.name_en!)") { if self.setCityId(name1: item.name!, name2: item.name_en!) {
self.loc = item self.loc = item
} }
self.adrDatas.append(item) self.adrDatas.append(item)
...@@ -1368,7 +1380,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -1368,7 +1380,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
self.adrDatas.removeAll() self.adrDatas.removeAll()
for item in model.data! { for item in model.data! {
if self.selectLoc.contains("\(item.name!)") || self.selectLoc.localizedLowercase.contains("\(item.name_en!)") { if self.setCityId(name1: item.name!, name2: item.name_en!) {
self.loc = item self.loc = item
} }
self.adrDatas.append(item) self.adrDatas.append(item)
......
...@@ -13,6 +13,8 @@ import MAMapKit ...@@ -13,6 +13,8 @@ import MAMapKit
import AMapSearchKit import AMapSearchKit
import LGButton import LGButton
import IQKeyboardManagerSwift import IQKeyboardManagerSwift
protocol SJMapViewControllerDelegate { protocol SJMapViewControllerDelegate {
func SJMapViewControllerSelectArd(adr:String) func SJMapViewControllerSelectArd(adr:String)
} }
...@@ -47,7 +49,10 @@ class SJMapViewController: UIViewController,AMapLocationManagerDelegate,MAMapVie ...@@ -47,7 +49,10 @@ class SJMapViewController: UIViewController,AMapLocationManagerDelegate,MAMapVie
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)
let coo = JZLocationConverter.wgs84(toGcj02: CLLocationCoordinate2D(latitude: lat, longitude: lng))
initMapView(lat: coo.latitude, lng: coo.longitude)
initSearch() initSearch()
initUI() initUI()
} }
...@@ -277,7 +282,7 @@ class SJMapViewController: UIViewController,AMapLocationManagerDelegate,MAMapVie ...@@ -277,7 +282,7 @@ class SJMapViewController: UIViewController,AMapLocationManagerDelegate,MAMapVie
searchBr.delegate = self searchBr.delegate = self
searchBr.delegateL = self searchBr.delegateL = self
} }
let locationM = AMapLocationManager()
func initMapView(lat:CLLocationDegrees,lng:CLLocationDegrees) { func initMapView(lat:CLLocationDegrees,lng:CLLocationDegrees) {
let btmView = UIView() let btmView = UIView()
self.view.addSubview(btmView) self.view.addSubview(btmView)
...@@ -287,6 +292,11 @@ class SJMapViewController: UIViewController,AMapLocationManagerDelegate,MAMapVie ...@@ -287,6 +292,11 @@ class SJMapViewController: UIViewController,AMapLocationManagerDelegate,MAMapVie
} }
initBtmView(view: btmView) initBtmView(view: btmView)
// locationM.desiredAccuracy = kCLLocationAccuracyBest
// locationM.locationTimeout = 2
// locationM.reGeocodeTimeout = 2
AMapServices.shared().enableHTTPS = true AMapServices.shared().enableHTTPS = true
mapView = MAMapView() mapView = MAMapView()
mapView.delegate = self mapView.delegate = self
...@@ -311,7 +321,9 @@ class SJMapViewController: UIViewController,AMapLocationManagerDelegate,MAMapVie ...@@ -311,7 +321,9 @@ class SJMapViewController: UIViewController,AMapLocationManagerDelegate,MAMapVie
make.bottom.equalTo(btmView.snp_top).offset(-13.5) make.bottom.equalTo(btmView.snp_top).offset(-13.5)
} }
} }
// deinit {
// locationM.stopUpdatingLocation()
// }
func initSearch() { func initSearch() {
search = AMapSearchAPI() search = AMapSearchAPI()
search.delegate = self search.delegate = self
......
...@@ -337,13 +337,15 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo ...@@ -337,13 +337,15 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
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
let coo = JZLocationConverter.wgs84(toGcj02: CLLocationCoordinate2D(latitude: (location?.coordinate.latitude)!, longitude: (location?.coordinate.longitude)!))
if lat == 0 && lng == 0 { if lat == 0 && lng == 0 {
lat = location?.coordinate.latitude as! CLLocationDegrees lat = coo.latitude
lng = location?.coordinate.longitude as! CLLocationDegrees lng = coo.longitude
mapView.centerCoordinate = CLLocationCoordinate2DMake((lat),(lng))
mapView.centerCoordinate = CLLocationCoordinate2DMake(lat,lng)
} }
tempLat = location?.coordinate.latitude as! CLLocationDegrees tempLat = coo.latitude
tempLng = location?.coordinate.longitude as! CLLocationDegrees tempLng = coo.longitude
} }
func setMapCenter(lat:CLLocationDegrees,lng:CLLocationDegrees) { func setMapCenter(lat:CLLocationDegrees,lng:CLLocationDegrees) {
......
...@@ -59,7 +59,7 @@ class HLLTopCell: UITableViewCell,UIScrollViewDelegate { ...@@ -59,7 +59,7 @@ class HLLTopCell: UITableViewCell,UIScrollViewDelegate {
@objc func otherClick(_ sender: UIButton) { @objc func otherClick(_ sender: UIButton) {
print("abc")
} }
func scrollViewDidScroll(_ scrollView: UIScrollView) { func scrollViewDidScroll(_ scrollView: UIScrollView) {
leftBtn.isHidden = false leftBtn.isHidden = false
...@@ -142,7 +142,10 @@ class HLLTopCell: UITableViewCell,UIScrollViewDelegate { ...@@ -142,7 +142,10 @@ class HLLTopCell: UITableViewCell,UIScrollViewDelegate {
let view = UIView(frame: CGRect(x: CGFloat(i) * (scViewBg.bounds.size.width), y:0, width: scViewBg.bounds.size.width, height: scViewBg.bounds.size.height)) let view = UIView(frame: CGRect(x: CGFloat(i) * (scViewBg.bounds.size.width), y:0, width: scViewBg.bounds.size.width, height: scViewBg.bounds.size.height))
let model = datas[i] let model = datas[i]
let imgV = UIImageView() let imgV = UIImageView()
// imgV.image =
view.addSubview(imgV) view.addSubview(imgV)
SDWebImageDownloader.shared.downloadImage(with: URL(string:model.img_url_high_light!), options: .continueInBackground, progress: { (a, b, nil) in SDWebImageDownloader.shared.downloadImage(with: URL(string:model.img_url_high_light!), options: .continueInBackground, progress: { (a, b, nil) in
}) { (img, data, err, true) in }) { (img, data, err, true) in
imgV.image = img imgV.image = img
...@@ -154,6 +157,14 @@ class HLLTopCell: UITableViewCell,UIScrollViewDelegate { ...@@ -154,6 +157,14 @@ class HLLTopCell: UITableViewCell,UIScrollViewDelegate {
make.centerX.equalTo(view.snp.centerX) make.centerX.equalTo(view.snp.centerX)
make.centerY.equalTo(view.snp.centerY) make.centerY.equalTo(view.snp.centerY)
} }
}else{
imgV.image = UIImage(named: "lmn_tool_image")
imgV.snp.makeConstraints { (make) in
make.width.equalTo(self.scViewBg.bounds.size.width)
make.height.equalTo(self.scViewBg.bounds.size.height)
make.centerX.equalTo(view.snp.centerX)
make.centerY.equalTo(view.snp.centerY)
}
} }
} }
scrollView?.addSubview(view) scrollView?.addSubview(view)
......
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