Esri大赛:添加Arcgis Android sdk 100.1.0

来源:互联网 发布:c51单片机流水灯程序 编辑:程序博客网 时间:2024/06/05 12:48

在大约今年四月份老师让我们学习如何用android开发GIS,参加esri大赛,当然第一步就是添加esri的android的sdk:
https://developers.arcgis.com/android/latest/guide/welcome-to-the-help-for-arcgis-runtime-sdk-for-android.htm(这是Esri官网的教程以及Demo);

第一步新建一个android工程

加载android sdk依赖库

在Android项目视图窗口中,在Gradle脚本下,双击build.gradle(Project:)。这将打开整个项目的gradle构建脚本。在脚本的仓库部分,添加一个新的部分maven,值为url’https://esri.bintray.com/arcgis‘。现在的整个部分应该像下面的代码:

allprojects {    repositories {        jcenter()        // Add the Esri public Bintray Maven repository        maven {            url 'https://esri.bintray.com/arcgis'        }    }}

该指令告诉Gradle通过指定Maven存储库URL来查找适用于Android依赖关系的ArcGIS Runtime SDK。
在Android项目视图窗口中,在Gradle脚本下,双击build.gradle(Module:)。
在脚本的 依赖项部分,添加一个新值“ compile”com.esri.arcgisruntime:arcgis-android:100.1.0“ ”。依赖关系部分应该看起来像下面的代码 - 依赖关系的确切列表将取决于Android Studio的版本和所选的项目设置:

dependencies {   compile 'com.esri.arcgisruntime:arcgis-android:100.1.0'   compile fileTree(dir: 'libs', include: ['*.jar'])  [more dependencies...]}

然后进行同步这样就可以了;

第二布添加布局

将以下类变量声明添加到MainActivity类的顶部:

private MapView mMapView;

在现有的setContentView调用之后,将以下代码添加到onCreate方法中:

mMapView = (MapView) findViewById(R.id.mapView);ArcGISMap map = new ArcGISMap(Basemap.Type.TOPOGRAPHIC, 34.056295, -117.195800, 16); mMapView.setMap(map);

添加以下代码以覆盖活动的onPause和onResume方法,并在调用这些方法时暂停并恢复MapView:

@Override protected void onPause(){  mMapView.pause();  super.onPause();}@Override protected void onResume(){  super.onResume();  mMapView.resume();}

运行就可以了;
所有内容参考自esri官网

阅读全文
1 0
原创粉丝点击