Arcgis Android API开发之离线地图
最近一直在倒腾Arcgis Android API等相关的东西,想把自己的做的图放到地图上去,也就是离线地图,穷人一般是没有钱的,一个月好几十的流量是开不起的,所以就左捉摸,右思考,看着API里面有离线地图,始终没有弄明白是怎么回事,直到今天下午,想起来了就有试了试,结果成功了,那个激动啊,好半天那……
Arcgis Android API离线地图主要是通过ArcGISLocalTiledLayer实现的,下面是ArcGISLocalTiledLayer的相关内容:
java.lang.Objectcom.esri.android.map.Layer
com.esri.android.map.TiledLayer
com.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. */
@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/arcgis/Parcels/v101/Parcel Map");
local = new ArcGISLocalTiledLayer("file:///mnt/sdcard/arcgis/neimeng/Layers");
map.addLayer(local);
}
}
完成后效果如下图:
Arcgis Android API开发之离线地图的更多相关文章
- ArcGIS JavaScript API本地部署离线开发环境[转]
原文地址:http://www.cnblogs.com/brawei/archive/2012/12/28/2837660.html 1 获取ArcGIS JavaScript API API的下载地 ...
- ArcGIS for Android示例解析之离线地图-----LocalTiledLayer
转自:http://blog.csdn.net/wozaifeiyang0/article/details/7327423 LocalTiledLayer 看到这个标题是否是很激动,如题,该示例就是添 ...
- 基于 ArcGIS Silverlight API开发的WebGIS应用程序的部署
部署流程概述 在微软的iis服务器上部署基于ArcGIS Silverlight API的应用程序,主要包括以下几个步骤: 1)(可选)部署GIS服务 如果需要将GIS服务也部署在Web服务器上,则 ...
- Arcgis Javascript API 开发笔记
JS API3.4的要求 à(1) IE9或以上版本 否则dijit1.8.3不匹配 1.如何发布ArcgisJavascript API应用 0.准备工作: (1).有web应用: (2).有js ...
- ArcGIS JS API使用PrintTask打印地图问题解决汇总
环境:来源于工作过程,使用的API是 arcgis js 3.* 3系API,4.*暂时没测试: 1.数据与打印服务跨域情况下,不能打印问题. 一般情况下,我们发布的数据服务和打印服务是在一台服务 ...
- arcgis android 通过getExtent得到当前地图范围四个点的坐标
困扰了我很久的问题终于要得到解决了,先欢喜一下.我的目的是想做一个当程序完全退出后,再次打开程序地图直接显示上次程序退出前地图的范围.arcgis for android官方软件就有这个功能.网上搜索 ...
- Android API 文档 离线秒开方法
http://blog.csdn.net/haifengzhilian/article/details/39898627 也是最近才看Android开发,但是,它的API文档无论是在线还是离线的,实在 ...
- ARCGIS FLEX API加载google地图、百度地图、天地图(转)
http://www.cnblogs.com/chenyuming507950417/ Flex加载google地图.百度地图以及天地图作底图 一 Flex加载Google地图作底图 (1)帮助类G ...
- 为android游戏开发-准备的地图编辑器-初步刷地图
采用多文理混合,单页面支持8张文理进行刷绘
随机推荐
- HTML 块级元素与行内元素
1.块元素一般都从新行开始,它可以容纳内联元素和其他块元素,常见块元素是段落标签'P".“form"这个块元素比较特殊,它只能用来容纳其他块元素. 2.如果没有css的作用,块元素 ...
- 使用PHP模拟post提交数据
使用PHP模拟post提交数据 分类: PHP LAMP 2013-04-13 12:03 3954人阅读 评论(0) 收藏 举报 CurlsocketPHP 这也是个老生常谈的话题了,上午花了点时间 ...
- Delphi 正则表达式之TPerlRegEx 类的属性与方法(2): 关于子表达式
Delphi 正则表达式之TPerlRegEx 类的属性与方法(2): 关于子表达式 // MatchedExpression 与 SubExpressions[0] var reg: TPerl ...
- POJ 2253 Frogger (Dijkstra变型)
题意:求点1到点2的路径中,权值最大的那条边,其最小值是多少. 分析:最大值最小化.可以将迪杰斯特拉模板中的松弛操作加以修改,在O(n^2)的时间内解决该问题.其中需要注意的是,dist[i]指的是: ...
- 链接指示:extern "C"
C++程序有时需要调用其他语言编写的函数,最常见的是调用C语言编写的函数.像所有其他名字一样,其他语言中的函数名字也必须在C++中进行声明,并且该声明必须指定返回类型和形参列表.对于其他语言编写的函数 ...
- Android应用程序用真机调试步骤
仅供参考: 1.开启调试模式 2.安装 Adb.exe 将platform-tools文件夹里面adb.exe AdbWinApi.dll AdbWinUsbApi.dll拷贝到tools ...
- PC平台逆向破解
---恢复内容开始--- PC平台逆向破解 实践目标 本次实践的对象是一个名为pwn1的linux可执行文件. 该程序正常执行流程是:main调用foo函数,foo函数会简单回显任何用户输入的字符串. ...
- Linux常用命令--文件(夹)查找之find命令
Linux系统用得越久,就会发现这真的是一个很优秀的系统,各种方便各种实用各种高效率. 晚饭前写一下find命令的笔记. 其实这篇笔记,也是看到一篇外文博客,写得不错,自己拿来练一练,然后才顺便写篇笔 ...
- redis_入门网址
redis中文网: http://www.redis.cn/ 可以 试用 以及 下载 redis百度百科:http://baike.baidu.com/link?url=MEkE5MpGAOfJ7ci ...
- 配置zabbix通过微信报警企业微信报警
如今势态: 报警的方式可谓是八仙过海各显神通,如电话报警,短信报警,邮件报警,QQ报警,微信报警等等. 电话报警:一般都是使用别的平台的工具,平台给你提供一个接口供你使用,大多数为限量收费款 短信报警 ...
