Arcgis Android API開發之離線地圖
Arcgis Android API離線地圖主要是通過ArcGISLocalTiledLayer實現的,下面是ArcGISLocalTiledLayer的相關內容:</span>
java.lang.ObjectThe 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:com.esri.android.map.Layer
com.esri.android.map.TiledLayer
com.esri.android.map.ags.ArcGISLocalTiledLayer
<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");
上面的內容是從幫助文檔里面粘貼過來的,英文水平不高,就不翻譯了,各位的水平肯定比我高。下面就把做的例子展示一下吧:
在做之前,需要把數據拷貝到手機的SD卡里面,我的在手機里是這樣組織的:
所用的數據呢,是用Arcgis Server切片的數據。數據弄好之后,因為你要讀取Sd卡上的內容,所以,你得在AndroidManifest.xml文件中添加用戶權限:
<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=" 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> </pre><br />
Activity的代碼如下:
相關經驗
相關資訊