Android Arcgis(16)、网络图层加载二

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Gary__123456/article/details/77726813

在上一讲,Android Arcgis(15)、网络图层加载一,简单介绍了加载网络服务。下面我们继续学习加载网络图层。

一、ArcGISDynamicMapServiceLayer

服务地址:
http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer,这是美国的高铁图。
用浏览器打开,有三个子图层,Single Fused Map Cache: false!
这里写图片描述
下面是ArcGISDynamicMapServiceLayer的介绍:
这里写图片描述
加载代码 :

  private static final String DYNAMIC_USA_HIGHWAY_URL = "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer";
    private ArcGISDynamicMapServiceLayer usaHighwayLayer = null;
    private MapView mMapView = null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mMapView = (MapView) findViewById(R.id.map_view);
        usaHighwayLayer = new ArcGISDynamicMapServiceLayer(DYNAMIC_USA_HIGHWAY_URL);
        mMapView.addLayer(usaHighwayLayer);
        usaHighwayLayer.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","加载失败");
                }
            }
        });}

效果图
这里写图片描述

二、ArcGISFeatureLayer加载图层

服务地图
http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer/0,也就是上面服务的子图层。

    ArcGISFeatureLayer arcGISFeatureLayer = new ArcGISFeatureLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer/0", ArcGISFeatureLayer.MODE.ONDEMAND);
        mMapView.addLayer(arcGISFeatureLayer);
        arcGISFeatureLayer.setRenderer(new SimpleRenderer(new SimpleLineSymbol(Color.argb(250, 52, 17, 255),2)));
        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","加载失败");
                }
            }
        });

注意要设置setRenderer,效果
这里写图片描述
ArcGISFeatureLayer 具有FeatureLayer的一些查询方法,与前面几讲里FeatureLayer查询相似,这里不再讲了。

//查询要素方法
queryIds(Query query, CallbackListener<int[]> callback)
queryFeatures(Query query, CallbackListener<FeatureSet> callback)

http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer/0,页面底部,

这里写图片描述

点击Query进入查询要素界面,可直接 查询要素

这里写图片描述

where 1=1,点击Query(GET),可得到以下结果集

这里写图片描述

阅读更多

没有更多推荐了,返回首页