ArcGIS for Android利用LocalTiledLayer 打开离线地图

package com.esri.arcgis.android.samples.localtiledlayer;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;

import com.esri.android.map.MapView;
import com.esri.android.map.ags.ArcGISLocalTiledLayer;
import com.esri.android.map.event.OnSingleTapListener;
import com.esri.core.geometry.Point;

/**
* This sample illustrates the use of ArcGISLocatlTiledLayer 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 (Tile Packages or .tpk's are not currently supported).
* The typical compact cache structure is as  follows:
* <CacheName><br>
*  Layers<br>
*   _allLayers<br>
*    conf.cdi,conf.xml<br>
* The path used in the constructor of the ArcGISLocalTiledLayer must point to the Layers folder e.g. <br>
*  ArcGISLocalTiledLayer local = new ArcGISLocalTiledLayer("file:///mnt/sdcard/<CacheName>/Layers");

*  A sample data set has been created and is available via ArcGIS Online:
http://www.arcgis.com/home/item.html?id=d2d263a280164a039ef0a02e26ee0501
*  1) In order to use the data, download it from the url above
*  2) Copy the data to your sdcard
*  3) Set the path to the data by replacing <CacheName> with file:///mnt/sdcard/Parcels/v101/Parcel Map
*     on line60 below.

*  You can also use your own data if it is in an ArcGIS Compact Cache format, for more information on
*  this data format see this link:
http://blogs.esri.com/Dev/blogs/arcgisserver/archive/2010/05/27/Introducing-the-compact-cache-storage-format.aspx

**/

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
  
  local = new ArcGISLocalTiledLayer("file:///mnt/sdcard/Parcels/v101/Parcel Map");
  map.addLayer(local);

 }
}

 

代码就是这样的,可以从http://www.arcgis.com/home/item.html?id=d2d263a280164a039ef0a02e26ee0501 这里下载sample data set(Parcels.zip)将其解压文件夹结构为:Parcels/v101/Parcel Map.将Parcels文件夹复制到手机sd卡上就可以运行咯

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值