創建標記時,它們會立即顯示在地圖上和數據庫中。 但是,當我刪除它時,它會留在地圖中,直到我更新視圖。我想在地圖中立即刪除它,但不知道如何。 有什麼建議嗎?從火力點檢索到的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