本文共 929 字,大约阅读时间需要 3 分钟。
@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
转载地址:http://mzrav.baihongyu.com/