TheMelody / OmniMap-Compose

🔥🔥🔥Compose一键集成5大地图平台地图
MIT License
136 stars 16 forks source link

百度地图海量点击点, multiPointItems 增加新的数据,闪退 #29

Open LCodeX opened 1 month ago

LCodeX commented 1 month ago
fun addPointData() {
    val pointItemList = MultiPointOverlayRepository.initMultiPointItemList()
    val list = pointItemList.subList(10, 20)
    var newList = currentState.multiPointItems.plus(list)
    setState {
        copy(
            isLoading = false,
            multiPointItems = newList
        )
    }

}

Xnip2024-10-14_01-54-04 Screenshot 2024-10-12 at 13 08 29

TheMelody commented 1 month ago

没看出来闪退日志是什么,你看看你是不是集合自己处理的有问题

LCodeX commented 1 month ago

不会是集合的问题,我还是拿之前数据源切进去的 ` update = { update(onClick) { this.onPointItemClick = it }

        set(anchor) { this.multiPointOverlay.anchor(it.x, it.y) }
        set(icon) { this.multiPointOverlay.icon = it }
        set(textureSize) {
            it?.apply { multiPointOverlay.setPointSize(this.width,this.height) }
        }
        set(multiPointItems) {
            mapApplier?.map?.addOverlay(MultiPointOption().apply {
                this.setAnchor(anchor.x, anchor.y)
                // 纹理渲染大小,默认为icon图片大小
                textureSize?.let {
                    this.setPointSize(it.width,it.height)
                }
                this.multiPointItems = it
                this.icon = icon
            }) as? MultiPoint ?: error("Error adding MultiPointOverlay")

            // this.multiPointOverlay.multiPointItems = it
        }
    },`
     // this.multiPointOverlay.multiPointItems = it 直接赋值会造成整体重绘吧,百度so 报错

    采用 addOverlay 倒是可以,但是在 BDMap compsose 中:

    var mapView = remember { MapView(SDKUtils.getApplicationContext()) }
    我用这个mapView 的map 去 addOverlay 不响应(这个应该是个基础问题)