學習筆記之——基於ArcGIS的Android地圖構建

本博文是關於採用ArcGIS來構建Android地圖

 

 

 

在android studio上配置ArcGIS

(參考資料:https://developers.arcgis.com/android/latest/guide/develop-your-first-map-app.htm

首先創建一個新的工程。

更新項目的Gradle存儲庫

allprojects {
    repositories {
        google()
        jcenter()

        //***ADD***
        maven {
            url 'https://esri.bintray.com/arcgis'
        }
        
    }
}

再配置APP下的build.gradle (Module: app)

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation project(path: ':opencv430')

    // *** ADD ***
    implementation 'com.esri.arcgisruntime:arcgis-android:100.8.0'
}

並且再android 模塊中添加Java 8 compile options 

android {
  ...
  // *** ADD ***
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }

然後點擊

成功了

 

更新android清單文件以允許網絡訪問,同時也表明應用程序使用opengl2.0或更高版本。

<uses-permission android:name="android.permission.INTERNET" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />

 

將地圖視圖添加到佈局中

先修改layout文件如下:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Main3Activity">

    <com.esri.arcgisruntime.mapping.view.MapView
        android:id="@+id/mapView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    </com.esri.arcgisruntime.mapping.view.MapView>

</androidx.constraintlayout.widget.ConstraintLayout>

默認情況下,所添加的Mapview不會顯示任何東西,故此下一步就算定義一個地圖來顯示。

在mapview中設置地圖

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

參考資料

https://developers.arcgis.com/labs/browse/?product=android&topic=any

https://blog.csdn.net/Gary__123456/article/details/64503424

https://www.cnblogs.com/gis-luq/p/4923508.html

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章