在10.2裡MapView直接繼承于ViewGroup類,本身就是地圖内容的展示容器,使用時候直接在MapView可以加載各種基礎底圖、業務圖層和繪制圖層。
- 切片資料圖層(ArcGISTiledLayer)
切片資料主要用來做為底圖的展示,包含渲染後的地圖和地圖的空間參考資訊,其離線資料的格式為TPK。
說是新增,其實是将之前的ArcGISLocalTiledLayer類和ArcGISTiledMapServiceLayer類合并成一個,也就是說這個類既可以加載離線TPK資料,也可以加載線上切片資料。
離線資料:
String url = StorageUtil.getSDCardRootPath(getApplicationContext()) + "/ydyzt/data/YGYX.tpk";
TileCache mainTileCache = new TileCache(url);
ArcGISTiledLayer layer = new ArcGISTiledLayer(mainTileCache);
線上資料:
String theURLString ="http://map.geoq.cn/arcgis/rest/services/ChinaOnlineCommunity/MapServer";
ArcGISTiledLayer mainArcGISTiledLayer = new ArcGISTiledLayer(theURLString);
- 矢量切片資料圖層(ArcGISVectorTiledLayer)
矢量切片資料是ArcGIS10.4裡推出的一種新資料,它在傳統的切片資料的基礎上同時打包了矢量資料,是以除了展示外,也可以提供查詢的功能。其離線打包資料格式為VTPK。
Runtime100裡采用ArcGISVectorTiledLayer類來展示矢量切片資料,使用方法和ArcGISTiledLayer類相似:
離線資料:
String url = StorageUtil.getSDCardRootPath(getApplicationContext()) + "/ydyzt/data/YGYX_YS.vtpk";
ArcGISVectorTiledLayer layer = new ArcGISVectorTiledLayer(mainTileCache);
線上資料:
String theOfflineTiledLayers ="https://www.arcgis.com/home/item.html?id=e19e9330bf08490ca8353d76b5e2e658";
ArcGISVectorTiledLayer mainArcGISVectorTiledLayer = new ArcGISVectorTiledLayer(theOfflineTiledLayers);
- 要素圖層(FeatureLayer)
要素資訊是ArcGIS的最基本的資訊,包含了矢量資訊以及與之對應的表資料,可以用來進行展示、查詢、分析、編輯等。其離線資料格式為geodatabase。
Runtime100裡依然保留了ArcGIS的經典圖層——FeatureLayer,每個要素圖層裡都通過一個FeatureTable構造來。FeatureTable可以通過離線geodatabase擷取,也可以通過線上的要素服務得到:
離線資料:
String path=StorageUtil.getSDCardRootPath(getApplicationContext())+"/ydyzt/data/GD_TDYT.geodatabase";
final Geodatabase localGdb=new Geodatabase(path);
localGdb.loadAsync();
localGdb.addDoneLoadingListener(new Runnable() {
@Override
public void run() {
LayerList mainLayerList = arcGISMap.getOperationalLayers();
for (GeodatabaseFeatureTable gdbFeatureTable : localGdb.getGeodatabaseFeatureTables()) {
FeatureLayer dataFeatureLayer = new FeatureLayer(gdbFeatureTable);
mainLayerList.add(dataFeatureLayer);}}});
線上資料:
String mainFeatureLayerURL =
"http://sampleserver6.arcgisonline.com/arcgis/rest/services/PoolPermits/FeatureServer/0";
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();
}
}
});
- 動态地圖圖層(ArcGISMapImageLayer和ArcGISMapImageSublayer)
動态地圖圖層ArcGISMapImageLayer是通過通路動态地圖服務MapService擷取的,裡面包含的是一個子圖層集合SublayerList,通過這個子圖層集合可以構造得到每個動态地圖圖層 ArcGISMapImageSublayer:
String mainArcGISMapImageLayerURL =
"http://sampleserver6.arcgisonline.com/arcgis/rest/services/SampleWorldCities/MapServer";
final ArcGISMapImageLayer mainMapImageLayer = new ArcGISMapImageLayer(mainArcGISMapImageLayerURL);
mainMapImageLayer.addDoneLoadingListener(new Runnable() {
@Override
public void run() {
SublayerList mainSublayerList = mainMapImageLayer.getSublayers();
ArcGISMapImageSublayer mainMapImageSublayer = (ArcGISMapImageSublayer) mainSublayerList.get(0);
}
});
- 移動地圖資料包含的圖層
移動地圖資料是ArcGIS10.5新推出的一種資料格式,其特點是 将所有地圖和資料資源打包,并且将資料存儲于壓縮的Mobile GDB中,是以可以進行展示、查詢、分析等所有操作。相比TPK資料來資料更小,而對于geodatabase資料而言,其加載圖層效率上有明顯的優勢。因為其擷取圖層的方式比較特殊,是以單獨拿出來說明下。
MMPK因為是将所有地圖和資料資源打包,是以其直接擷取到的是ArcGISMap,我們要擷取要素圖層,需要先擷取到ArcGISMap以後,再從其中擷取FeatureLayer。
String mainMMPKPath = StorageUtil.getSDCardRootPath(getApplicationContext())+"/ydyzt/data/SanFrancisco.mmpk";
final MobileMapPackage mainMobileMapPackage = new MobileMapPackage(mainMMPKPath);
mainMobileMapPackage.loadAsync();
mainMobileMapPackage.addDoneLoadingListener(new Runnable() {
@Override
public void run() {
LoadStatus mainLoadStatus = mainMobileMapPackage.getLoadStatus();
if (mainLoadStatus == LoadStatus.LOADED) {
List<ArcGISMap> mainArcGISMapL = mainMobileMapPackage.getMaps();
ArcGISMap mainArcGISMapMMPK = mainArcGISMapL.get(0);
mMapView.setMap(mainArcGISMapMMPK);}}});
除此以外,圖層還有三維地圖圖層(ArcGISSceneLayer),基于微軟必應地圖的圖層(BingMapsLayer),要素集合圖層(FeatureCollectionLayer)