Arcgis Android API开发之离线地图
Arcgis Android API离线地图主要是通过ArcGISLocalTiledLayer实现的,下面是ArcGISLocalTiledLayer的相关内容:</span> 上面的内容是从帮助文档里面粘贴过来的,英文水平不高,就不翻译了,各位的水平肯定比我高。下面就把做的例子展示一下吧: 在做之前,需要把数据拷贝到手机的SD卡里面,我的在手机里是这样组织的: 所用的数据呢,是用Arcgis Server切片的数据。数据弄好之后,因为你要读取Sd卡上的内容,所以,你得在AndroidManifest.xml文件中添加用户权限:java.lang.Object com.esri.android.map.Layer com.esri.android.map.TiledLayer com.esri.android.map.ags.ArcGISLocalTiledLayer
The ArcGISLocatlTiledLayer class is a type of tiled layer where the data is stored locally on the device, therefore this layer can function even when the device does not have any network connectivity. The data for this layer must be in an ArcGIS Compact Cache format. The typical compact cache structure is as follows:
<CacheName>
Layers
_allLayers, conf.cdi, conf.xml
The path used in the constructor of the ArcGISLocalTiledLayer must point to the Layers folder e.g.
ArcGISLocalTiledLayer local = new ArcGISLocalTiledLayer("file:///mnt/sdcard/<CacheName>/Layers");
<uses-permission android:name="android.permission.INTERNET" /><!-- 允许访问Internet --> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /><span style="font-family: Arial, Helvetica, sans-serif;"><!-- 允许写入Sd卡 --></span> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
用户权限配置好之后,布局文件中加入mapview空间,布局文件main.xml的代码如下: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <com.esri.android.map.MapView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/map" android:layout_width="fill_parent" android:layout_height="fill_parent"> </com.esri.android.map.MapView> </LinearLayout>
Activity的代码如下: