- 浏览: 1138809 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
RebeccaZhong:
严重: StandardWrapper.Throwableco ...
三步发布java方式的rest服务 -
RebeccaZhong:
严重: StandardWrapper.Throwableco ...
三步发布java方式的rest服务 -
冷酷月光:
楼主。请教一下。arcgis for android 有提供地 ...
ArcGIS API For Android离线地图的实现 -
winney117:
请问如何GET已有网页上的指定内容?比如百度文库中的某一篇文章 ...
三步发布java方式的rest服务 -
zige1012:
您好,我想问问我想换个自己地图的切片,也有4层(L0-L3), ...
ArcGIS API For Android离线地图的实现
今天搞了一个ArcGIS API For Android离线地图的实现。
效果如下:
Android的版本是2.1
main.xml,这里要说明的,初始化范围一定要有,不然会不能显示的。
AgsLOD.java
AgsOfflineTiledLayer.java
AgsOfflineTiledLayerModel.java
AgsOfflineTiles.java
在SD卡的瓦片数据的路径
源码和测试数据在附件中
呵呵,这个你要找esri中国了,不然有侵权的嫌疑了
这个是瓦片的算法,建议你看一下关于esri的瓦片生成原理
有一些包你在eclipse里提示可以找到
自己做的呀,arcgis server的切图呀,要不数据不大的话,我就上传了,方便大家的
用arcgis server切的图,可以附上自己的图不?
自己做的呀,arcgis server的切图呀,要不数据不大的话,我就上传了,方便大家的
你需要自己根据自己的地图文件修改一下里面固定参数呀,例如:4326
没有离线安装包,可能是eclipse的版本问题吧,第一次我也有这样的问题,多试几次就好了,个人感觉,ArcGIS for Android的API发布的比较着急,并没有很好的定位
没有
在线安装挺容易的,是不是eclipse的版本不对呀
效果如下:
Android的版本是2.1
main.xml,这里要说明的,初始化范围一定要有,不然会不能显示的。
<?xml version="1.0" encoding="utf-8"?> <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" initExtent="120.64101459999999 31.280566089 120.6769494 31.303135911"> <com.esri.arcgis.sample.AgsOfflineTiledLayer android:id="@+id/layer"/> </com.esri.android.map.MapView>
AgsLOD.java
package com.esri.arcgis.sample; import com.esri.core.internal.d.c; public class AgsLOD extends c { private static final long serialVersionUID = 4341699179151728883L; private int level; private double resolution; private double scale; public AgsLOD(int level, double scale, double resolution) { super(); this.level = level; this.scale = scale; this.resolution = resolution; } public int a() { return this.level; } public double b() { return this.resolution; } public double c() { return this.scale; } }
AgsOfflineTiledLayer.java
package com.esri.arcgis.sample; import java.io.File; import java.util.ArrayList; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import com.esri.android.map.TiledLayer; import com.esri.core.geometry.Envelope; import com.esri.core.geometry.Point; import com.esri.core.geometry.SpatialReference; import com.esri.core.internal.d.c; import com.esri.core.internal.d.k; import com.esri.core.map.TiledLayerModel; public class AgsOfflineTiledLayer extends TiledLayer { //瓦片文件的路径呀 private String location = "/sdcard/BaseMap/Layers"; //REST里面的空间参考 private SpatialReference spatialReference = SpatialReference.create(4326); //全图范围 private Envelope fullExtent = new Envelope(120.64101459999999, 31.280566089, 120.6769494, 31.303135911); private k tileInfo; public AgsOfflineTiledLayer(Context context, AttributeSet attrs) { super(context, attrs); try { init(); } catch (Exception ex) { ex.printStackTrace(); } } @Override protected TiledLayerModel initModel() throws Exception { return new AgsOfflineTiledLayerModel(location, spatialReference, fullExtent, tileInfo); } private void init() { String confPath = location + File.separator + "conf.xml"; Log.i("conf", confPath); try { tileInfo = new k(); DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory .newInstance(); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); File file = new File(confPath); Document doc = docBuilder.parse(file); NodeList nsX = doc.getElementsByTagName("X"); double originX = Double.valueOf(nsX.item(0).getFirstChild() .getNodeValue()); NodeList nsY = doc.getElementsByTagName("Y"); double originY = Double.valueOf(nsY.item(0).getFirstChild() .getNodeValue()); tileInfo.f = new Point(originX, originY); NodeList nsTileRows = doc.getElementsByTagName("TileRows"); tileInfo.a = Integer.valueOf(nsTileRows.item(0).getFirstChild() .getNodeValue()); NodeList nsTileCols = doc.getElementsByTagName("TileCols"); tileInfo.b = Integer.valueOf(nsTileCols.item(0).getFirstChild() .getNodeValue()); NodeList nsLODInfos = doc.getElementsByTagName("LODInfos"); tileInfo.h = new ArrayList<c>(); NodeList lodInfos = nsLODInfos.item(0).getChildNodes(); for (int j = 0, jcount = lodInfos.getLength(); j < jcount; j++) { Node lod = lodInfos.item(j); NodeList list = lod.getChildNodes(); int level = Integer.valueOf(list.item(0).getFirstChild() .getNodeValue()); double scale = Double.valueOf(list.item(1).getFirstChild() .getNodeValue()); double resolution = Double.valueOf(list.item(2).getFirstChild() .getNodeValue()); tileInfo.h.add(new AgsLOD(level, scale, resolution)); } } catch (Exception e) { e.printStackTrace(); } } }
AgsOfflineTiledLayerModel.java
package com.esri.arcgis.sample; import java.io.File; import java.io.FileInputStream; import android.util.Log; import com.esri.core.geometry.Envelope; import com.esri.core.geometry.SpatialReference; import com.esri.core.internal.d.k; import com.esri.core.map.TiledLayerModel; public class AgsOfflineTiledLayerModel extends TiledLayerModel { private static final long serialVersionUID = 7726567118839553087L; private String location; public AgsOfflineTiledLayerModel(String location, SpatialReference sr, Envelope full, k tileInfo) { super(sr, full, tileInfo); this.location = location; } @Override public byte[] getTile(int level, int row, int col) throws Exception { byte[] result = null; try { String bundlesDir = location + File.separator + "_alllayers"; Log.i("location", bundlesDir); String l = "0" + level; int lLength = l.length(); if (lLength > 2) { l = l.substring(lLength - 2); } l = "L" + l; int rGroup = 128 * (row / 128); String r = "000" + Integer.toHexString(rGroup); int rLength = r.length(); if (rLength > 4) { r = r.substring(rLength - 4); } r = "R" + r; int cGroup = 128 * (col / 128); String c = "000" + Integer.toHexString(cGroup); int cLength = c.length(); if (cLength > 4) { c = c.substring(cLength - 4); } c = "C" + c; String bundleBase = String .format("%s/%s/%s%s", bundlesDir, l, r, c); String bundlxFileName = bundleBase + ".bundlx"; String bundleFileName = bundleBase + ".bundle"; int index = 128 * (col - cGroup) + (row - rGroup); FileInputStream isBundlx = new FileInputStream(bundlxFileName); isBundlx.skip(16 + 5 * index); byte[] buffer = new byte[5]; isBundlx.read(buffer); long offset = (long) (buffer[0] & 0xff) + (long) (buffer[1] & 0xff) * 256 + (long) (buffer[2] & 0xff) * 65536 + (long) (buffer[3] & 0xff) * 16777216 + (long) (buffer[4] & 0xff) * 4294967296L; FileInputStream isBundle = new FileInputStream(bundleFileName); isBundle.skip(offset); byte[] lengthBytes = new byte[4]; isBundle.read(lengthBytes); int length = (int) (lengthBytes[0] & 0xff) + (int) (lengthBytes[1] & 0xff) * 256 + (int) (lengthBytes[2] & 0xff) * 65536 + (int) (lengthBytes[3] & 0xff) * 16777216; result = new byte[length]; isBundle.read(result); } catch (Exception ex) { ex.printStackTrace(); } return result; } }
AgsOfflineTiles.java
package com.esri.arcgis.sample; import com.esri.android.map.MapView; import android.app.Activity; import android.os.Bundle; public class AgsOfflineTiles extends Activity { MapView map = null; AgsOfflineTiledLayer layer = null; /** 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); layer = (AgsOfflineTiledLayer) findViewById(R.id.layer); } }
在SD卡的瓦片数据的路径
源码和测试数据在附件中
- BaseMap.rar (1.5 MB)
- 下载次数: 2045
- AgsOfflineTiles.rar (2.4 MB)
- 下载次数: 2059
评论
17 楼
Virgo_S
2011-09-17
眼高手低 写道
您能给我提供一个ArcGIS Server 10的下载地址吗?我在网上找了好几天也没找到。
呵呵,这个你要找esri中国了,不然有侵权的嫌疑了
16 楼
眼高手低
2011-09-16
您能给我提供一个ArcGIS Server 10的下载地址吗?我在网上找了好几天也没找到。
15 楼
眼高手低
2011-09-16
我是个新手,不太明白您说的“有一些包你在eclipse里提示可以找到”。您指的是"import com.esri.core.internal.d.k;",然后将光标放在上面后给出的那个提示吗?我的Eclipse给出的是"Note: This element has no attached source and the Javadoc could not be found in the attached Javadoc"。这应该是没有相关信息的意思吧?
14 楼
Virgo_S
2011-09-14
眼高手低 写道
AgsOfflineTiledLayerModel.java部分从int index = 128 * (col - cGroup) + (row - rGroup);开始我就没看懂,您能给解释一下吗?
这个是瓦片的算法,建议你看一下关于esri的瓦片生成原理
13 楼
Virgo_S
2011-09-14
眼高手低 写道
您好,我想请教一个问题。就是com.esri.core.internal.d.c和com.esri.core.internal.d.k是什么类啊?我看到工程目录中有很多这样后面是简单字母的包及类。这些在参考中又查不到。当然除了这些之外还有许多查不到的包及类。我能不能知道您是通过什么渠道学习那些参考中查不到的包及类的?我是个新人,刚刚接触ArcGIS API for Android,手上只有一个《ArcGIS API for Android+案例教程》,您能不能给推荐一些资料?我万分感谢!
有一些包你在eclipse里提示可以找到
12 楼
眼高手低
2011-09-08
AgsOfflineTiledLayerModel.java部分从int index = 128 * (col - cGroup) + (row - rGroup);开始我就没看懂,您能给解释一下吗?
11 楼
眼高手低
2011-09-08
您好,我想请教一个问题。就是com.esri.core.internal.d.c和com.esri.core.internal.d.k是什么类啊?我看到工程目录中有很多这样后面是简单字母的包及类。这些在参考中又查不到。当然除了这些之外还有许多查不到的包及类。我能不能知道您是通过什么渠道学习那些参考中查不到的包及类的?我是个新人,刚刚接触ArcGIS API for Android,手上只有一个《ArcGIS API for Android+案例教程》,您能不能给推荐一些资料?我万分感谢!
10 楼
anndaming
2011-08-31
Virgo_S 写道
anndaming 写道
请问一下,你这个离线地图,是自己做的么,怎么做的?
自己做的呀,arcgis server的切图呀,要不数据不大的话,我就上传了,方便大家的
用arcgis server切的图,可以附上自己的图不?
9 楼
Virgo_S
2011-08-31
anndaming 写道
请问一下,你这个离线地图,是自己做的么,怎么做的?
自己做的呀,arcgis server的切图呀,要不数据不大的话,我就上传了,方便大家的
8 楼
anndaming
2011-08-31
请问一下,你这个离线地图,是自己做的么,怎么做的?
7 楼
helloandroid
2011-08-25
呵呵,真在搞android离线地图,谢过
6 楼
Virgo_S
2011-08-17
hjh811 写道
级别有问题 放大的时候会有问题 放大图调用不了
你需要自己根据自己的地图文件修改一下里面固定参数呀,例如:4326
5 楼
hjh811
2011-08-15
级别有问题 放大的时候会有问题 放大图调用不了
4 楼
Virgo_S
2011-05-25
trojantale 写道
楼主有ArcGIS for Android的离线安装包吗?为什么我在线安装老是出现错误?
没有离线安装包,可能是eclipse的版本问题吧,第一次我也有这样的问题,多试几次就好了,个人感觉,ArcGIS for Android的API发布的比较着急,并没有很好的定位
3 楼
sjrhero
2011-05-11
我哥们儿说你很牛X:特别让我来给你送句祝福的话儿。祝你天天开心。。。他说对你顶礼膜拜 !!!!过两天他就来亲自找你了。。嘿嘿。。。
2 楼
Virgo_S
2011-04-25
trojantale 写道
楼主有ArcGIS for Android的离线安装包吗?为什么我在线安装老是出现错误?
没有
在线安装挺容易的,是不是eclipse的版本不对呀
1 楼
trojantale
2011-04-23
楼主有ArcGIS for Android的离线安装包吗?为什么我在线安装老是出现错误?
发表评论
-
Java中使用Sqlite数据库
2011-03-24 00:04 3544Sqlite数据库第三方java扩展包下载地址:http:// ... -
Android SDK 2.2 离线安装
2011-03-19 21:14 4128Android各版本的市场份额 android的普通安装 ... -
ACOD:如何在eclipse中使用离线文档中的中文Javadoc
2011-03-19 21:08 24830、下载ACOD(Android Chinese Offlin ... -
Android RatingBar 评分条
2011-03-18 00:31 2954RatingBar评分条是SeekBar拖动条的子类。现阶段系 ... -
Android SeekBar 拖动条 滑动条
2011-03-18 00:29 9415SeekBar可以作为音乐播放器的进度指示和调整工具,音量调整 ... -
Android ProgressBar 进度条
2011-03-18 00:25 3269在某项延续性工作的进 ... -
Android Menu
2011-03-17 23:08 1790本讲内容:菜单 menu (Android 2.1) 1、选项 ... -
Activity之间的相互调用与传递参数
2011-03-16 22:25 5139Activity之间是如何调用的 Activity与Activ ...
相关推荐
ArcGIS API for Android离线文档
arcgis for android api 离线 版本 下载
ArcGIS API for Android 1.0离线文档
ArcGIS Android 2.0 API 离线文档
ArcGIS Runtime for Android 2.0离线文档
ArcGIS Runtime for Android API 10.1.1离线文档
ArcGIS Android 10.1.1 API离线帮助手册。
arcgis for android 2.0 的离线文档
使用ArcGIS for Android开发的加载GoogleMap地图。并判断无网络时自动加载本地图片。图片存放在/ArcGIS/samples/tiledcache/下。在有网络时自动存储地图图片。未做容量控制及清空策略。并集成了从ArcGIS Server缓存...
arcgis-runtime-sdk-android-100.9.0
通过ArcGIS for Android API提供的接口实现添加标绘。内有android程序和离线切片地图。
2. ArcGIS Runtime for Android简介 2 第二章. 开发环境配置 4 1. 系统要求 4 2. Android配置 5 3. ArcGIS Runtime for Android配置 7 4. 使用Android模拟器开发 8 5. 使用Android设备开发 10 第三章. 创建第...
• 大量的预定义图块源:Google地图,Mapbox,ArcGIS,诺基亚地图,必应地图,Open Street Maps和其他许多地图项(16个提供程序,88种地图类型); • 能够创建自己的地图样式或使用自己的图块源(例如,WMS); • ...
基于android平台的arcgis开发,包括jar包、英文离线html格式文档、安装使用方法、中文案例(pdf)
supermap加载天地图图层API,非常的试用
•在线和离线地图; •带有高程的2D地图和3D地图; •2D,3D和Billboard标记; •支持Texture,NGUI,SpriteRenderer,uGUI(UIImage,UIRawImage)和Tileset; •谷歌地图,Mapbox,ArcGIS,诺基亚地图(HERE.com)...
离线风力涡轮机检查员机器人========================================弃用通知此存储库已被弃用,因为 ArcGIS Android API 已更新用于处理离线数据的 API 模式。 请参阅了解现代离线模式,并查看了解未来更多此类...