//
|
// YYMapViewManagerViewModel.swift
|
// OKProject
|
//
|
// Created by alvin_y on 2020/6/5.
|
// Copyright © 2020 yangwang. All rights reserved.
|
//
|
|
import UIKit
|
import RxCocoa
|
import RxSwift
|
|
class YYMapViewManagerViewModel: YYViewModel {
|
|
/// 预计行驶时间
|
let time = BehaviorRelay<String>(value: "大约行驶0分钟")
|
|
/// 选择地点和终点后获取预计行驶时长
|
func queryExpectedTime() {
|
guard let originInfo = YYMapViewManager.share.originInfo.value,let destination = YYMapViewManager.share.destination.value else {return}
|
APIManager.shared.provider.rx
|
.request(.queryExpectedTime(slat: originInfo.lat, slon: originInfo.lon, elat: destination.lat, elon: destination.lon))
|
.map(YYModel<ExpectedTimeModel>.self)
|
.validate()
|
.subscribe(onSuccess: {[unowned self] (model) in
|
guard let data = model.data else{return}
|
self.time.accept("大约行驶\(data.minute)分钟")
|
}) { (error) in
|
}
|
.disposed(by: disposeBag)
|
}
|
}
|