【发布时间】:2015-09-03 14:00:29
【问题描述】:
我正在尝试在我的 android 应用程序中为建筑物添加 london shapefile。但是,我无法显示它。它在地图上什么也没有显示。但是相同的 shapefile 正在在线正确显示。所以,shapefile 没有任何问题。
我从以下位置下载 shapefile https://docs.google.com/uc?id=0B0kRhiw4fD7uQzU3MzBMRzFfSFk&export=download
我的代码: 布局.xml
<!-- MapView layout and initial basemap and extent. -->
<com.esri.android.map.MapView
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
mapoptions.ZoomLevel="5"
mapoptions.center="18.0000, 79.5800" >
</com.esri.android.map.MapView>
MapActivity.java
mMapView = (MapView) findViewById(R.id.map);
mMapView.enableWrapAround(true);
String mShapefilePath = "/london_buildings/TQTL_LON.shp";
String mSdcard = Environment.getExternalStorageDirectory().getPath();
mMapView = (MapView) findViewById(R.id.map);
ArcGISTiledMapServiceLayer mTiledlayer = new ArcGISTiledMapServiceLayer(
"http://services.arcgisonline.com/arcgis/rest/services/ESRI_Imagery_World_2D/MapServer");
mMapView.addLayer(mTiledlayer);
try {
shpFileFeatTable = new ShapefileFeatureTable(mSdcard + mShapefilePath);
mFlayer = new FeatureLayer(shpFileFeatTable);
mFlayer.setRenderer(new SimpleRenderer(new SimpleMarkerSymbol(Color.CYAN, 2, STYLE.SQUARE)));
mMapView.addLayer(mFlayer);
} catch (FileNotFoundException e) {
Toast.makeText(getApplicationContext(), "File not found in SDCard, nothing to load", Toast.LENGTH_LONG)
.show();
} catch (RuntimeException e) {
Log.d("**ShapefileTest**", "File not found in SDCard, nothing to load");
Toast.makeText(getApplicationContext(), "File not found in SDCard, nothing to load", Toast.LENGTH_LONG)
.show();
}
【问题讨论】: