Commit 9e4bd83f authored by lujunye's avatar lujunye

输入搜索实现

parent aa6d427a
......@@ -20,12 +20,15 @@ protocol ToAndFormSelectViewControllerDelegate {
class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLocationManagerDelegate, AMapSearchDelegate, UISearchBarDelegate, SearchBarViewDelegate,UITableViewDelegate,UITableViewDataSource,CityListViewControllerDelegate,HuoLaLaDiZhiCellDelegate{
func HuoLaLaDiZhiCellBtnClick(model: citySearchDataPoiChildrenModel,cityStr:String) {
citySelectBtn.setTitle(cityStr, for: .normal)
mapView.centerCoordinate = CLLocationCoordinate2DMake((model.location?.lat)!,(model.location?.lon)!)
mapView.centerCoordinate = BLCoordinatesChangeHelper.shared()?.bl_wgs84togcj02((model.location?.lon)!, andLat: (model.location?.lat)!) as! CLLocationCoordinate2D
isMove = false
adrName = model.name!
detailAdr = model.address!
searchList.isHidden = true
closeBtn.isHidden = true
listViewBG.isHidden = true
IQKeyboardManager.shared.resignFirstResponder()
print("1")
}
func CityListViewControllerLocSelect(loc: cityListDataModel) {
......@@ -39,12 +42,12 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
@IBAction func citySelectClick(_ sender: UIButton) {
let vc = CityListViewController()
vc.adrDatas = adrDatas!
vc.locatStr = cityName as String
vc.delegate = self
self.navigationController?.pushViewController(vc, animated: true)
let vc = CityListViewController()
vc.adrDatas = adrDatas!
vc.locatStr = cityName as String
vc.delegate = self
self.navigationController?.pushViewController(vc, animated: true)
}
......@@ -166,7 +169,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
let model = searchAdrDatas[indexPath.row]
citySelectBtn.setTitle(model.city!, for: .normal)
let locData = BLCoordinatesChangeHelper.shared()?.bl_wgs84togcj02(model.location!.lon!, andLat: model.location!.lat!)
isMove = false
adrName = model.name!
......@@ -196,7 +199,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
searchBr.cornerRadius = 35/2.0
searchBr.delegate = self
searchBr.delegateL = self
// searchBr.returnKeyType = .done
searchBr.returnKeyType = .done
if idx != 0 {
sureSelectLbl.text = "确认收货地"
......@@ -238,7 +241,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
mapView.zoomLevel = 16
mapView.isZoomEnabled = true
self.mapView.centerCoordinate = CLLocationCoordinate2DMake(lat,lng)
print("==",lat,lng)
MapBgView.addSubview(mapView!)
......@@ -337,7 +340,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
}
titleLbl!.text = response.pois.first?.name
titleLbl!.text = response.pois.first?.name
cityName = response.pois.first?.city as! NSString
locName = response.pois.first?.name as! String
......@@ -437,7 +440,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
req.requireExtension = true
search.aMapPOIAroundSearch(req)
print("6")
}
var annotation:MAPointAnnotation? = nil
......@@ -449,7 +452,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
print("7",mapView.centerCoordinate.latitude)
search.aMapReGoecodeSearch(request)
request.requireExtension = true
if annotation == nil
{
let pointAnnotation = MAPointAnnotation()
......@@ -503,27 +506,34 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
}
searchBar.resignFirstResponder()
let dict = ["user_token":UserToken as Any,
"nonce_str":String.randomStr(len: 30) as Any,
"kw":keyword as Any
]
citySearch(dict, success: { (data) in
let model = data as! citySearchModel
self.searchAdrDatas.removeAll()
if (model.data?.poi!.count)! > 0 {
for item in model.data!.poi! {
self.searchAdrDatas.append(item)
}
self.searchList.isHidden = false
self.searchList.reloadData()
}
}) { (err) in
}
}
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
// keyword = searchText
keyword = searchText
if keyword.count > 0 {
searchList.isHidden = false
let dict = ["user_token":UserToken as Any,
"nonce_str":String.randomStr(len: 30) as Any,
"kw":keyword as Any
]
citySearch(dict, success: { (data) in
let model = data as! citySearchModel
self.searchAdrDatas.removeAll()
if (model.data?.poi!.count)! > 0 {
for item in model.data!.poi! {
self.searchAdrDatas.append(item)
}
self.searchList.isHidden = false
self.searchList.reloadData()
}
}) { (err) in
}
}else{
searchList.isHidden = true
}
}
func searchBarShouldBeginEditing(_ searchBar: UISearchBar) -> Bool {
......@@ -533,5 +543,5 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
return true
}
}
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