最近一直在倒腾Arcgis Android API等相关的东西,想把自己的做的图放到地图上去,也就是离线地图,穷人一般是没有钱的,一个月好几十的流量是开不起的,所以就左捉摸,右思考,看着API里面有离线地图,始终没有弄明白是怎么回事,直到今天下午,想起来了就有试了试,结果成功了,那个激动啊,好半天那……

Arcgis Android API离线地图主要是通过ArcGISLocalTiledLayer实现的,下面是ArcGISLocalTiledLayer的相关内容:

java.lang.Objectcom.esri.android.map.Layercom.esri.android.map.TiledLayercom.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");

上面的内容是从帮助文档里面粘贴过来的,英文水平不高,就不翻译了,各位的水平肯定比我高。下面就把做的例子展示一下吧:

在做之前,需要把数据拷贝到手机的SD卡里面,我的在手机里是这样组织的:

所用的数据呢,是用Arcgis Server切片的数据。数据弄好之后,因为你要读取Sd卡上的内容,所以,你得在AndroidManifest.xml文件中添加用户权限:

<uses-permission android:name="android.permission.INTERNET" /><!-- 允许访问Internet -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /><!-- 允许写入Sd卡 -->
<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的代码如下:

/* Copyright 2012 ESRI** All rights reserved under the copyright laws of the United States* and applicable international laws, treaties, and conventions.** You may freely redistribute and use this sample code, with or* without modification, provided you include the original copyright* notice and use restrictions.** See the �Sample code usage restrictions� document for further information.**/package com.esri.arcgis.android.samples.localtiledlayer;import android.app.Activity;
import android.os.Bundle;import com.esri.android.map.MapView;
import com.esri.android.map.ags.ArcGISLocalTiledLayer;/**
* 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 or packaged as a Tile package (*.tpk).
*
* 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 <Path-to-local-data> with file:///mnt/sdcard/Parcels/v101/Parcel Map
*     on line68 below.
*
*  A sample Tile Map Package has been created and is available via ArcGIS Online:
*  http://www.arcgis.com/home/item.html?id=4497b7bb42e543b691027840d1b9092a
*  1) In order to use the data, download it from the url above
*  2) Copy the data to your device
*  3) Set the path to the *.tpk file by replacing <Path-to-local-data> on line 68 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. */@Overridepublic 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/arcgis/Parcels/v101/Parcel Map");local = new ArcGISLocalTiledLayer("file:///mnt/sdcard/arcgis/neimeng/Layers");map.addLayer(local);}
}

完成后效果如下图:

转载于:https://www.cnblogs.com/lzugis/p/6539918.html

