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

xiaoxiao2021-02-28  117

在上一讲,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),可得到以下结果集

转载请注明原文地址: https://www.6miu.com/read-17380.html

最新回复(0)