我有一个MapViewModel适合我的MapViewController.
我有一个返回一个MapObjectService函数fetchMapObjects(currentLocation: CLLocation)Observable<MapObjects>
在 MapViewModel 我有:
var currentLocation: Observable<CLLocation?>
var mapObjects: Observable<MapObjects>
我可以像这样初始化当前位置:
currentLocation = locationManager.rx.didUpdateLocations.map( { locations in
return locations.filter() { loc in
return loc.horizontalAccuracy < 20
}.first
})
如何有效地初始化这两个属性,以便fetchMapObjects()使用 currentLocation 来设置mapObjects属性?
我的计划是将这些属性绑定到 mapView 中,MapViewController以将地图对象显示为图钉和当前位置。
谢谢!