安卓智能地图开发与实施七:在线业务图层(浏览查询) - ArcGIS Runtime SDK for Android(Version 100.0.0)

0
分享 2017-08-21
业务图层(OperationalLayers)
业务图层(OperationalLayers)旨在可视化变化频繁的数据,可以通过ArcGISMapImageLayer加载现有的可视化成果,可以通过FeatureLayer来可视化要素,甚至查询、编辑。

对业务图层(OperationalLayers)的加载,针对移动端的处理方式分为在线和离线方式。在线方式主要通过ArcGIS Server 、ArcGIS Online、Portal for ArcGIS发布的地图服务(Map Service、 Feature Service)进行调用。离线方式主要通过ArcGIS Desktop(Geodatabase文件)、ArcGIS Pro(MMPK文件)生产的离线数据包进行访问。
在线业务图层 - 要素服务(Feature Service)

在线FeatureLayer通过ServiceFeatureTable来解析Feature Service。添加FeatureLayer,理论上或者说代码层面是可以不需要基础底图(Basemap),展示的结果就只是业务图层。但是ArcGISMap对象是需要新建出来的。例如:
ArcGISMap mainArcGISMap =new ArcGISMap(); mainMapView.setMap(mainArcGISMap);

在线FeatureLayer也可以通过PortalItem来承载,当然这个PortalItem必须包含Feature Service。



package hymn.esrichina.displayamapusingfeaturelayer;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.esri.arcgisruntime.data.ServiceFeatureTable;
import com.esri.arcgisruntime.geometry.Envelope;
import com.esri.arcgisruntime.geometry.SpatialReferences;
import com.esri.arcgisruntime.layers.FeatureLayer;
import com.esri.arcgisruntime.loadable.LoadStatus;
import com.esri.arcgisruntime.loadable.LoadStatusChangedEvent;
import com.esri.arcgisruntime.loadable.LoadStatusChangedListener;
import com.esri.arcgisruntime.mapping.ArcGISMap;
import com.esri.arcgisruntime.mapping.Basemap;
import com.esri.arcgisruntime.mapping.LayerList;
import com.esri.arcgisruntime.mapping.MobileMapPackage;
import com.esri.arcgisruntime.mapping.Viewpoint;
import com.esri.arcgisruntime.mapping.view.MapView;

import java.util.List;

public class MainActivity extends AppCompatActivity {
private MapView mainMapView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
String mainFeatureLayerURL =
"http://sampleserver6.arcgisonl ... 3B%3B
mainMapView = (MapView) findViewById(R.id.mainMapView);
final ServiceFeatureTable mainServiceFeatureTable = new ServiceFeatureTable(mainFeatureLayerURL);
mainServiceFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE);
mainServiceFeatureTable.addLoadStatusChangedListener(new LoadStatusChangedListener() {
@Override
public void loadStatusChanged(LoadStatusChangedEvent loadStatusChangedEvent) {
if (loadStatusChangedEvent.getNewLoadStatus() == LoadStatus.LOADED) {
ServiceFeatureTable.FeatureRequestMode mainFeatureRequestMode =
mainServiceFeatureTable.getFeatureRequestMode();
String mainFeatureRequestModeName = mainFeatureRequestMode.name();
}
}
});
FeatureLayer mainFeatureLayer = new FeatureLayer(mainServiceFeatureTable);
ArcGISMap mainArcGISMap = new ArcGISMap();
mainMapView.setMap(mainArcGISMap);
mainArcGISMap.getOperationalLayers().add(mainFeatureLayer);
mainArcGISMap.setInitialViewpoint(
new Viewpoint(
new Envelope(
-1.30758164047166E7,
4014771.46954516,
-1.30730056797177E7,
4016869.78617381,
SpatialReferences.getWebMercator())));

} catch (Exception e) {

}
}
}

ServiceFeatureTable加载完成之前,其图层中要素请求模式(getFeatureRequestMode())为UNDEFINED(未定义);加载完成后其图层中要素请求模式为ON_INTERACTION_CACHE(响应地图交互缓存),随着地图的操作(缩放、平移、旋转)自动缓存到本端。还可以通过设置BufferFactor属性,来预加载比当前地图范围更大的缓存。

图层中要素请求模式(FeatureRequestMode)


  • MANUAL_CACHE (手动缓存)
  • ON_INTERACTION_CACHE(响应地图交互缓存)
  • ON_INTERACTION_NO_CACHE(响应地图交互实时请求)
  • UNDEFINED(未定义)


