在API10.1.1版本中,离线地图很容易实现,只要用ArcGISLocalTiledLayer类就行了,他也是一个Layer他的初始化可以使用碎片文件夹地址
或者一个打包文件.tpk文件。其中后者就是给前者打了个包,加了一个参数。下面是demo源码,测试数据为test.tpk文件,将文件下载下来放在手机sd卡根目录既可使用。下载地址: http://download.csdn.net/detail/guet_wukin/5814595
package com.esri.arcgis.android.samples.localtiledlayer;
import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import com.esri.android.map.MapView;
import com.esri.android.map.ags.ArcGISLocalTiledLayer;
public class LocalTiledLayer extends Activity {
MapView map = null;
ArcGISLocalTiledLayer local;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
map = (MapView) findViewById(R.id.map);
//the data is stored on the SDCARD
//the data is created as a tiled cache
String path = Environment.getExternalStorageDirectory().getPath();
Log.i("path",path);
local = new ArcGISLocalTiledLayer("file:///mnt/sdcard/test.tpk");
map.addLayer(local);
}
}
- <?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>