younger_times
2023-05-06 2a8d65d91258689d2f51448517245b247a08a61b
Google Map
8个文件已修改
7个文件已添加
425 ■■■■■ 已修改文件
BrokerDriver.xcodeproj/project.pbxproj 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BrokerDriver/Assets.xcassets/Icon/marker_car.imageset/Contents.json 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BrokerDriver/Assets.xcassets/Icon/marker_car.imageset/marker_car@2x.png 补丁 | 查看 | 原始文档 | blame | 历史
BrokerDriver/Assets.xcassets/Icon/marker_car.imageset/marker_car@3x.png 补丁 | 查看 | 原始文档 | blame | 历史
BrokerDriver/Assets.xcassets/Icon/marker_terminate.imageset/Contents.json 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BrokerDriver/Assets.xcassets/Icon/marker_terminate.imageset/marker_terminate@2x.png 补丁 | 查看 | 原始文档 | blame | 历史
BrokerDriver/Assets.xcassets/Icon/marker_terminate.imageset/marker_terminate@3x.png 补丁 | 查看 | 原始文档 | blame | 历史
BrokerDriver/Def.swift 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BrokerDriver/Home/VC/HomeDetailContentVC.swift 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BrokerDriver/Home/VC/HomeDetailContentVC.xib 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BrokerDriver/Home/VC/HomeDetailMapVC.swift 87 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BrokerDriver/Models/GoogleModel.swift 152 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BrokerDriver/Network/NetworkRequest.swift 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BrokerDriver/Network/Services.swift 68 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BrokerDriver/SceneDelegate.swift 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BrokerDriver.xcodeproj/project.pbxproj
@@ -76,6 +76,7 @@
        139F0F8529F68B90007D9EA4 /* BaseTCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 139F0F8429F68B90007D9EA4 /* BaseTCell.swift */; };
        13A0133D29FBB41000537A4F /* PhotoPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13A0133C29FBB41000537A4F /* PhotoPickerView.swift */; };
        13A0133F29FBB41700537A4F /* PhotoPickerView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13A0133E29FBB41700537A4F /* PhotoPickerView.xib */; };
        13F47D422A05F5F900B8AB63 /* GoogleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13F47D412A05F5F900B8AB63 /* GoogleModel.swift */; };
        13F536B229F7D0DF00A7937A /* NoteContentTCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13F536B029F7D0DF00A7937A /* NoteContentTCell.swift */; };
        13F536B329F7D0DF00A7937A /* NoteContentTCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13F536B129F7D0DF00A7937A /* NoteContentTCell.xib */; };
        13F536B729F7D6CF00A7937A /* Services.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13F536B529F7D6CF00A7937A /* Services.swift */; };
@@ -164,6 +165,7 @@
        139F0F8429F68B90007D9EA4 /* BaseTCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseTCell.swift; sourceTree = "<group>"; };
        13A0133C29FBB41000537A4F /* PhotoPickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoPickerView.swift; sourceTree = "<group>"; };
        13A0133E29FBB41700537A4F /* PhotoPickerView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PhotoPickerView.xib; sourceTree = "<group>"; };
        13F47D412A05F5F900B8AB63 /* GoogleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoogleModel.swift; sourceTree = "<group>"; };
        13F536B029F7D0DF00A7937A /* NoteContentTCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteContentTCell.swift; sourceTree = "<group>"; };
        13F536B129F7D0DF00A7937A /* NoteContentTCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NoteContentTCell.xib; sourceTree = "<group>"; };
        13F536B529F7D6CF00A7937A /* Services.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Services.swift; sourceTree = "<group>"; };
@@ -417,6 +419,7 @@
            children = (
                13F536BA29F8CC0500A7937A /* UserModel.swift */,
                13F536C129F927FC00A7937A /* OrderModel.swift */,
                13F47D412A05F5F900B8AB63 /* GoogleModel.swift */,
            );
            path = Models;
            sourceTree = "<group>";