对于一些多人协同编辑的业务,要素时时刻刻都有可能变化,建议设置图层中要素请求模式为ON_INTERACTION_NO_CACHE(响应地图交互实时请求),这样一来地图的每次交互都会从服务端请求最新的要素来显示。 对于设计数据量非常大的业务,实时加载在地图操作时已经影响到性能,建议设置图层中要素请求模式为MANUAL_CACHE (手动缓存),在需要显示图层要素时,再调用populateFromService方法来手动加载显示。
在线业务图层 - 动态地图服务(Map Service)

动态地图服务(Map Service)通过ArcGISMapImageLayer进行承载。直接给予动态地图服务地址(通过ArcGIS Server发布)即可。也可以通过PortalItem进行加载,PortalItem必须包含Map Service。

就ArcGISMapImageLayer自身而言,也可以加入基础底图(Basemap)中,当动态的底图使用。




ArcGISMapImageLayer包含着诸多自图层,通过SublayerList装载,每一个自图层为ArcGISMapImageSublayer对象。
package hymn.esrichina.displayamapusingarcgismapimagelayer;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.esri.arcgisruntime.layers.ArcGISMapImageLayer;
import com.esri.arcgisruntime.layers.ArcGISMapImageSublayer;
import com.esri.arcgisruntime.layers.SublayerList;
import com.esri.arcgisruntime.mapping.ArcGISMap;
import com.esri.arcgisruntime.mapping.Basemap;
import com.esri.arcgisruntime.mapping.view.MapView;

public class MainActivity extends AppCompatActivity {
private MapView mainMapView;
private ArcGISMapImageLayer mainMapImageLayer;
private SublayerList mainSublayerList;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
String mainArcGISMapImageLayerURL =
"http://sampleserver6.arcgisonl ... 3B%3B
mainMapView = (MapView) findViewById(R.id.mainMapView);
ArcGISMap mainArcGISMap = new ArcGISMap(Basemap.Type.TOPOGRAPHIC, 48.354406, -99.998267, 2);
mainMapImageLayer = new ArcGISMapImageLayer(mainArcGISMapImageLayerURL);
mainMapImageLayer.addDoneLoadingListener(new Runnable() {
@Override
public void run() {
mainSublayerList = mainMapImageLayer.getSublayers();
ArcGISMapImageSublayer mainMapImageSublayer = (ArcGISMapImageSublayer) mainSublayerList.get(0);
}
});
mainMapImageLayer.setOpacity(0.5f);
mainArcGISMap.getOperationalLayers().add(mainMapImageLayer);
mainMapView.setMap(mainArcGISMap);
} catch (Exception e) {

}
}
}


结尾



源程序包含:
DisplayAMapUsingArcGISMapImageLayer 
DisplayAMapUsingFeatureLayer 
请自行下载: 
链接:http://pan.baidu.com/s/1sli5MhR 密码:8gh8 
若失效,可发邮件给韩源萌(polyline@126.com)索要。
 
 安卓智能地图开发与实施一:配置离线SDK - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3304
 安卓智能地图开发与实施二:开发环境准备 - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3303
 安卓智能地图开发与实施三:创建第一个地图程序 - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3302
 安卓智能地图开发与实施四:二维地图的MapView与Layers - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3305
 安卓智能地图开发与实施五:在线基础底图 - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3309
 安卓智能地图开发与实施六:离线基础底图 - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3299
 安卓智能地图开发与实施七:在线业务图层(浏览查询) - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3298
 安卓智能地图开发与实施八:离线业务图层(浏览查询) - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3297
 安卓智能地图开发与实施九:地图缩放与旋转 - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3296
 安卓智能地图开发与实施十:图层管理 - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3295
 安卓智能地图开发与实施十一:业务数据查询 - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3294
 安卓智能地图开发与实施十二:空间查询与模糊搜索 - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3293
 安卓智能地图开发与实施十三:空间查询与展示 - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3308
 安卓智能地图开发与实施十四:业务数据编辑 - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3307
 安卓智能地图开发与实施十五:离线与同步 - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3306
 安卓智能地图开发与实施十六:三维地图 - ArcGIS Runtime SDK for Android(Version 100.1.0) :http://zhihu.esrichina.com.cn/article/3289
 安卓智能地图开发与实施十七:使用天地图 - ArcGIS Runtime SDK for Android(Version 100.1.0) :http://zhihu.esrichina.com.cn/article/3288
 安卓智能地图开发与实施十八:空间要素绘制 - ArcGIS Runtime SDK for Android(Version 100.1.0) :http://zhihu.esrichina.com.cn/article/3287
 安卓智能地图开发与实施十九:符号与渲染器 - ArcGIS Runtime SDK for Android(Version 100.1.0) :http://zhihu.esrichina.com.cn/article/3286
文章来源:http://blog.csdn.net/allenlu2008/article/details/71440288

0 个评论

要回复文章请先登录注册