使用arcgis for android 10.2.x中加载离线地图,使用tpk + geodatabase模式:
1、初始化tpk文件
// 初始化离线切片
String yxtPath = Environment.getExternalStorageDirectory() + File.separator + "ArcGis" + File.separator + "yxt.tpk";
ArcGISLocalTiledLayer yxtLayer = new ArcGISLocalTiledLayer(yxtPath);
mMapView.addLayer(yxtLayer);
1、初始化geodatabase文件
// 离线地图geodatabase文件路径
String path = Environment.getExternalStorageDirectory() + File.separator + "ArcGis" + File.separator + "xxx.geodatabase";
Geodatabase localGdb = null;
try {
localGdb = new Geodatabase(path);
} catch (Exception e) {
e.printStackTrace();
}
if (localGdb != null) {
for (GeodatabaseFeatureTable gdbFeatureTable : localGdb.getGeodatabaseTables()) {
if (gdbFeatureTable.hasGeometry()) {
FeatureLayer featureLayer = new FeatureLayer(gdbFeatureTable);
mMapView.addLayer(featureLayer);
}
}
}
网友评论