private boolean openMap(){ m_workspace = new Workspace(); m_mapView = (MapView)findViewById(R.id.Map_view); m_mapControl = m_mapView.getMapControl(); m_mapControl.getMap().setWorkspace(m_workspace); DatasourceConnectionInfo dsInfo = new DatasourceConnectionInfo(); // dsInfo.setServer("http://220.165.249.18:9055/iserver/services/map-532503MengZiShi/rest/maps/map"); // dsInfo.setEngineType(EngineType.Rest); // dsInfo.setAlias("ChinaRest"); String url = "http://t0.tianditu.gov.cn/vec_c/wmts?tk=493052acd769f94413bb19a27879476b"; dsInfo.setServer(url); dsInfo.setAlias("TianDiTu1"); dsInfo.setEngineType(EngineType.OGC); dsInfo.setDriver("WMTS"); // String url = "http://t0.tianditu.gov.cn/img_c/esri/wmts?tk=493052acd769f94413bb19a27879476b"; // String url = "http://t0.tianditu.gov.cn/img_c/wmts?tk=493052acd769f94413bb19a27879476b"; dsInfo.setServer(url); Datasource ds = m_workspace.getDatasources().open(dsInfo); if(ds != null){ m_mapControl.getMap().getLayers().add(ds.getDatasets().get(0), true); m_mapControl.getMap().refresh(); return true; } Log.e(this.getClass().getName(), "打开数据源失败了"); return true; }
报错
E/com.example.myapplication.MainActivity: 打开数据源失败了
implementation files('libs/com.supermap.track_v910.jar') implementation files('libs/com.supermap.services_v910.jar') implementation files('libs/com.supermap.realspace_v910.jar') implementation files('libs/com.supermap.plot_v910.jar') implementation files('libs/com.supermap.navigation_v910.jar') implementation files('libs/com.supermap.messagequeue_v910.jar') implementation files('libs/com.supermap.mdatacollector_v910.jar') implementation files('libs/com.supermap.mapping_v910.jar') implementation files('libs/com.supermap.analyst_v910.jar') implementation files('libs/com.supermap.data_v910.jar') implementation files('libs/com.github.mikephil.charts.jar') implementation files('libs/classes.jar') implementation files('libs/chartengine.jar')
您好,建议您那边下载一个最新版本的移动端sdk加载天地图,之前的版本没有对接带token的天地图,下载地址:http://support.supermap.com.cn/DownloadCenter/DownloadPage.aspx?id=1282