@@ -628,6 +631,7 @@
                135FD1F12A04A86B0048BE7A /* TroubleFootView.swift in Sources */,
                1309AE1129F7919900F5FA26 /* HomeDetailAttachVC.swift in Sources */,
                139F0F7A29F66EB7007D9EA4 /* HomeHeaderVC.swift in Sources */,
                13F47D422A05F5F900B8AB63 /* GoogleModel.swift in Sources */,
                138DA4D929F6305600A71FE7 /* LoginVC.swift in Sources */,
                13F536B829F7D6CF00A7937A /* NetworkRequest.swift in Sources */,
                13F536C229F927FC00A7937A /* OrderModel.swift in Sources */,
BrokerDriver/Assets.xcassets/Icon/marker_car.imageset/Contents.json
New file
@@ -0,0 +1,22 @@
{
  "images" : [
    {
      "idiom" : "universal",
      "scale" : "1x"
    },
    {
      "filename" : "marker_car@2x.png",
      "idiom" : "universal",
      "scale" : "2x"
    },
    {
      "filename" : "marker_car@3x.png",
      "idiom" : "universal",
      "scale" : "3x"
    }
  ],
  "info" : {
    "author" : "xcode",
    "version" : 1
  }
}
BrokerDriver/Assets.xcassets/Icon/marker_car.imageset/marker_car@2x.png
BrokerDriver/Assets.xcassets/Icon/marker_car.imageset/marker_car@3x.png
BrokerDriver/Assets.xcassets/Icon/marker_terminate.imageset/Contents.json
New file
@@ -0,0 +1,22 @@
{
  "images" : [
    {
      "idiom" : "universal",
      "scale" : "1x"
    },
    {
      "filename" : "marker_terminate@2x.png",
      "idiom" : "universal",
      "scale" : "2x"
    },
    {
      "filename" : "marker_terminate@3x.png",
      "idiom" : "universal",
      "scale" : "3x"
    }
  ],
  "info" : {
    "author" : "xcode",
    "version" : 1
  }
}
BrokerDriver/Assets.xcassets/Icon/marker_terminate.imageset/marker_terminate@2x.png
BrokerDriver/Assets.xcassets/Icon/marker_terminate.imageset/marker_terminate@3x.png
BrokerDriver/Def.swift
@@ -76,23 +76,6 @@
    hud.hide(animated: true, afterDelay: 1.7)
}
// MARK: -- Key
//extension UICollectionView{
//    public func jq_setEmptyView( _ noticeStr:String? = nil,image:UIImage? = UIImage(named: "icon_empty"),foregroundColor:UIColor = UIColor.gray,clouse:((EmptyDataSetView)->Void)? = nil) {
//        self.emptyDataSetView { (emptyDataSetView) in
//            emptyDataSetView.titleLabelString(NSAttributedString.init(string: (noticeStr != nil) ? noticeStr! : Localized("暂无数据"), attributes: [.font:UIFont.systemFont(ofSize: 16,weight: .medium), .foregroundColor:foregroundColor as Any]))
//                .image(image)
//                .dataSetBackgroundColor(UIColor.white)
//                .verticalOffset(-50)
//                .verticalSpace(0)
//                .shouldDisplay(true)
//                .shouldFadeIn(true)
//                .isTouchAllowed(true)
//                .isScrollAllowed(true)
//                .didTapContentView {
//
//                }
//            clouse?(emptyDataSetView)
//        }
//    }
//}
let GoogleAppKey = "AIzaSyBBW0XxW1FK7IXmmS7KFtAjX3o99eFPsss"
BrokerDriver/Home/VC/HomeDetailContentVC.swift
@@ -92,7 +92,10 @@
        }).disposed(by: disposeBag)
    }
    @IBAction func tapAction(_ sender: TapButton) {
    @IBAction func tapAction(_ sender: UIButton) {
        //到达码头:提示上传
        //运输中:上传POD
        //运回码头:提示上传
        print("---->")
    }
BrokerDriver/Home/VC/HomeDetailContentVC.xib
@@ -219,17 +219,25 @@
                                <constraint firstItem="Swf-mb-v0c" firstAttribute="top" secondItem="42Z-5A-7T8" secondAttribute="top" id="UTU-kB-XGi"/>
                            </constraints>
                        </view>
                        <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="JKR-Yv-Icp">
                            <rect key="frame" x="0.0" y="0.0" width="393" height="44"/>
                            <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
                            <connections>
                                <action selector="tapAction:" destination="-1" eventType="touchUpInside" id="9Sr-9z-Zu9"/>
                            </connections>
                        </button>
                    </subviews>
                    <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                    <constraints>
                        <constraint firstItem="JKR-Yv-Icp" firstAttribute="top" secondItem="ZL1-Nv-BlK" secondAttribute="top" id="0lF-S0-DDg"/>
                        <constraint firstItem="42Z-5A-7T8" firstAttribute="top" secondItem="ZL1-Nv-BlK" secondAttribute="top" id="5rC-co-RCj"/>
                        <constraint firstAttribute="trailing" secondItem="42Z-5A-7T8" secondAttribute="trailing" id="HbE-Sz-7Ie"/>
                        <constraint firstAttribute="height" constant="44" id="L3V-NS-6Zl"/>
                        <constraint firstAttribute="bottom" secondItem="JKR-Yv-Icp" secondAttribute="bottom" id="XE3-5E-pF3"/>
                        <constraint firstItem="42Z-5A-7T8" firstAttribute="leading" secondItem="ZL1-Nv-BlK" secondAttribute="leading" id="fsu-ga-8tu"/>
                        <constraint firstItem="JKR-Yv-Icp" firstAttribute="leading" secondItem="ZL1-Nv-BlK" secondAttribute="leading" id="tC5-NG-XHM"/>
                        <constraint firstAttribute="trailing" secondItem="JKR-Yv-Icp" secondAttribute="trailing" id="tgr-Db-gSy"/>
                    </constraints>
                    <connections>
                        <action selector="tapAction:" destination="-1" eventType="touchUpInside" id="DJ0-9e-7dK"/>
                    </connections>
                </view>
            </subviews>
            <viewLayoutGuide key="safeArea" id="nCn-el-ZCs"/>
BrokerDriver/Home/VC/HomeDetailMapVC.swift
@@ -1,16 +1,50 @@
//
//  HomeDetailMapVC.swift
//  BrokerDriver
//
//  Created by 无故事王国 on 2023/4/25.
//
    //
    //  HomeDetailMapVC.swift
    //  BrokerDriver
    //
    //  Created by 无故事王国 on 2023/4/25.
    //
import UIKit
import GoogleMaps
class HomeDetailMapVC: BaseViewController {
    private var troubleBtn:UIButton!
    private var orderId:String!
    private lazy var mapView:GMSMapView = {
        let map = GMSMapView()
        map.frame = CGRect(x: 0, y: 0, width: JQ_ScreenW, height: JQ_ScreenW * 0.6)
        map.mapType = .normal
        map.settings.scrollGestures = false
        map.settings.zoomGestures = false
        map.accessibilityElementsHidden = false
        map.isBuildingsEnabled = false
        map.settings.compassButton = true
        return map
    }()
    private lazy var destionMarker:GMSMarker = {
        let marker = GMSMarker()
        marker.title = "Terminal"
        marker.icon = UIImage(named: "marker_terminate")
        return marker
    }()
    private lazy var carMarker:GMSMarker = {
        let marker = GMSMarker()
        marker.title = "Car"
        marker.icon = UIImage(named: "marker_car")
        return marker
    }()
    private lazy var polyline:GMSPolyline = {
        let line = GMSPolyline()
        line.strokeWidth = 4.0
        line.strokeColor = UIColor(hexString: "#FED703")!
        line.geodesic = true
        return line
    }()
    override func viewDidLoad() {
        super.viewDidLoad()
@@ -24,6 +58,12 @@
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    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))
    }
