首页 / 浏览问题 / 移动GIS / 问题详情
资源文件不存在
30EXP 2023年08月01日

是一个轨迹记录的功能

private boolean openWorkspace() {

    m_Workspace = new Workspace();
    WorkspaceConnectionInfo info = new WorkspaceConnectionInfo();
    info.setServer(path);
    info.setType(WorkspaceType.SMWU);
    boolean isOpen = m_Workspace.open(info);
    if(!isOpen){
        Toast.makeText(context,"打开失败",Toast.LENGTH_SHORT).show();
        return false;
    }
    m_MapView    = (MapView) findViewById(R.id.getTrack);
    m_MapControl = m_MapView.getMapControl();
    m_Map        = m_MapControl.getMap();
    m_Map.setWorkspace(m_Workspace);
    /*m_Map.open(m_Workspace.getMaps().get(0));
    String mapName = m_Workspace.getMaps().get(0);
    m_Map.open(mapName);
    Point2D point2D = new Point2D();
    point2D.setX(116.004177318841);
    point2D.setY(36.4349243801011);
    m_MapControl.getMap().setScale(1.0 / 20000);
    PrjCoordSys Prj = m_Map.getPrjCoordSys();
    if (Prj.getType() != PrjCoordSysType.PCS_EARTH_LONGITUDE_LATITUDE) {
        Point2Ds point2Ds = new Point2Ds();
        point2Ds.add(point2D);
        PrjCoordSys prjCoordSys = new PrjCoordSys();
        prjCoordSys.setType(PrjCoordSysType.PCS_EARTH_LONGITUDE_LATITUDE);
        CoordSysTranslator.convert(point2Ds, prjCoordSys, Prj, new CoordSysTransParameter(), CoordSysTransMethod.MTH_GEOCENTRIC_TRANSLATION);
        point2D = point2Ds.getItem(0);
        m_Map.setCenter(point2D);
        m_Map.refresh();
    }*/
    //加载高德矢量图 作为地图。0为矢量,1为影像
    DatasourceConnectionInfo dsInfo = new DatasourceConnectionInfo();
    dsInfo.setEngineType(EngineType.GaoDeMaps);
    dsInfo.setDriver("WMTS");
    dsInfo.setAlias("gaode");
    Datasource ds = m_Workspace.getDatasources().open(dsInfo);
    m_Map.getLayers().add(ds.getDatasets().get(0),true);

    m_Map.setScale(1/229492.1875);
    m_Map.setCenter(new Point2D(12953693.6950684, 4858067.04711915));
    m_Map.refresh();
    mNavigation = m_MapControl.getNavigation();
    mNavigation.setEncryption(new SuperMapPatent());
    return true;
}

会显示资源文件不存在

 Process: com.example.supermap_project, PID: 31998
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.supermap_project/com.example.supermap_project.worker.trac.TrackActivity}: java.lang.NullPointerException: ResourceFile is not exist.
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3956)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4113)
        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:2458)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:233)
        at android.os.Looper.loop(Looper.java:334)
        at android.app.ActivityThread.main(ActivityThread.java:8395)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:582)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1065)
     Caused by: java.lang.NullPointerException: ResourceFile is not exist.
        at com.supermap.mapping.NavigationPlus.ResourceUtil.check(ResourceUtil.java:62)
        at com.supermap.mapping.NavigationPlus.ResourceUtil.getLayoutId(ResourceUtil.java:13)
        at com.supermap.mapping.NavigationPlus.NaviMapViewPlus.a(NaviMapViewPlus.java:94)
        at com.supermap.mapping.NavigationPlus.NaviMapViewPlus.<init>(NaviMapViewPlus.java:84)
        at com.supermap.mapping.MapView$4.run(MapView.java:945)
        at android.app.Activity.runOnUiThread(Activity.java:7548)
        at com.supermap.mapping.MapView.b(MapView.java:935)
        at com.supermap.mapping.MapControl.getNavigation(MapControl.java:140)
        at com.example.supermap_project.worker.trac.TrackActivity.openWorkspace(TrackActivity.java:177)
        at com.example.supermap_project.worker.trac.TrackActivity.onCreate(TrackActivity.java:118)
        at android.app.Activity.performCreate(Activity.java:8485)
        at android.app.Activity.performCreate(Activity.java:8463)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3929)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4113) 
        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:2458) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loopOnce(Looper.java:233) 
        at android.os.Looper.loop(Looper.java:334) 
        at android.app.ActivityThread.main(ActivityThread.java:8395) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:582) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1065) 

注释掉mNavigation = m_MapControl.getNavigation(); mNavigation.setEncryption(new SuperMapPatent());会成功打开,和查看以往轨迹但是无法定位。

1个回答

您好,记录轨迹该用track类,而不是navigation,可以参考示例程序的track
3,690EXP 2023年08月01日
...