Android开发,arcgis自定义layer-历史影像和地图缓存的实现

本文介绍了在Android开发中,如何使用ArcGIS进行自定义layer以实现历史影像显示和地图缓存功能。对于历史影像,通过继承ArcGISTiledMapServiceLayer并实现关键方法。地图缓存部分,详细阐述了利用SQLite存储和检索地图图片的过程,以及在网络条件和缓存管理方面的考虑。
摘要由CSDN通过智能技术生成

Arcgis自带有很多的layer,一般来说,可以直接使用,但是在某些特殊的情况下,自带的就无法满足我们的需求了

下面是我最近所使用到的两种自定义layer的实现及使用

一、历史影像

继承的是ArcGISTiledMapServiceLayer

首先我们需要知道,继承layer需要实现哪些方法

第一个构造方法这个不用说

第二个getTile,这个方法是必须的,用于获取添加的图片文件或bundle文件的二进制数组

第三个可以选择,实现initLayer,用于初始化时进行的一些操作


先看一下整体代码

public class ArcGISTimeSpaceLayer extends ArcGISTiledMapServiceLayer {

	private String mUrl = null;
	private String mTime = null;

	public ArcGISTimeSpaceLayer(String time, String url) {
		super(url);
		this.mTime = time;
		this.mUrl = url;
		this.init();
	}

	private void init() {
		try {
			getServiceExecutor().submit(new Runnable() {
				public void run() {
					ArcGISTimeSpaceLayer.this.initLayer();
				}
			});
		} catch (RejectedExecutionException rejectedexecutionexception) {
			Log.e("ArcGIS", "initialization of the layer failed.", rejectedexecutionexception);
		}
	}

	@Override
	protected byte[] getTile(int level, int col, int row) throws Exception {
		byte[] result = null;
		try {
			URL url = new URL(mUrl + "/exts/TimeSpatialTileRestSOE/getTileOperation?" + "&time=" + mTime + "&level=" + level + "&row=" + row
					+ "&col=" + col + "&f=png" + "&username=" + "&key=");
			byte[] buf = new byte[1024];
			HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();
			httpConnection.connect();
			BufferedInputStream is = new BufferedInputStream(httpConnection.getInputStream());
			ByteArrayOutputStream bos = new ByteArrayOutputStream();
			int temp = -1;
			while ((temp = is.read(buf)) > 0) {
				bos.write(buf, 0, temp);
			}
			is.close();
			httpConnec
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值