|
|
@@ -63,8 +63,13 @@ class MapViewModel: NSObject, ObservableObject, MapCapability {
|
|
|
result(paramsDecodeError)
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- self.markers = markers
|
|
|
+ // 使用字典优化查找性能
|
|
|
+ var markerDict = Dictionary(uniqueKeysWithValues: self.markers.map { ($0.id, $0) })
|
|
|
+
|
|
|
+ markerDict.merge(Dictionary(uniqueKeysWithValues: markers.map { ($0.id, $0) }), uniquingKeysWith: { _, new in new })
|
|
|
+
|
|
|
+ // 转换回数组
|
|
|
+ self.markers = Array(markerDict.values)
|
|
|
result(nil)
|
|
|
}
|
|
|
|