Android GIS开发系列-- 入门季(1) 起点

前言

这个系列,待最终完成更新,大家体谅点,第一版本全部是参考的网络教程,最近会逐步的细化更新为可以直接使用的情况。

本系列的开发基于AS (  Android Studio ), 和ArcGIS 的Android开发的API。

配置

开发首先要下载Arcgis SDK。

 下载地址在Arcgis官网https://developers.arcgis.com/,不过下载要注册,比较麻烦。

可以从http://download.csdn.net/detail/gary__123456/9787775,下载jar包与so文件。

学习采用的版本是Arcgis SdK 10.2.4。下载jar与so后,进入正题,新启项目Arcgis Demo。

1.添加so与jar


      2.工程的Mainfest文件中添加相应的权限:

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

   3.build.gradle文件下的android节点加上如下配置:解决jackson-mapper-lgpl-1.9.5.jar与jackson-core-lgpl-1.9.5.jar无法编译问题

packagingOptions {
    exclude 'META-INF/LGPL2.1'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
}

在MainActivity的布局中添加MapView控件,并加上id.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.arcgis.test.MainActivity">

    <com.esri.android.map.MapView
        android:id="@+id/map_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</RelativeLayout>

       在MainActivity中获取控件,并添加一个开放的网络图层。利用ArcGISTiledMapServiceLayer图层添加。

private MapView mMapView;
private String mapServerUrl = "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mMapView = (MapView) findViewById(R.id.map_view);
    addLayer();
}

private void addLayer() {
    ArcGISTiledMapServiceLayer arcGISTiledMapServiceLayer = new ArcGISTiledMapServiceLayer(mapServerUrl);
    mMapView.addLayer(arcGISTiledMapServiceLayer);
}

protected void onResume() {
    super.onResume();
    mMapView.unpause();
}
@Override
protected void onPause() {
    super.onPause();
    mMapView.pause();
}
View Code

  运行项目,效果图如下。Arcgis 在Studio中基本配置就到这里。

参考文章

Android Arcgis入门(一) Arcgis开发配置

你们的评论、反馈,及对你们有所用,是我整理材料和博文写作的最大的鼓励和唯一动力。欢迎讨论和关注!
没有整理与归纳的知识,一文不值!高度概括与梳理的知识,才是自己真正的知识与技能。 永远不要让自己的自由、好奇、充满创造力的想法被现实的框架所束缚,让创造力自由成长吧! 多花时间,关心他(她)人,正如别人所关心你的。理想的腾飞与实现,没有别人的支持与帮助,是万万不能的。
原文地址:https://www.cnblogs.com/arxive/p/7751829.html