一. ArcGis for Android 加载本地shp文件

首先在使用Arcgis for Android之前必须对此添加依赖

  1. 在project的build.gradle中添加以下代码
allprojects {    repositories {        jcenter()        maven {            url 'http://dl.bintray.com/esri/arcgis'        }    }}
  1. Module中如下
android {     packagingOptions {        exclude 'META-INF/LGPL2.1'        exclude 'META-INF/LICENSE'        exclude 'META-INF/NOTICE'        }   }dependencies {   compile 'com.esri.arcgis.android:arcgis-android:10.2.7'   }

下面就是核心代码

String shpPath = getPath()+"/dilikuangja/路线.shp";try {    //传入文件路径    ShapefileFeatureTable shapefileFeatureTable = new ShapefileFeatureTable(shpPath);    FeatureLayer featureLayer = new FeatureLayer(shapefileFeatureTable);    featureLayer1.setRenderer(new SimpleRenderer(new SimpleFillSymbol(Color.BLUE)));    mMapView.addLayer(featureLayer);    } catch (Exception e) {       e.printStackTrace();    }   //getPath()方法 public String getSDPath() {        String sdDir = null;        boolean sdCardExist = Environment.getExternalStorageState()                .equals(android.os.Environment.MEDIA_MOUNTED);   //判断sd卡是否存在        if (sdCardExist) {            sdDir = Environment.getExternalStorageDirectory().getAbsolutePath();//获取跟目录        }        return sdDir.toString();    }

添上测试的shp文件
http://download.csdn.net/download/mosquitoes_fly/10149579

更多相关文章

  1. Android横竖屏加载不同布局的适配方案
  2. Android(安卓)拍照 录音 拍视频 旋转 裁剪 压缩图片
  3. Android(安卓)3.1 r1 中文API文档 (121) —— ResourceCursorTre
  4. Android原生项目引入最新的React Native包
  5. android增加5G热点
  6. Android地图添加标记和文字【代码片段】
  7. 【Android(安卓)UI】状态栏和toolbar颜色一致
  8. Android面试总结(持续更新)
  9. NPM 和webpack 的基础使用

随机推荐

  1. 使用bugly做应用升级时android 7.0上遇到
  2. appium主线分析
  3. android studio 报错Failed to save sett
  4. cocos2dx生成android时出错解决方法
  5. Eclipse3.7中搭建Android开发环境
  6. Android(安卓)有些机型不带tcpdump的解决
  7. Received status code 400 from server:
  8. android中使用OpenGL ES
  9. Android(安卓)Fragment生命周期
  10. android 游戏 实战打飞机游戏 怪物(敌机)