@@ -49,6 +89,41 @@
        }
    }
    func updateBounds(carCoordinate:CLLocationCoordinate2D,terminalCoordinate:CLLocationCoordinate2D){
        destionMarker.position = terminalCoordinate
        carMarker.position = carCoordinate
        destionMarker.map = mapView
        carMarker.map = mapView
        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)
    }
    private func updatePath(start:CLLocationCoordinate2D,terminal:CLLocationCoordinate2D){
        let path = GMSMutablePath()
        path.add(start)
        path.add(terminal)
        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(){
        let vc = TroubleListVC(orderId: orderId)
        push(vc: vc)
BrokerDriver/Models/GoogleModel.swift
New file
@@ -0,0 +1,152 @@
//
//  GoogleModel.swift
//  BrokerDriver
//
//  Created by 无故事王国 on 2023/5/6.
//
import Foundation
import HandyJSON
struct GoogleModel:HandyJSON {
    var plus_code:PlusCode?
    var results:[GoogleResult] = []
    var status:String = ""
}
struct GoogleResult:HandyJSON {
    var address_components:[AddressComponent] = []
    var formatted_address:String = ""
    var geometry:Geometry?
    var place_id:String = ""
    var plus_code:PlusCode?
    var types:[String] = []
}
struct AddressComponent:HandyJSON {
    var long_name:String = ""
    var short_name:String = ""
    var types:[String] = []
}
struct Geometry:HandyJSON {
    var bounds : Bound!
    var location : Northeast!
    var location_type : String = ""
    var viewport : Bound!
}
struct Bound:HandyJSON {
    var northeast : Northeast?
    var southwest : Northeast?
}
struct Northeast:HandyJSON {
    var lat:CLLocationDegrees = 0
    var lng:CLLocationDegrees = 0
}
struct PlusCode:HandyJSON {
    var compound_code : String = ""
    var global_code : String = ""
}
struct GooglePOIModel:HandyJSON {
    var html_attributions = [String]()
    var next_page_token = ""
    var results = [GooglePOIResultModel]()
}
struct GooglePOIResultModel:HandyJSON{
    var business_status : String = ""
    var formatted_address = ""
    var geometry : Geometry?
    var icon : String = ""
    var icon_background_color : String = ""
    var icon_mask_base_uri : String = ""
    var more_opening_hours : [AnyObject]!
    var name : String = ""
    var photos : [GoogleMapPhoto] = [GoogleMapPhoto]()
    var place_id : String = ""
    var plus_code : PlusCode?
    var rating : Double = 0
    var reference : String = ""
    var scope : String = ""
    var types : [String] = [String]()
    var user_ratings_total : Int = 0
    var vicinity : String = ""
}
struct GoogleMapPhoto:HandyJSON {
    var height : Int = 0
    var html_attributions = [String]()
    var photo_reference : String = ""
    var width : Int = 0
}
struct GoogleRoteModel:HandyJSON {
    var status = ""
    var routes = [GoogleRoteRouteModel]()
    var geocoded_waypoints = [GoogleRoteWaypointModel]()
}
struct GoogleRoteWaypointModel:HandyJSON {
    var geocoder_status = ""
    var place_id = ""
    var types = [String]()
}
struct GoogleRoteRouteModel:HandyJSON {
    var bounds:Bound?
    var copyrights:String = ""
    var legs = [GoogleRoteRouteLegModel]()
}
struct GoogleRoteRouteLegModel:HandyJSON {
    var distance : GoogleRoteDistanceModel?
    var duration : GoogleRoteDistanceModel?
    var duration_in_traffic : GoogleRoteDistanceModel?
    var end_address : String = ""
    var end_location : Northeast?
    var start_address : String = ""
    var start_location : Northeast?
    var steps  = [GoogleRoteStepModel]()
    var traffic_speed_entry : [String] = []
    var via_waypoint :  [String] = []
}
struct GoogleRoteDistanceModel:HandyJSON{
    var text : String = ""
    var value : Int = 0
}
struct GoogleRoteStepModel:HandyJSON {
    var distance : GoogleRoteDistanceModel?
    var duration : GoogleRoteDistanceModel?
    var end_location : Northeast?
    var html_instructions : String = ""
    var maneuver : String = ""
    var polyline : GoogleRotePolylineModel?
    var start_location : Northeast?
    var travel_mode : String?
}
struct GoogleRotePolylineModel:HandyJSON {
    var points : String!
}
struct SnappedPointsModel:HandyJSON{
    var snappedPoints = [SnappedPointModel]()
}
struct SnappedPointModel:HandyJSON {
    var location:SnappedLocationModel?
    var originalIndex:Int = 0
    var placeId = ""
}
struct SnappedLocationModel:HandyJSON {
    var latitude:CLLocationDegrees?
    var longitude:CLLocationDegrees?
}
BrokerDriver/Network/NetworkRequest.swift
@@ -62,6 +62,11 @@
        params += ["\(key)":"\(value)"]
        return self
    }
    func append(key: String,value: Bool) -> ParamsAppender {
        params += ["\(key)":"\(value)"]
        return self
    }
    
    func append(key: String,value: String?) -> ParamsAppender {
//        if  value?.isEmpty ?? true ||  value == ""  { return self }
@@ -108,6 +113,24 @@
    class func build(url: String) -> ParamsAppender {
        return ParamsAppender(url: url)
    }
    func googleMapDone() -> ParamsAppender {
        var paramsArray: [String] = []
        // 排序
        let sortedArray: [String] = Array(params.keys).sorted()
        for item in sortedArray{
            // 拼接字符串
            if params.has(key: item){
                paramsArray.append("\(item)=\(params[item]!)")
            }
        }
        let content = paramsArray.joined(separator: "&")
        params += ["key": GoogleAppKey]
        //https://developers.google.com/maps/faq#languagesupport
        params += ["language":"en"]
        return self
    }
    
}
class NetworkRequest {
BrokerDriver/Network/Services.swift
@@ -1,22 +1,22 @@
//
//  Services.swift
//  YixiuShop
//
//  Created by Sweet on 2019/9/30.
//  Copyright © 2019 jackLove. All rights reserved.
//
    //
    //  Services.swift
    //  YixiuShop
    //
    //  Created by Sweet on 2019/9/30.
    //  Copyright © 2019 jackLove. All rights reserved.
    //
import UIKit
//import RxRelay
//import RxCocoa
//import RxDataSources
import RxSwift
import Alamofire
//外网测试环境
#if DEBUG
let All_Url = "http://192.168.110.22:8040"
//内网测试环境
//let All_Url = ""
let Google_Url = "https://roads.googleapis.com/v1"
#else
let All_Url = "http://192.168.110.22:8040"
let Google_Url = "https://roads.googleapis.com/v1"
#endif
class Services: NSObject {
@@ -155,3 +155,45 @@
    }
}
class GoogleServices:NSObject{
    enum DirectionType {
        case byPlaceId(String)
        case byAddress(String)
        case byCoordinates(CLLocationCoordinate2D)
        func toFormat()->String{
            switch self {
                case .byPlaceId(let string):
                    return String(format: "place_id:%@", string)
                case .byAddress(let string):
                    return string
                case .byCoordinates(let coordiante):
                    return String(format: "%lf,%lf", coordiante.latitude,coordiante.longitude)
            }
        }
    }
    class func directionsLine(origin:DirectionType,destination:DirectionType)->Observable<BaseResponse<GoogleRoteModel>>{
        let params = ParamsAppender.build(url: Google_Url)
            .interface(url: "/directions/json")
            .append(key: "origin", value: origin.toFormat())
            .append(key: "destination", value: destination.toFormat())
            .append(key: "alternatives", value: false) //可供选择方案:会增加请求时间
        return NetworkRequest.request(params: params.googleMapDone(), method: .post, progress: false)
    }
        /// When directions line was done , need call the method snap to the road.
        /// - Parameter path: coordiante paths
    class func snapToRoads(path:String)->Observable<BaseResponse<SnappedPointsModel>>{
        let params = ParamsAppender.build(url: Google_Url)
            .interface(url: "/snapToRoads/")
            .append(key: "path", value: path)
            .append(key: "interpolate", value: true)
        params.params.removeValue(forKey: "appid")
        params.params.removeValue(forKey: "language")
        return NetworkRequest.request(params: params.googleMapDone(), method: .post, progress: false)
    }
}
BrokerDriver/SceneDelegate.swift
@@ -6,6 +6,7 @@
//
import UIKit
import GoogleMaps
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
@@ -28,6 +29,12 @@
        window?.overrideUserInterfaceStyle = .light
        window?.makeKeyAndVisible()
        setupGoogleAMap()
    }
    func setupGoogleAMap(){
        GMSServices.provideAPIKey(GoogleAppKey)
    }
    func sceneDidDisconnect(_ scene: UIScene) {