mMapView = (MapView) findViewById(R.id.mapView);
mainArcGISMap = new ArcGISMap(Basemap.createStreetsVector());
mMapView.setMap(mainArcGISMap);
String reqPermission = new String{Manifest.permission.WRITE_EXTERNAL_STORAGE};
int requestCode = 2;
if (ContextCompat.checkSelfPermission(this, reqPermission[0]) == PackageManager.PERMISSION_GRANTED) {
showShapefile();
} else {
ActivityCompat.requestPermissions(this, reqPermission, requestCode);
}
}
private void showShapefile() {
// load the shapefile with a local path
final ShapefileFeatureTable shapefileFeatureTable = new ShapefileFeatureTable(
getExternalFilesDir(null) + getString(R.string.shapefile_path));
shapefileFeatureTable.loadAsync();
shapefileFeatureTable.addDoneLoadingListener(new Runnable() {
@Override
public void run() {
GeometryType gt = shapefileFeatureTable.getGeometryType();
String name = shapefileFeatureTable.getTableName();
mainShapefileLayer = new FeatureLayer(shapefileFeatureTable);
if (mainShapefileLayer.getFullExtent() != null) {
mMapView.setViewpointGeometryAsync(mainShapefileLayer.getFullExtent());
} else {
mainShapefileLayer.addDoneLoadingListener(new Runnable() {
@Override
public void run() {
mMapView.setViewpointGeometryAsync(mainShapefileLayer.getFullExtent());
}
});
}
mainArcGISMap.getOperationalLayers().add(mainShapefileLayer);
2 个回复
鲁仁华
赞同来自:
张佳期
赞同来自:
可以在arcmap检查一下你的数据是否有几何错误,或者用我附件的数据试试。
代码:
要回复问题请先登录或注册
发起人
相关问题
问题状态