提问人:Morozov 提问时间:11/10/2023 最后编辑:Morozov 更新时间:11/10/2023 访问量:16
无虚拟方法布尔值 call-mutableStateOf
No virtual method Boolean call-mutableStateOf
问:
当我尝试在properties
actual fun
java.lang.NoSuchMethodError:无虚拟方法 布尔值$arg-2$call-$init$$arg-0$call-mutableStateOf$fun-$anonymous$$arg-0$call-remember$val-properties$delegate$fun-GoogleMaps()Z 在 Lcom/mandarine/fiveplus/util/LiveLiterals$GoogleMapsKt 类中;或 它的超类(声明 “com.mandarine.fiveplus.util.LiveLiterals$GoogleMapsKt”出现在 /data/data/com.mandarine.fiveplus.android/code_cache/.overlay/base.apk/classes7.dex) 在 com.mandarine.fiveplus.util.GoogleMapsKt.GoogleMaps(GoogleMaps.kt:45)
这也是我的乐趣:
@Composable
actual fun GoogleMaps(
modifier: Modifier,
isControlsVisible: Boolean,
onMarkerClick: ((MapMarker) -> Unit)?,
onMapClick: ((LatLong) -> Unit)?,
onMapLongClick: ((LatLong) -> Unit)?,
markers: List<MapMarker>?,
cameraPosition: CameraPosition?,
cameraPositionLatLongBounds: CameraPositionLatLongBounds?,
polyLine: List<LatLong>?
) {
val cameraPositionState = rememberCameraPositionState()
val uiSettings by remember {
mutableStateOf(
MapUiSettings()
)
}
val properties by remember {
mutableStateOf(
MapProperties(
isMyLocationEnabled = true,
minZoomPreference = 10f,
maxZoomPreference = 20f,
)
)
}
LaunchedEffect(cameraPosition) {
cameraPosition?.let { cameraPosition ->
CameraUpdateFactory.newLatLngZoom(
LatLng(
cameraPosition.target.latitude,
cameraPosition.target.longitude
),
cameraPosition.zoom
)
}
}
LaunchedEffect(cameraPositionLatLongBounds) {
cameraPositionLatLongBounds?.let {
val latLngBounds = LatLngBounds.builder().apply {
it.coordinates.forEach { latLong ->
include(LatLng(latLong.latitude, latLong.longitude))
}
}.build()
cameraPositionState.move(
CameraUpdateFactory.newLatLngBounds(latLngBounds, it.padding)
)
}
}
Box(Modifier.fillMaxSize()) {
GoogleMap(
cameraPositionState = cameraPositionState,
modifier = modifier,
uiSettings = uiSettings,
properties = properties,
onMapClick = { latLng: LatLng ->
onMapClick?.let { nativeFun ->
nativeFun(LatLong(latLng.latitude, latLng.longitude))
}
},
) {
markers?.forEach { marker ->
Marker(
state = rememberMarkerState(
key = marker.key,
position = LatLng(marker.position.latitude, marker.position.longitude)
),
alpha = marker.alpha,
title = marker.title
)
}
polyLine?.let { polyLine ->
Polyline(
points = List(polyLine.size) {
val latLong = polyLine[it]
LatLng(latLong.latitude, latLong.longitude)
},
color = Color(0XFF1572D5),
width = 16f
)
Polyline(
points = List(polyLine.size) {
val latLong = polyLine[it]
LatLng(latLong.latitude, latLong.longitude)
},
color = Color(0XFF00AFFE),
width = 8f
)
}
}
}
}
但错误是指我的:expect function
@Suppress("NO_ACTUAL_FOR_EXPECT")
@Composable
expect fun GoogleMaps(
modifier: Modifier,
isControlsVisible: Boolean = true,
onMarkerClick: ((MapMarker) -> Unit)? = {},
onMapClick: ((LatLong) -> Unit)? = {},
onMapLongClick: ((LatLong) -> Unit)? = {},
markers: List<MapMarker>? = null,
cameraPosition: CameraPosition? = null,
cameraPositionLatLongBounds: CameraPositionLatLongBounds? = null,
polyLine: List<LatLong>? = null
)
答: 暂无答案
评论