Exemplo n.º 1
0
  private void initMap() {
    //        TDTImgLayer = new TianDiTuLayer(TianDiTuLayerTypes.TIANDITU_IMAGE_2000);
    //        TDTImgAnnotationLayer = new TianDiTuLayer(
    //                TianDiTuLayerTypes.TIANDITU_IMAGE_ANNOTATION_CHINESE_2000);
    //        mMapView.addLayer(TDTImgLayer);
    //        mMapView.addLayer(TDTImgAnnotationLayer);

    // GPS定位的图形层
    gpsLayer = new GraphicsLayer();
    // gpsLayer.setVisible(false);
    // mMapView.addLayer(gpsLayer);

    //        addLayer(localGdb);
    mapls = new ArrayList<MapTypeLayer>();
    for (String layername : layertypes) {
      for (int i = 0; i < lmtl.size(); i++) {
        if (layername.equals(lmtl.get(i).getName())) {
          mapls.add(lmtl.get(i));
          break;
        }
      }
    }

    locallist = new ArrayList<ArcGISLocalTiledLayer[]>();
    for (int i = 0; i < mapls.size(); i++) {
      MapTypeLayer maptypelayer = mapls.get(i);
      System.out.println(maptypelayer.getName());
      ArrayList<MAPLayer> maplays = maptypelayer.getMaplist();
      ArcGISLocalTiledLayer[] local = new ArcGISLocalTiledLayer[maplays.size()];

      for (int j = 0; j < maplays.size(); j++) {
        local[j] = new ArcGISLocalTiledLayer(maplays.get(j).getuRL());
        mMapView.addLayer(local[j]);
        if (i == 0) {
          local[j].setVisible(true);
        } else {
          local[j].setVisible(false);
        }
      }
      locallist.add(local);
    }

    adapter = new MapLayerShow(context, mapls, mMapView);
    map_layers.setAdapter(adapter);

    mMapView.setOnStatusChangedListener(
        new OnStatusChangedListener() {
          public void onStatusChanged(Object source, STATUS status) {
            // 地图加载成功后定位到详细位置
            if (status == STATUS.LAYER_LOADED) {

              //     Point centerPt = new Point(116.45, 27.60);
              //    mMapView.zoomToScale(centerPt, 3000000);
            }
          }
        });
  }
Exemplo n.º 2
0
  public void getAllMaps(String filePath) {
    lmtl = new ArrayList<MapTypeLayer>();
    File file = null;
    try {
      file = new File(filePath);
      // 判断路径是否存在
      if (file.exists()) {
        File[] fs = file.listFiles();
        for (int i = 0; i < fs.length; i++) {
          // 判断是否是目录
          if (fs[i].isDirectory()) {
            MapTypeLayer maptypelayer = new MapTypeLayer();
            maptypelayer.setName(fs[i].getName());
            ArrayList<MAPLayer> maplist = new ArrayList<MAPLayer>();

            File file1 = new File(fs[i] + "");
            File[] fs1 = file1.listFiles();

            for (int j = 0; j < fs1.length; j++) {
              MAPLayer maplayer = new MAPLayer();
              maplayer.setURL(
                  "file://mnt/sdcard/WHDLGQSYS/map/" + fs[i].getName() + "/" + fs1[j].getName());
              maplayer.setState("0");
              maplist.add(maplayer);
            }
            maptypelayer.setMaplist(maplist);
            lmtl.add(maptypelayer);
          }
          System.out.println(fs[i].getAbsolutePath());
        }
        System.out.println("-------------end----------");
      } else {
        file.mkdir();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }