gpt4 book ai didi

java - 您在 `removeAnnotationIcon` 被销毁后调用 `MapView` ,您是在 `onDestroy()` 之后调用它吗? map 框

转载 作者:行者123 更新时间:2023-12-01 17:20:34 29 4
gpt4 key购买 nike

You're calling removeAnnotationIcon after the MapView was destroyed, were you invoking it after onDestroy()?

这是一个 ambibdata 函数

 for (i in p0.children) {
var user: ModelSharing? =
i.getValue(ModelSharing::class.java)
var datalongitude = user!!.longitude
var datalatitude = user.latidude
var nama = user.name
var foto = user.image
lokasi = LatLng(datalatitude, datalongitude)
if (markerViewManager != null) {
customview = LayoutInflater.from(context!!.applicationContext)
.inflate(R.layout.marker, null)
customview.layoutParams =
FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)
val titleTextView: TextView =
customview.findViewById(R.id.marker_window_title)
val gambarView: ImageView =
customview.findViewById(R.id.gambarview)

Picasso.get().load(foto).resize(50,50)
.into(gambarView)
marker = MarkerView(lokasi, customview)
titleTextView.text = nama
markerViewManager?.addMarker(marker)
markerMap.put(counter, marker)
counter++
//break
}
}

这是一个 onMapReady

override fun onMapReady(mapboxMap: MapboxMap) {
this.mapboxMap = mapboxMap

mapboxMap.setStyle(Style.MAPBOX_STREETS) {

enableLocationComponent(it)
markerViewManager = MarkerViewManager(mapboxfamily, mapboxMap)
mapboxMap.addOnMapClickListener(this)
if (setMarker == true)
{
try {
ambildata()
} catch (e: IOException) {
e.printStackTrace()
}

}
}


}

enter image description here

  1. 每个 fragment 都会移动并返回到前一个 fragment 。它会出错。怎么处理?

最佳答案

我遇到了同样的问题,为了防止它,请尝试覆盖 onDestroy 而不是 onDestroyView

   override fun onDestroy() {
super.onDestroy()

mapBox.locationComponent.isLocationComponentEnabled = false
mapView.onDestroy()
}

关于java - 您在 `removeAnnotationIcon` 被销毁后调用 `MapView` ,您是在 `onDestroy()` 之后调用它吗? map 框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61299301/

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