1. 程式人生 > >android arcgis(100.0.0) 載入網路圖層

android arcgis(100.0.0) 載入網路圖層

arcgis版本:arcgis-android:100.0.0

載入線上地圖:
1.是使用ArcGISMapImageLayer載入,以圖片形式載入整個地圖,適合大資料量載入

ArcGISMapImageLayer layer = new ArcGISMapImageLayer(Url);//url為線上圖層的網址
// layer.setName("名字");可以設定圖層的名字
layer.addLoadStatusChangedListener(new LoadStatusChangedListener() {
                                    @Override
                                    public void loadStatusChanged(LoadStatusChangedEvent loadStatusChangedEvent) {
                                        if (loadStatusChangedEvent.getNewLoadStatus()==LoadStatus.LOADED){
                                        }
                                    }
                                });//監聽圖層載入的狀態,當loaded時,圖層載入好了
 MapView mainMapView = (MapView) findViewById(R.id.mapView);
LayerList mainLayerList = mainMapView.getMap().getOperationalLayers();
mainLayerList .add(layer);

2.使用FeatureLayer載入圖層,適合數量小的圖層

ServiceFeatureTable mainServiceFeatureTable = new ServiceFeatureTable(url);//url為線上圖層網址
mainServiceFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE);
 mainServiceFeatureTable.addLoadStatusChangedListener(new LoadStatusChangedListener() {
                                    @Override
                                    public void loadStatusChanged(LoadStatusChangedEvent loadStatusChangedEvent) {
                                        String a = loadStatusChangedEvent.getNewLoadStatus().toString();
                                        if (loadStatusChangedEvent.getNewLoadStatus() == LoadStatus.LOADED) {
                                           
                                        }
                                    }
                                });
FeatureLayer mainFeatureLayer = new FeatureLayer(mainServiceFeatureTable);
MapView mainMapView = (MapView) findViewById(R.id.mapView);
LayerList mainLayerList = mainMapView.getMap().getOperationalLayers();
 mainLayerList.add(mainFeatureLayer);