首页 / 浏览问题 / 移动GIS / 问题详情
强制类型转换
23EXP 2023年08月15日

想把天地图注记图层背景设为透明,使用的是矢量的注记,但显示错误:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.tianditu/com.example.tianditu.MainActivity}: java.lang.ClassCastException: com.supermap.mapping.LayerSettingImage cannot be cast to com.supermap.mapping.LayerSettingVector
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3771)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3938)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2318)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:210)
at android.os.Looper.loop(Looper.java:299)
at android.app.ActivityThread.main(ActivityThread.java:8306)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:576)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1073)
Caused by: java.lang.ClassCastException: com.supermap.mapping.LayerSettingImage cannot be cast to com.supermap.mapping.LayerSettingVector
at com.example.tianditu.MainActivity.onCreate(MainActivity.java:79)
at android.app.Activity.performCreate(Activity.java:8194)
at android.app.Activity.performCreate(Activity.java:8160)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3744)

代码如下:

1个回答

您好,应该使用LayerSettingImage,天地图打开后是影像数据集而不是矢量数据集,LayerSettingVector用于设置矢量数据集风格
3,735EXP 2023年08月15日
...