android arcgis缓存,Android应用开发之Android Arcgis(15)、网络图层加载一

本文将带你了解Android应用开发Android Arcgis(15)、网络图层加载一,希望本文对大家学Android有所帮助。

一、首先我们来看一个网络图层:

https://services.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer,这是全球街道图。加载的代码也很简单:

private   static final String WORLD_STREETS_URL =   "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";

private MapView mMapView = null;

private ArcGISTiledMapServiceLayer mWorldStreetsLayer   = null;

@Override

protected void onCreate(Bundle savedInstanceState)   {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

mMapView = (MapView)   findViewById(R.id.map_view);

mWorldStreetsLayer = new ArcGISTiledMapServiceLayer(WORLD_STREETS_URL);

mMapView.addLayer(mWorldStreetsLayer);

mWorldStreetsLayer.setOnStatusChangedListener(new OnStatusChangedListener() {

@Override

public void onStatusChanged(Object o, STATUS status)   {

if (status==STATUS.INITIALIZED){

Log.i("huang","加载成功");

}else if(status==STATUS.INITIALIZATION_FAILED||status==STATUS.LAYER_LOADING_FAILED){

Log.i("huang","加载失败");

}

}

});

}

效果图

问:为什么用ArcGISTiledMapServiceLayer   加载而不用其他图层加载呢?

用浏览器打开

https://services.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer,可以看到详细信息。

它的子图层只有一个:

下面是坐标信息,注意Single   Fused Map Cache: true,支持缓存。

与Tile Info信息,

通过信息说明这是一个TiledLayer,而ArcGISTiledMapServiceLayer是TiledLayer子类的子类,看一下ArcGISTiledMapServiceLayer的介绍

点开World   Street   Map链接,

https://services.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer/0,这是它的唯一子图层。真正加载的也是这个图层

Type虽然说是FeatureLayer,但它得用ArcGISFeatureLayer加载。

ArcGISFeatureLayer arcGISFeatureLayer = new ArcGISFeatureLayer(WORLD_STREETS_URL+"/0",   ArcGISFeatureLayer.MODE.ONDEMAND);

SimpleFillSymbol simpleFillSymbol =   new   SimpleFillSymbol(Color.argb(0,0,0,0),SimpleFillSymbol.STYLE.SOLID);

mMapView.addLayer(arcGISFeatureLayer);

arcGISFeatureLayer.setRenderer(new SimpleRenderer(simpleFillSymbol));

arcGISFeatureLayer.setOnStatusChangedListener(new OnStatusChangedListener() {

@Override

public void onStatusChanged(Object o, STATUS status) {

if (status==STATUS.INITIALIZED){

Log.i("huang","加载成功");

}else if(status==STATUS.INITIALIZATION_FAILED||status==STATUS.LAYER_LOADING_FAILED){

Log.i("huang","加载失败");

}

}

});

上面虽然加载成功,但并看不到图层,而且报错:

FeatureSetCallback.onError

com.esri.core.io.EsriServiceException:   Requested operation is not supported by this service.

The requested capability is not   supported.

仔细再看网络信息,

大体上知道为什么报   The requested capability is not   supported。也就是不能用这种方法加载,而得用前面的代码加载!!!

本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标移动开发之Android频道!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值