gpt4 book ai didi

android - Mapbox IllegalStateException : Calling getSourceAs when a newer style is loading/has loaded

转载 作者:行者123 更新时间:2023-12-04 23:50:02 34 4
gpt4 key购买 nike

我在 mapView.getMapAsync{} 期间收到以下错误称呼:

2019-10-03 19:37:57.605 10964-10964/my.app E/AndroidRuntime: FATAL EXCEPTION: main
Process: my.app, PID: 10964
java.lang.IllegalStateException: Calling getSourceAs when a newer style is loading/has loaded.
at com.mapbox.mapboxsdk.maps.Style.validateState(Style.java:584)
at com.mapbox.mapboxsdk.maps.Style.getSourceAs(Style.java:131)
at com.mapbox.mapboxsdk.location.LocationLayerController.refreshSource(LocationLayerController.java:292)
at com.mapbox.mapboxsdk.location.LocationLayerController.setLocationPoint(LocationLayerController.java:302)
at com.mapbox.mapboxsdk.location.LocationLayerController.access$000(LocationLayerController.java:61)
at com.mapbox.mapboxsdk.location.LocationLayerController$1.onNewAnimationValue(LocationLayerController.java:422)
at com.mapbox.mapboxsdk.location.LocationLayerController$1.onNewAnimationValue(LocationLayerController.java:418)
at com.mapbox.mapboxsdk.location.MapboxAnimator.postUpdates(MapboxAnimator.java:83)
at com.mapbox.mapboxsdk.location.MapboxAnimator.onAnimationUpdate(MapboxAnimator.java:71)
at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1547)
at android.animation.ValueAnimator.setCurrentFraction(ValueAnimator.java:674)
at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:637)
at android.animation.ValueAnimator.start(ValueAnimator.java:1069)
at android.animation.ValueAnimator.start(ValueAnimator.java:1088)
at android.animation.ValueAnimator.startWithoutPulsing(ValueAnimator.java:1081)
at android.animation.AnimatorSet.handleAnimationEvents(AnimatorSet.java:1142)
at android.animation.AnimatorSet.startAnimation(AnimatorSet.java:1227)
at android.animation.AnimatorSet.start(AnimatorSet.java:729)
at android.animation.AnimatorSet.start(AnimatorSet.java:684)
at com.mapbox.mapboxsdk.location.MapboxAnimatorSetProvider.startAnimation(MapboxAnimatorSetProvider.java:30)
at com.mapbox.mapboxsdk.location.LocationAnimatorCoordinator.playAnimators(LocationAnimatorCoordinator.java:294)
at com.mapbox.mapboxsdk.location.LocationAnimatorCoordinator.feedNewLocation(LocationAnimatorCoordinator.java:97)
at com.mapbox.mapboxsdk.location.LocationComponent.updateLocation(LocationComponent.java:1317)
at com.mapbox.mapboxsdk.location.LocationComponent.access$1000(LocationComponent.java:94)
at com.mapbox.mapboxsdk.location.LocationComponent$CurrentLocationEngineCallback.onSuccess(LocationComponent.java:1473)
at com.mapbox.mapboxsdk.location.LocationComponent$CurrentLocationEngineCallback.onSuccess(LocationComponent.java:1461)
at com.mapbox.android.core.location.GoogleLocationEngineImpl$GoogleLocationEngineCallbackTransport.onLocationResult(GoogleLocationEngineImpl.java:114)
at com.google.android.gms.internal.location.zzau.notifyListener(Unknown Source:4)
at com.google.android.gms.common.api.internal.ListenerHolder.notifyListenerInternal(Unknown Source:17)
at com.google.android.gms.common.api.internal.ListenerHolder$zaa.handleMessage(Unknown Source:5)
at android.os.Handler.dispatchMessage(Handler.java:106)
at com.google.android.gms.internal.base.zap.dispatchMessage(Unknown Source:8)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6702)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)

这是我的代码:

MapFragment.kt
var symbolOptions = SymbolOptions()
private var symbolManager: SymbolManager? = null
private var mapView: MapView? = null
private lateinit var mapboxMap: MapboxMap
private var navigationMapRoute: NavigationMapRoute? = null

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
/** Initialise Mapbox **/
mapView = view.findViewById(R.id.mapView)
mapView?.onCreate(savedInstanceState)
val destinationMarker = ContextCompat.getDrawable(activity, R.drawable.logo) ?: return
mapView?.getMapAsync { mapboxMap ->
Log.d("getMapAsync") // this doesn't print
this.mapboxMap = mapboxMap
this.mapboxMap.setStyle(Style.MAPBOX_STREETS) { style ->
style.addImage("destination", destinationMarker)
showUserLocation(style)
resetCamera()
}
}
}

不幸的是,我不明白错误消息 Calling getSourceAs when a newer style is loading/has loaded.这是 map 样式的初始加载,所以我不确定为什么它告诉我我正在尝试更改样式。

错误是什么意思,我该如何解决?

最佳答案

只需使用:

 mapboxMap.getStyle(new Style.OnStyleLoaded() {
@Override
public void onStyleLoaded(@NonNull Style style) {
// Continue your job here

}
});

关于android - Mapbox IllegalStateException : Calling getSourceAs when a newer style is loading/has loaded,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58217011/

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