首页 / 浏览问题 / 移动GIS / 问题详情
iMobile Lite 10i 加载地图图层出错
4EXP 2022年07月05日
MapView mapView = (MapView) this.findViewById(R.id.mapView);
LayerView layerView = new LayerView(this);
layerView.setURL("http://MyServerIP:8090/iserver/services/map-china400/rest/maps/China");
//添加图层
mapView.addLayer(layerView);

 报错信息

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.bygtgis, PID: 5467
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.bygtgis/com.example.bygtgis.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.supermap.imobilelite.maps.MapView.addLayer(com.supermap.imobilelite.maps.AbstractTileLayerView)' on a null object reference
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        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:2016)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

 lite 能加载在线地图且实现定位吗?

1个回答

您好,

1.请您检查一下依赖有没有加成功,这种错误是Android环境的问题,网上有很多解决方案的,建议可以先百度。可以参考这篇博客https://blog.csdn.net/qq_35928566/article/details/85762677

2.iMobile Lite的示范demo中是没有定位的,还是可以按照GPS定位或者第三位定位(腾讯、高德等)的代码来写。您只需要将定位的点坐标显示在地图中,定位的坐标一般是wgs84的经纬度坐标,如果坐标系不一致需要进行坐标转换。这边建议您使用iMobile for Android,产品包有相应的定位的demo,也提供坐标转换的接口,在Lite中是没有提供坐标转换的接口的。

希望可以帮助到您。

3,400EXP 2022年07月05日
lite中没有坐标转换的接口,可以使用其他的转换坐标去转换吗

已经将下载的lite中的jar都加入到项目中进行依赖了,so文件也没问题。依旧报错。

W/System.err: bundle:com.supermap.android.MapCommon is null
W/System.err: bundle:com.supermap.android.MapCommon is null
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.bygtgis, PID: 5824
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.bygtgis/com.example.bygtgis.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.supermap.imobilelite.maps.MapView.addLayer(com.supermap.imobilelite.maps.AbstractTileLayerView)' on a null object reference
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)

您好,supermap imobile lite现在已经开源,建议您使用supermap imobile for Android,您可以查看我们的产品生命周期PowerPoint 演示文稿 (supermap.com.cn)

希望可以帮助到您。

...