arcgis for android 离线切片加载与geodatabase查询

加载geodatabase数据

private FeatureLayer valueFL;
    //离线数据图
    @Override
    public void getLocalMapServerDiFangData(){

        try {
            List list=null;
            if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())){

                File file=Environment.getExternalStorageDirectory().getAbsoluteFile();
                File file1=new File(file,Constant.LOCAL_DATA);
                if (file1.exists()){
                    list=Arrays.asList(file1.listFiles(new FilenameFilter() {
                        @Override
                        public boolean accept(File dir, String name) {
                            return name.endsWith("geodatabase");
                        }
                    }));

                }
            }


            if (list==null||list.size()==0){
                messageDialog("请在手机SD卡根目录下localdata文件架下放入geodatabase文件!");
            }else {

                String mainGeodatabaseFilePath =list.get(0).getPath();
                final Geodatabase mainGeodatabase = new Geodatabase(mainGeodatabaseFilePath);
                mainGeodatabase.loadAsync();
                mainGeodatabase.addDoneLoadingListener(new Runnable() {
                    @Override
                    public void run() {
                        List resultsGFT = mainGeodatabase.getGeodatabaseFeatureTables();
                        
                        valueFL = new FeatureLayer(resultsGFT.get(2));
                        QueryParameters query = new QueryParameters();
                        query.setWhereClause("1=1");// 设置空间几何对象
                        FeatureTable mTable = valueFL.getFeatureTable();//得到查询属性表
                        final ListenableFuture featureQueryResult
                                = mTable.queryFeaturesAsync(query);
                        featureQueryResult.addDoneListener(new Runnable() {
                            @Override
                            public void run() {
                                try {
                                    FeatureQueryResult featureResul = featureQueryResult.get();
                                    mGeometryMap = new HashMap();
                                    for (Object element : featureResul) {
                                        if (element instanceof Feature) {
                                            Feature mFeatureGrafic = (Feature) element;
                                            Map mQuerryString = mFeatureGrafic.getAttributes();
                                            mList.add(mQuerryString);
                                            mGeometryMap.put(mQuerryString.get("TBYBH") + "", mFeatureGrafic.getGeometry());
                                            mLayerMap.put(mQuerryString.get("TBYBH") + "_"+mQuerryString.get("YH")+"_"+mQuerryString.get("DCLY"),mFeatureGrafic);
                                           
                                        }
                                    }
                                    getSortData(mList);
                                    Message message = new Message();
                                    message.what = 666;
                                    mHandler.sendMessage(message);
                                }catch (Exception e){
                                    e.printStackTrace();
                                }
                            }
                        });
                        valueFL.setVisible(true);
                        LayerList mainLayerList = mArcGISMap.getOperationalLayers();
                        mainLayerList.add(valueFL);
                    }
                });


            }




        } catch (Exception e) {

        }

    }             

离线切片tpk:

 /**
     * 函数:创建离线底图
     * 参数:
     * @param path tpk数据路径
     * @param mBaseMap arcgis 基础图层
     * @param mArcgisMap arcgis 图层
     * 返回值:
     */

    //离线底图
    @Override
    public void createLocalMapView(){
        if (mMapView == null) return;
        List list=null;
        if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())){

            File file=Environment.getExternalStorageDirectory().getAbsoluteFile();
            File file1=new File(file,Constant.LOCAL_TPK);
            if (file1.exists()){
                list=Arrays.asList(file1.listFiles(new FilenameFilter() {
                    @Override
                    public boolean accept(File dir, String name) {
                        return name.endsWith("tpk");
                    }
                }));

            }
        }
        if (list==null||list.size()==0){
            messageDialog("请在手机SD卡根目录下localtpk文件架下放入tpk文件!");

        }else {
            TileCache vTileCache = new TileCache(list.get(0).getPath());
            ArcGISTiledLayer mainArcGISTiledLayer = new ArcGISTiledLayer(vTileCache);
            mBasemap = new Basemap(mainArcGISTiledLayer);
            mArcGISMap = new ArcGISMap(mBasemap);
            mMapView.setMap(mArcGISMap);
        }

    }

 

 

 

 

 

你可能感兴趣的:(android,arcgis,for,android)