创建标记时,它们会立即显示在地图上和数据库中。 但是,当我删除它时,它会留在地图中,直到我更新视图。我想在地图中立即删除它,但不知道如何。 有什么建议吗?从火力点检索到的Google地图标记
这是我如何检索火力和显示标记数据在为cicle
我也把我用它来创建标记
func mapView(_ mapView: GMSMapView, didLongPressAt coordinate: CLLocationCoordinate2D) {
print("You tapped at \(coordinate.latitude), \(coordinate.longitude)")
let alertController = UIAlertController(title: "Crea Marker", message: "...", preferredStyle: UIAlertControllerStyle.alert) //Replace UIAlertControllerStyle.Alert by UIAlertControllerStyle.alert
let DestructiveAction = UIAlertAction(title: "Annulla", style: UIAlertActionStyle.cancel) {
(result : UIAlertAction) -> Void in
print("Annulla")
}
// Replace UIAlertActionStyle.Default by UIAlertActionStyle.default
let okAction = UIAlertAction(title: "Crea", style: UIAlertActionStyle.default) {
(result : UIAlertAction) -> Void in
let ref = FIRDatabase.database().reference().child("userdata")
let currentUser = FIRAuth.auth()?.currentUser
let displayName = currentUser?.displayName
let post = ["username": displayName,"uid": currentUser?.uid as Any,"latitude": coordinate.latitude,"longitude": coordinate.longitude, "firstname":"test"]
ref.childByAutoId().setValue(post)
print("Entra")
}
alertController.addAction(DestructiveAction)
alertController.addAction(okAction)
self.present(alertController, animated: true, completion: nil)
}
注:该功能我可是从火力地堡
编辑手动删除数据: This is a gif for a better explain
哪里是你的删除标记代码? – CodeChanger
即时只能从数据库手动删除 – GaTz
您是否正在从Firebase手动删除? – CodeChanger