ArcGis for android 加载tpk离线文件(http://blog.csdn.net/vpingchangxin/article/details/8778869)

ArcGis for android 加载tpk离线文件

1.安装 arcgis android sdk (必须安装过 android sdk及 adt 环境喲)

创建一个本地缓存arcgis android项目 

如下代码

[java]  view plain copy
  1. package com.esri.arcgis.android.samples.localtiledlayer;  
  2.   
  3. import android.app.Activity;  
  4. import android.os.Bundle;  
  5. import android.os.Environment;  
  6.   
  7. import com.esri.android.map.MapView;  
  8. import com.esri.android.map.ags.ArcGISLocalTiledLayer;  
  9.   
  10. /** 
  11. * This sample illustrates the use of ArcGISLocatlTiledLayer where the data is stored locally on the device, therefore  
  12. * this layer can function even when the device does not have any network connectivity. The data for this layer must be  
  13. * in an ArcGIS Compact Cache format (Tile Packages or .tpk's are not currently supported). 
  14. * The typical compact cache structure is as  follows: 
  15. *   <CacheName><br> 
  16. *       Layers<br> 
  17. *           _allLayers<br> 
  18. *               conf.cdi,conf.xml<br> 
  19. * The path used in the constructor of the ArcGISLocalTiledLayer must point to the Layers folder e.g. <br> 
  20. *  ArcGISLocalTiledLayer local = new ArcGISLocalTiledLayer("file:///mnt/sdcard/<CacheName>/Layers"); 
  21. *   
  22. *  A sample data set has been created and is available via ArcGIS Online: 
  23. *  http://www.arcgis.com/home/item.html?id=d2d263a280164a039ef0a02e26ee0501 
  24. *  1) In order to use the data, download it from the url above 
  25. *  2) Copy the data to your sdcard 
  26. *  3) Set the path to the data by replacing <CacheName> with file:///mnt/sdcard/Parcels/v101/Parcel Map 
  27. *     on line60 below. 
  28. *   
  29. *  You can also use your own data if it is in an ArcGIS Compact Cache format, for more information on  
  30. *  this data format see this link:  
  31. *  http://blogs.esri.com/Dev/blogs/arcgisserver/archive/2010/05/27/Introducing-the-compact-cache-storage-format.aspx 
  32. *   
  33. **/  
  34.   
  35. public class LocalTiledLayer extends Activity {  
  36.   
  37.     MapView map = null;  
  38.     ArcGISLocalTiledLayer local;  
  39.   
  40.     /** Called when the activity is first created. */  
  41.     @Override  
  42.     public void onCreate(Bundle savedInstanceState) {  
  43.         super.onCreate(savedInstanceState);  
  44.         setContentView(R.layout.main);  
  45.         map = (MapView) findViewById(R.id.map);  
  46.           
  47.         //the data is stored on the SDCARD  
  48.         //the data is created as a tiled cache  
  49. //      local = new ArcGISLocalTiledLayer("file:///mnt/sdcard/ArcGIS/Basemap/Layers");  
  50. //      local = new ArcGISLocalTiledLayer(Environment.getExternalStorageDirectory()  
  51. //                      + "/YX1.tpk"); // 不行  
  52.         local = new ArcGISLocalTiledLayer("file:///storage/sdcard0/YX1.tpk"); // ok  
  53.         map.addLayer(local);  
  54.     }  
  55. }  

项目截图:

运行截图


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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值