我正在使用arcGIS android API来创建我所在大学的基于android的地图应用程序。我遇到的问题是我不知道如何使用shapefile中的图层加载自定义地图,因此我无法使用该应用程序。如果有人能告诉我如何欣赏它。
答案 0 :(得分:0)
使用ShapefileFeatureTable
和FeatureLayer
。按照https://github.com/Esri/arcgis-runtime-demos-android/blob/master/2015-DS/DevSummitDemo/DevSummitDemo/src/main/java/com/esri/android/devsummit/DevSummitDemoActivity.java上的示例:
try {
mTable = new ShapefileFeatureTable(filePath + fileExt);
mFlayer = new FeatureLayer(mTable);
// Set renderer based on geometry type
if (mTable.hasGeometry()) {
if (mTable.getGeometryType() == Geometry.Type.POLYLINE) {
mFlayer.setRenderer(new SimpleRenderer(new SimpleLineSymbol(Color.YELLOW, 0.50f)));
} else if (mTable.getGeometryType() == Geometry.Type.POLYGON) {
mFlayer.setRenderer(new SimpleRenderer(new SimpleFillSymbol(getResources().getColor(R.color.accent))));
} else if (mTable.getGeometryType() == Geometry.Type.POINT) {
mFlayer.setRenderer(new SimpleRenderer(new SimpleMarkerSymbol(Color.YELLOW, 1, STYLE.CIRCLE)));
}
}
mMap.addLayer(mFlayer);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e1) {
Toast.makeText(getApplicationContext(), "Adding Shapefile has failed, please restart app to add shapefiles.", Toast.LENGTH_SHORT).show();
e1.printStackTrace();
}