第一個基於ArcGIS的Android應用

來源:互聯網
上載者:User

標籤:開啟   div   run   成功   red   version   oid   android應用   ide   

 使用Android Studio建立第一個工程

開啟Android Studio,建立工程。在Application name處填寫項目名稱,company domain是公司地址,將來作為包名,點擊Next下一步。

 

選擇Phone and Tablet,API選擇16以後版本(Arcgis官網教程這樣,可能系統要求),點擊Next下一步。

選擇Empty Activity下一步。

 

 現在已經成功建立了工程,接下來就是加入ArcGIS Runtime SDK依賴。

添加ArcGIS Runtime SDK依賴

使用gradle指令碼添加路徑,會自動下載壓縮包。開啟(Project)下的build.gradle檔案,添加代碼:

allprojects {    repositories {        jcenter()        maven {            url ‘https://esri.bintray.com/arcgis‘        }    }}

  

 添加依賴包,代開(Module)下的build.gradle檔案,添加代碼:

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

添加許可權。

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="com.example.jimmy.displaymap">    <uses-permission android:name="android.permission.INTERNET" />    <uses-feature android:glEsVersion="0x00020000" android:required="true" />    <application        android:allowBackup="true"        android:icon="@mipmap/ic_launcher"        android:label="@string/app_name"        android:roundIcon="@mipmap/ic_launcher_round"        android:supportsRtl="true"        android:theme="@style/AppTheme">        <activity android:name=".MainActivity">            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>    </application></manifest>

 為應用添加布局

 在AndroidManifest.xml檔案上,添加代碼:

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

 

 初始化地圖

在MainActivity上添加代碼:

 

package com.example.jimmy.displaymap;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import com.esri.arcgisruntime.mapping.ArcGISMap;import com.esri.arcgisruntime.mapping.view.MapView;import com.esri.arcgisruntime.mapping.Basemap;public class MainActivity extends AppCompatActivity {    private  MapView mapView;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        mapView = (MapView)findViewById(R.id.mapView);        ArcGISMap map = new ArcGISMap(Basemap.Type.TOPOGRAPHIC,26.893231, 112.571997,18);        mapView.setMap(map);    }    @Override    protected void onPause(){        mapView.pause();        super.onPause();    }    @Override    protected void onResume(){        super.onResume();        mapView.resume();    }}

 

 

 

運行程式

Make Project,等待下載完成包。沒有錯誤之後運行app,顯示效果如下:

 

 

地圖上有浮水印,底部還有連結。

第一個基於ArcGIS的Android應用

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.