地图显示annnotations优化
This commit is contained in:
@@ -407,20 +407,24 @@ extension VehicleMonitoringController : JXCategoryListContainerViewDelegate {
|
||||
self?.preciousTableView = vc?.vehicleMonitoringListView.tableView
|
||||
|
||||
// 设置当前选中的annotation
|
||||
self?.vehicleMonitoringView.maMapView.maMapView.setCenter(CLLocationCoordinate2D(latitude: Double(model.lat ?? "0")!, longitude: Double(model.lon ?? "0")!), animated: true)
|
||||
|
||||
if let lat = model.lat,let lon = model.lon {
|
||||
self?.vehicleMonitoringView.maMapView.maMapView.setCenter(CLLocationCoordinate2D(latitude: Double(lat) ?? 0, longitude: Double(lon) ?? 0), animated: true)
|
||||
}
|
||||
|
||||
// 当前annotation展开,其他闭合
|
||||
self?.vehicleMonitoringView.maMapView.maMapView.removeAnnotations(self?.mapAnnotaions)
|
||||
self?.mapAnnotaions.removeAll()
|
||||
for index in 0..<(vc?.models.count ?? 0) {
|
||||
let model = vc?.models[index]
|
||||
let coordinate = CLLocationCoordinate2D(latitude: Double(model?.lat ?? "") ?? 0, longitude: Double(model?.lon ?? "") ?? 0)
|
||||
let pointAnnotation = MAPointAnnotation.init()
|
||||
pointAnnotation.annotationClass = VehicleMonitoringPointAnnotation.self
|
||||
pointAnnotation.coordinate = coordinate
|
||||
pointAnnotation.tag = index
|
||||
self?.vehicleMonitoringView.maMapView.maMapView.addAnnotation(pointAnnotation)
|
||||
self?.mapAnnotaions.append(pointAnnotation)
|
||||
if let _ = model?.lat,let _ = model?.lon {
|
||||
let coordinate = CLLocationCoordinate2D(latitude: Double(model?.lat ?? "") ?? 0, longitude: Double(model?.lon ?? "") ?? 0)
|
||||
let pointAnnotation = MAPointAnnotation.init()
|
||||
pointAnnotation.annotationClass = VehicleMonitoringPointAnnotation.self
|
||||
pointAnnotation.coordinate = coordinate
|
||||
pointAnnotation.tag = index
|
||||
self?.vehicleMonitoringView.maMapView.maMapView.addAnnotation(pointAnnotation)
|
||||
self?.mapAnnotaions.append(pointAnnotation)
|
||||
}
|
||||
}
|
||||
}
|
||||
return vc
|
||||
@@ -467,7 +471,6 @@ extension VehicleMonitoringController : JXCategoryViewDelegate {
|
||||
}
|
||||
|
||||
vehicleMonitoringView.maMapView.maMapView.removeAnnotations(mapAnnotaions)
|
||||
var hasSetCenter = false
|
||||
for index in 0..<(mapModel?.count ?? 0) {
|
||||
let model = mapModel?[index]
|
||||
if model?.lat != nil && model?.lon != nil {
|
||||
@@ -478,13 +481,12 @@ extension VehicleMonitoringController : JXCategoryViewDelegate {
|
||||
pointAnnotation.tag = index
|
||||
vehicleMonitoringView.maMapView.maMapView.addAnnotation(pointAnnotation)
|
||||
mapAnnotaions.append(pointAnnotation)
|
||||
|
||||
if hasSetCenter == false {
|
||||
hasSetCenter = true
|
||||
vehicleMonitoringView.maMapView.maMapView.setCenter(coordinate, animated: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let annotations = vehicleMonitoringView.maMapView.maMapView.annotations {
|
||||
vehicleMonitoringView.maMapView.maMapView.showAnnotations(annotations, animated: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user