这是主要代码
package com.example.sichuan;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.supermap.data.Environment;
import com.supermap.data.Workspace;
import com.supermap.data.WorkspaceConnectionInfo;
import com.supermap.data.WorkspaceType;
import com.supermap.mapping.MapControl;
import com.supermap.mapping.MapView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MapControl mapControl = null;
String rootPath = android.os.Environment.getExternalStorageDirectory().getAbsolutePath();
//设置许可文件路径(默认路径“/SuperMap/license/”)
Environment.setLicensePath(rootPath + "/supermap1/license/");
//组件功能必须在Environment初始化之后才能调用
Environment.initialization(this);
setContentView(R.layout.activity_main);
//打开工作空间
Workspace m_workspace = new Workspace();
WorkspaceConnectionInfo info = new WorkspaceConnectionInfo();
info.setServer(rootPath + "/supermap1/GeometryInfo/SiChuan.smwu");
info.setType(WorkspaceType.SMWU);
m_workspace.open(info);
//将地图显示控件和工作空间关联
MapView m_mapView = findViewById(R.id.Map_view);
mapControl = m_mapView.getMapControl();
mapControl.getMap().setWorkspace(m_workspace);
//打开工作空间中的第二幅地图
String mapName = m_workspace.getMaps().get(1);
mapControl.getMap().open(mapName);
mapControl.getMap().refresh();
}
}