@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//在加载布局之前获取所需权限
addpermission();
Environment.setLicensePath(sdcard + "/YN_BGDC/license/");
Environment.initialization(this);
setContentView(R.layout.activity_main);
DatasourceConnectionInfo info = new DatasourceConnectionInfo();
info.setAlias("TianDiTu1");
info.setEngineType(EngineType.OGC);
info.setDriver("WMTS");
String url = "https://t0.tianditu.gov.cn/img_c/wmts?tk=493052acd769f94413bb19a27879476b";
info.setServer(url);
m_workspace = new Workspace();
Datasource datasource = m_workspace.getDatasources().open(info);
m_mapControl = m_mapView.getMapControl();
m_mapControl.getMap().getLayers().add(datasource.getDatasets().get(0), true);
}
报错 Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.supermap.mapping.MapControl com.supermap.mapping.MapView.getMapControl()' on a null object reference