gpt4 book ai didi

iOS Swift GMSMarker 不会删除

转载 作者:行者123 更新时间:2023-11-30 11:43:21 24 4
gpt4 key购买 nike

我正在使用 Google map ,并且正在尝试删除标记。

我正在使用 marker.map = nil 正如指南所说。但标记仍然在那里..

我不能使用map.clear(),因为我不想失去一切......

有什么建议吗?

/// Hide all the markers
func hideMarkers() {
let events = viewModel.events
for event in events {
event.marker?.map = nil
}
}

最佳答案

官方文档https://developers.google.com/maps/documentation/ios-sdk/marker?hl=en

If you wish to make modifications to a marker after you've added it to the map, ensure that you keep hold of the GMSMarker object. You can modify the marker later by making changes to this object.

let marker = GMSMarker(position: position)
marker.map = mapView
marker.map = nil

所以你已经保存了对你的标记的引用。我想您没有在标记上工作。

一种丑陋的方法是调用 mapView.clear() 并重新添加所有标记。

关于iOS Swift GMSMarker 不会删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49093837/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com