首页 / 浏览问题 / 移动GIS / 问题详情
使用天地图对接多个图层
23EXP 2023年08月12日

问题描述:对接天地图底图已经能够正常使用,现在想要添加矢量注记,参考的代码是示例代码中的MapOverlay,没有成功,报错如下:

FATAL EXCEPTION: main
Process: com.example.tianditu, PID: 18479
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.tianditu/com.example.tianditu.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'com.supermap.data.Datasets com.supermap.data.Datasource.getDatasets()' on a null object reference
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.NullPointerException: Attempt to invoke virtual method 'com.supermap.data.Datasets com.supermap.data.Datasource.getDatasets()' on a null object reference
at com.example.tianditu.MainActivity.onCreate(MainActivity.java:73)
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)

MainActivity中代码如下

1个回答

您好,根据错误信息"'com.supermap.data.Datasets com.supermap.data.Datasource.getDatasets()' on a null object reference",请注意对应url是否正确,正确url打开的数据源不应该为空,如果不确定,可以用idesktop去打开web数据源-天地图里面去查看对应url
3,690EXP 2023年08月14日
...