Arcgis Android API开发之离线地图相关推荐

  1. 如何用百度离线API调用百度离线地图

    这里以广西南宁市为例,说明如何用百度离线API调用百度离线地图. 首先,点击视图左上方的地图类型按钮选择百度地图(如果没有该项请点击"更多"选项),然后在视图右上方选择广西省南宁市 ...

  2. Android Map 开发之高德地图

    android Map 开发之google Map 可参考文档    链接 本文总结的是Android Map 开发之高德地图,以下是详细代码及注释: 如何把 API 添加到我的Android 工程中 ...

  3. 离线地图开发--BigeMap(离线地图服务器构建,支持百度、谷歌、高德等地图)

    前言: 目前高德地图以及百度谷歌等地图对Web端离线功能支持不太友好(甚至没有离线地图功能),这致使我们在进行内网服务器使用的地图开发时非常的不便利,因此在进行离线地图开发时我们通常选择引入第三方地图 ...

  4. ArcGIS JavaScript API本地部署离线开发环境

    1 获取ArcGIS JavaScript API API的下载地址http://support.esrichina.com.cn/2011/0223/960.html,在下载页面会看到api和sdk ...

  5. ArcGIS for Android示例解析之离线地图-----LocalTiledLayer

    转自:http://blog.csdn.net/wozaifeiyang0/article/details/7327423 LocalTiledLayer 看到这个标题是否是很激动,如题,该示例就是添 ...

  6. C# .NET winform地图开发GMap离线地图在线地图自建地图服务器

    目录 添加GMap引用 下载GMap demo 尝试一个测试程序 下载离线地图 使用离线模式读取地图 加载高德地图 获取WMTS 坐标系转化 GMap常用地图操作 自建地图服务器 添加GMap引用 下 ...

  7. android导航地图,地图导航-Android平台-开发指南-高德地图车机版 | 高德地图API

    直接导航 传入终点,以用户当前车位为起点直接发起导航. 参数说明 参数说明是否必填类型 ActionAUTONAVI_STANDARD_BROADCAST_RECV是String KEY_TYPE协议 ...

  8. android高德地图搜索地址,地点/周边搜索-Android平台-开发指南-高德地图车机版 | 高德地图API...

    关键字搜索 第三方通过该接口可传入关键字信息给auto,调起auto执行关键字搜索并跳转到搜索结果展现界面,官网版本都可支持 参数说明 参数说明是否必填类型 ActionAUTONAVI_STANDA ...

  9. android 高德地图周边,地点/周边搜索-Android平台-开发指南-高德地图车机版 | 高德地图API...

    关键字搜索 第三方通过该接口可传入关键字信息给auto,调起auto执行关键字搜索并跳转到搜索结果展现界面,官网版本都可支持 参数说明 参数说明是否必填类型 ActionAUTONAVI_STANDA ...

  10. 高德地图Web端JavaScript API开发(二)---在地图上绘制(点标注)

    使用高德地图在很多时候需要在地图上标记位置,并且很多时候需要用到自定义的图标去完成这种位置的标记. 当然,这些功能高德地图都为我们准备了,比如常用的地图覆盖物Marker和信息窗体等.这里就先说一下点 ...

最新文章

  1. Java魔法堂:深入正则表达式API
  2. mysql三大范式 答案_数据库三大范式定义与理解
  3. 使用netron对TensorFlow、Pytorch、Keras、PaddlePaddle、MXNet、Caffe、ONNX、UFF、TNN、ncnn、OpenVINO等模型的可视化
  4. django 的form登录 注册
  5. 2013年新的开始,每周至少要写一篇博客!
  6. Apache-DBUtils实现CRUD操作,已封装的API实现jdbc对数据库进行操作
  7. Linux 笔记 - 第九章 Linux 中软件的安装
  8. ElasticSearch vs. Solr
  9. 百度路书 信息显示_学会用地图制作路书,分分钟从小白变成自驾游达人
  10. Intel处理器家族和分类
  11. 利用.NET绘图技术制作水晶按钮控件(转)
  12. ARMLINUX学习笔记(3)---安装交叉编译器
  13. KMP模式匹配 三(弦)
  14. 反射--获取构造器,获取父类,获取带泛型的父类,获取实现的接口,获取所在的包,获取注解
  15. Python数据分析-绘图-2-Seaborn进阶绘图-6-回归图
  16. 国外问卷调查为什么这么热门?
  17. 湖南省中小学教师计算机培训,隆回信技术应用能力提升工程2.0管理团队和培训团队在长沙开班...
  18. Docker构建JDK 镜像
  19. 微型计算机原理中的mov,微机原理考试题目类型
  20. 《Docker系列》Docker安装Hadoop

热门文章

  1. 经典排序算法(七)--冒泡排序Bubble Sort
  2. 屏幕居中(DIV/CSS) 的几种方法
  3. C++游戏服务器开发常用工具介绍(转载)
  4. VS2015 关闭错误列表
  5. 二叉树的前中后序遍历的三种实现(java)以及一些小习题
  6. c# 存储图片到oracle,c# winform 读取oracle中blob字段的图片并且显示到pictureBox里 保存进库...
  7. python字典的基本操作编程_Python入门教程5. 字典基本操作【定义、运算、常用函数】 原创...
  8. java中 t无法对齐,java – 即使X应匹配T,也无法将X转换为T?
  9. JavaWeb:JSON对象和Java对象的相互转换
  10. Go语言:内存存储模型(对于可执行程序)