From aad7ea65994d33014308fd24dadc4308b35053e6 Mon Sep 17 00:00:00 2001 From: 杨锴 <841720330@qq.com> Date: 星期三, 30 十月 2024 14:59:30 +0800 Subject: [PATCH] fix --- XQMuse/Root/Pavilion/VC/PavilionDetailVC.swift | 74 +++++++++++++++++++++++++++++++++++++ 1 files changed, 74 insertions(+), 0 deletions(-) diff --git a/XQMuse/Root/Pavilion/VC/PavilionDetailVC.swift b/XQMuse/Root/Pavilion/VC/PavilionDetailVC.swift index dd92200..9732bdd 100644 --- a/XQMuse/Root/Pavilion/VC/PavilionDetailVC.swift +++ b/XQMuse/Root/Pavilion/VC/PavilionDetailVC.swift @@ -8,6 +8,7 @@ import UIKit import JQTools import WebKit +import MapKit class PavilionDetailVC: BaseVC { @@ -21,6 +22,7 @@ @IBOutlet weak var cons_webHei: NSLayoutConstraint! private var id:Int! + private var detailModel:PavilionDetailModel? override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) @@ -44,6 +46,7 @@ Services.getPavlilonDetail(id: id).subscribe(onNext: {data in if let m = data.data{ + self.detailModel = m self.label_title.text = m.hallName self.label_phone.text = m.contactNumber self.label_address.text = m.addressDetail @@ -64,6 +67,77 @@ }).disposed(by: disposeBag) } + + @IBAction func gotoThereAction(_ sender: Any) { + + guard let model = detailModel else {return} + + let items = JQ_MapNavigationTool.mapList() + var formatItems = items.map { type in + switch type { + case .BaiduMap:return "百度地图" //BD-09 + case .Amap:return "高德地图" //GCJ-02 + case .GoogleMap:return "谷歌地图" //GCJ-02 + case .qqMap:return "腾讯地图" //GCJ-02 + } + } + formatItems.insert("苹果地图", at: 0) + + CommonAlertSheetView.show(items: formatItems) { index in + switch index{ + case 0: + let item = MKMapItem(placemark: MKPlacemark(coordinate: CLLocationCoordinate2D(latitude: CLLocationDegrees(model.latitude), longitude: CLLocationDegrees(model.longitude)))) + item.name = model.hallName + item.openInMaps(launchOptions: [MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeDriving]) + case 1: + var components = URLComponents() + components.scheme = "iosamap" + components.host = "path" + components.queryItems = [URLQueryItem]() + components.queryItems?.append(URLQueryItem(name: "sourceApplication", value: "疗愈")) + components.queryItems?.append(URLQueryItem(name: "dlat", value: "\(model.latitude)")) + components.queryItems?.append(URLQueryItem(name: "dlon", value: "\(model.longitude)")) + components.queryItems?.append(URLQueryItem(name: "dname", value: model.hallName)) + UIApplication.shared.open(components.url!) + case 2: + var components = URLComponents() + components.scheme = "comgooglemaps" + components.host = "" + components.queryItems = [URLQueryItem]() + components.queryItems?.append(URLQueryItem(name: "daddr", value: "\(model.latitude),\(model.longitude)")) + components.queryItems?.append(URLQueryItem(name: "zoom", value: "14")) + components.queryItems?.append(URLQueryItem(name: "views", value: "traffic")) + components.queryItems?.append(URLQueryItem(name: "resume", value: "true")) + UIApplication.shared.open(components.url!) + case 3: + var components = URLComponents() + components.scheme = "baidumap" + components.host = "map" + components.path = "/direction" + components.queryItems = [URLQueryItem]() + components.queryItems?.append(URLQueryItem(name: "origin", value: "{{我的位置}}")) + components.queryItems?.append(URLQueryItem(name: "destination", value: "latlng:\(model.latitude),\(model.longitude)|name:\(model.hallName)")) + components.queryItems?.append(URLQueryItem(name: "coord_type", value: "gcj02")) + components.queryItems?.append(URLQueryItem(name: "mode", value: "driving")) + + UIApplication.shared.open(components.url!) + case 4: + var components = URLComponents() + components.scheme = "qqmap" + components.host = "map" + components.path = "/routeplan" + components.queryItems = [URLQueryItem]() + components.queryItems?.append(URLQueryItem(name: "fromcoord", value: "CurrentLocation")) + components.queryItems?.append(URLQueryItem(name: "type", value: "drive")) + components.queryItems?.append(URLQueryItem(name: "to", value: model.hallName)) + components.queryItems?.append(URLQueryItem(name: "tocoord", value: "\(model.latitude),\(model.longitude)")) + UIApplication.shared.open(components.url!) + default:break + } + } + } + + override func setRx() { webView.scrollView.rx.observe(CGSize.self, "contentSize").map { (size) -> CGFloat? in if let size = size{ -- Gitblit v1.7.1