| | |
| | | import UIKit |
| | | import GoogleMaps |
| | | |
| | | |
| | | let UpdateMap_Noti = Notification.Name.init("UpdateMap_Noti") |
| | | |
| | | class HomeDetailMapVC: BaseViewController { |
| | | |
| | | private var troubleBtn:UIButton! |
| | |
| | | |
| | | } |
| | | |
| | | override func setRx() { |
| | | NotificationCenter.default.rx.notification(UpdateMap_Noti).take(until: self.rx.deallocated).subscribe(onNext: {[weak self] noti in |
| | | if let tuple = noti.object as? (CLLocationCoordinate2D?,CLLocationCoordinate2D?){ |
| | | self?.updateBounds(carCoordinate: tuple.0, terminalCoordinate: tuple.1) |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | |
| | | required init(orderId:String) { |
| | | super.init(nibName: nil, bundle: nil) |
| | | self.orderId = orderId |
| | |
| | | override func viewDidAppear(_ animated: Bool) { |
| | | super.viewDidAppear(animated) |
| | | view.addSubview(mapView) |
| | | updateBounds(carCoordinate: CLLocationCoordinate2D(latitude: 30.572961, longitude: 104.166301), terminalCoordinate: CLLocationCoordinate2D(latitude: 30.572995, longitude: 104.066315)) |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | func updateBounds(carCoordinate:CLLocationCoordinate2D,terminalCoordinate:CLLocationCoordinate2D){ |
| | | destionMarker.position = terminalCoordinate |
| | | carMarker.position = carCoordinate |
| | | destionMarker.map = mapView |
| | | carMarker.map = mapView |
| | | func updateBounds(carCoordinate:CLLocationCoordinate2D?,terminalCoordinate:CLLocationCoordinate2D?){ |
| | | |
| | | let bounds = GMSCoordinateBounds(coordinate: carCoordinate, coordinate: terminalCoordinate) |
| | | let update = GMSCameraUpdate.fit(bounds, with: UIEdgeInsets(top: 30, left: 30, bottom: 30, right: 30)) |
| | | mapView.moveCamera(update) |
| | | updatePath(start: carCoordinate, terminal: terminalCoordinate) |
| | | var centerCoordiante:CLLocationCoordinate2D? |
| | | |
| | | if carCoordinate != nil{ |
| | | carMarker.position = carCoordinate! |
| | | carMarker.map = mapView |
| | | centerCoordiante = carCoordinate |
| | | } |
| | | |
| | | if terminalCoordinate != nil{ |
| | | destionMarker.position = terminalCoordinate! |
| | | destionMarker.map = mapView |
| | | centerCoordiante = terminalCoordinate |
| | | } |
| | | |
| | | if carCoordinate != nil && terminalCoordinate != nil{ |
| | | let bounds = GMSCoordinateBounds(coordinate: carCoordinate!, coordinate: terminalCoordinate!) |
| | | let update = GMSCameraUpdate.fit(bounds, with: UIEdgeInsets(top: 30, left: 30, bottom: 30, right: 30)) |
| | | mapView.moveCamera(update) |
| | | updatePath(start: carCoordinate!, terminal: terminalCoordinate!) |
| | | }else if centerCoordiante != nil{ |
| | | mapView.animate(toLocation: centerCoordiante!) |
| | | } |
| | | } |
| | | |
| | | private func updatePath(start:CLLocationCoordinate2D,terminal:CLLocationCoordinate2D){ |
| | |
| | | |
| | | polyline.path = path |
| | | polyline.map = mapView |
| | | |
| | | |
| | | // let span = GMSStyleSpan(style: .gradient(from: UIColor(hexStr: "#FED703"), to: .red)) |
| | | // polyline.spans = [span] |
| | | |
| | | // GoogleServices.directionsLine(origin: GoogleServices.DirectionType.byCoordinates(start), destination: GoogleServices.DirectionType.byCoordinates(terminal)).subscribe(onNext: {data in |
| | | // |
| | | // |
| | | // }) { error in |
| | | // |
| | | // }.disposed(by: disposeBag) |
| | | |
| | | } |
| | | |
| | | @objc func troubleAction(){ |