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開發配置

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM