arcgis android离线地图,Arcgis Android API开发之离线地图

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

java.lang.Object

com.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:

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//Layers");

在做之前,需要把数据拷贝到手机的SD卡里面:

545a9420fb8bd8cd1e6eb32f8a6769ae.png

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

用户权限配置好之后,布局文件中加入mapview空间,布局文件main.xml的代码如下:

xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="vertical"

>

xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@+id/map" android:layout_width="fill_parent"

android:layout_height="fill_parent">

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:

*

*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//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 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 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);

}

}

完成后效果如下图:

e1e324afe681cf974577f02c56df1a82.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值