123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- //
- // PublishAddAddressController.swift
- // RainbowPlanet
- //
- // Created by Christopher on 2019/6/17.
- // Copyright © 2019 RainbowPlanet. All rights reserved.
- //
- import UIKit
- class PublishAddAddressController: BaseViewController {
-
- override func didReceiveMemoryWarning() {
- super.didReceiveMemoryWarning()
- }
-
- deinit {
- NXLLog("deinit")
- }
-
- typealias SelectLocationClosure = (_ address:String) -> Void
- var selectLocationClosure : SelectLocationClosure?
-
- var locationAddress: String?
- /// 纬度
- var latitude : String = LocationModel.shared().object()?.latitude ?? "34.20840377740726"
- /// 经度
- var longitude : String = LocationModel.shared().object()?.longitude ?? "108.96265686107972"
- /// poiList
- var poiList: Array<SwiftLocationPOIModel> = LocationModel.shared().object()?.poiList ?? []
-
- override func viewDidLoad() {
- super.viewDidLoad()
- setupViews()
- setupLayouts()
-
- BaiduMapManager.shared.startLocation()
- BaiduMapManager.shared.locationSuccessBlock = {
- [weak self] in
- self?.poiList = LocationModel.shared().object()?.poiList ?? []
- self?.addressPOIView.poiList = self?.poiList
- }
- BaiduMapManager.shared.locationFalseBlock = { SwiftProgressHUD.shared().showText("定位失败")
- }
- }
-
- override func viewWillAppear(_ animated: Bool) {
- navigationController?.interactivePopGestureRecognizer?.isEnabled = false
- }
-
- override func viewWillDisappear(_ animated: Bool) {
- navigationController?.interactivePopGestureRecognizer?.isEnabled = true
- }
-
- override func setupViews() {
- navigationBar.leftButton.isHidden = true
- navigationBar.addSubview(navigationBarView)
- view.addSubview(addressPOIView)
- view.insertSubview(navigationBar, aboveSubview: addressPOIView)
- addressPOIView.locationAddress = locationAddress
- addressPOIView.longitude = longitude
- addressPOIView.latitude = latitude
-
- }
-
- override func setupLayouts() {
- navigationBarView.snp.makeConstraints { (make) in
- make.top.equalTo(kSafeStatusBarHeight)
- make.bottom.left.right.equalToSuperview()
- }
- addressPOIView.snp.makeConstraints { (make) in
- make.top.equalTo(navigationBar.snp.bottom)
- make.left.right.bottom.equalToSuperview()
- }
- }
-
- private lazy var navigationBarView: SearchAddrNavigationbarView = {
- let navigationBarView = SearchAddrNavigationbarView()
- navigationBarView.cancelBlock = {
- [weak self] in
- self?.navigationController?.popViewController(animated: true)
- }
- navigationBarView.searchBlock = {
- [weak self] keyword in
- self?.addressPOIView.searchPOI(keyword)
- }
- return navigationBarView
- }()
-
- private lazy var addressPOIView: PublishAddressPOIView = {
- let addressPOIView = PublishAddressPOIView()
- addressPOIView.didSelectBlock = { [weak self] (latitude:String,longitude:String,address:String) in
- if let selectLocationClosure = self?.selectLocationClosure {
- selectLocationClosure(address)
- self?.navigationController?.popViewController(animated: true)
- }
-
- }
- return addressPOIView
- }()
-
- }
|