安卓智能地图开发与实施三:创建第一个地图程序 - ArcGIS Runtime SDK for Android(Version 100.0.0)

0
分享 2017-08-21
本文纯粹是流程操作,手把手第一次,先看效果图。
 
 
1、创建一个新工程(File > New > New Project) 
2、输入工程名:Set Map Initial Location 
3、修改Company Domain 和 Project Location 
4、修改Package name 
5、点击下一步,勾选“Phone and Tablet” 
6、选择合适的SDK
 
 
7、点击下一步,选择“Empty Activity” 
8、点击下一步,输入Activity Name。 
9、输入Layout Name(可采用默认)。 
10、单击完成,等待工程初始化完成。
 
 
11、于(project)的build.gradle文件中在相应的地方添加:url ‘https://esri.bintray.com/arcgis
buildscript { repositories { jcenter() }
dependencies { classpath 'com.android.tools.build:gradle:2.3.1' }
}

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

task clean(type: Delete) { delete rootProject.buildDir }



12、于app module的build.gradle文件中在相应的地方添加: compile ‘com.esri.arcgisruntime:arcgis-android:100.0.0’
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "esrichina.hymn.setmapinitiallocation"
minSdkVersion 23
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile 'com.esri.arcgisruntime:arcgis-android:100.0.0'
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile
('com.android.support.test.espresso:espresso-core:2.2.2', {
'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0'
testCompile 'junit:junit:4.12'
}



13、在Android Studio toolbar中,单击 “Sync Project with Gradle Files” (要有好网络,否则等待漫长的下载)

14、在“Android project view”中打开“AndroidManifest.xml”(app > manifests) 添加:
<uses-permission android:name="android.permission.INTERNET" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="esrichina.hymn.setmapinitiallocation">
<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>

15、在Layout(res > layout:activity_main.xml)文件中添加MapView。
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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="esrichina.hymn.setmapinitiallocation.MainActivity">
<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>
</android.support.constraint.ConstraintLayout>



16、初始化 MapView。进入“MainActivity”(java > [package name]),于相应处编码。
package esrichina.hymn.setmapinitiallocation;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.esri.arcgisruntime.mapping.ArcGISMap;
import com.esri.arcgisruntime.mapping.Basemap;
import com.esri.arcgisruntime.mapping.view.MapView;
public class MainActivity extends AppCompatActivity {
private MapView mMapView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mMapView = (MapView) findViewById(R.id.mapView);
ArcGISMap map = new ArcGISMap
(Basemap.Type.TOPOGRAPHIC, 34.056295, -117.195800, 16);
mMapView.setMap(map);
}
}



17、运行程序,选择设备,得到结果。


 
 安卓智能地图开发与实施一:配置离线SDK - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3304
 安卓智能地图开发与实施二:开发环境准备 - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3303
 安卓智能地图开发与实施三:创建第一个地图程序 - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3302
 安卓智能地图开发与实施四:二维地图的MapView与Layers - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3305
 安卓智能地图开发与实施五:在线基础底图 - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3309
 安卓智能地图开发与实施六:离线基础底图 - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3299
 安卓智能地图开发与实施七:在线业务图层(浏览查询) - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3298
 安卓智能地图开发与实施八:离线业务图层(浏览查询) - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3297
 安卓智能地图开发与实施九:地图缩放与旋转 - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3296
 安卓智能地图开发与实施十:图层管理 - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3295
 安卓智能地图开发与实施十一:业务数据查询 - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3294
 安卓智能地图开发与实施十二:空间查询与模糊搜索 - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3293
 安卓智能地图开发与实施十三:空间查询与展示 - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3308
 安卓智能地图开发与实施十四:业务数据编辑 - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3307
 安卓智能地图开发与实施十五:离线与同步 - ArcGIS Runtime SDK for Android(Version 100.0.0) :http://zhihu.esrichina.com.cn/article/3306
 安卓智能地图开发与实施十六:三维地图 - ArcGIS Runtime SDK for Android(Version 100.1.0) :http://zhihu.esrichina.com.cn/article/3289
 安卓智能地图开发与实施十七:使用天地图 - ArcGIS Runtime SDK for Android(Version 100.1.0) :http://zhihu.esrichina.com.cn/article/3288
 安卓智能地图开发与实施十八:空间要素绘制 - ArcGIS Runtime SDK for Android(Version 100.1.0) :http://zhihu.esrichina.com.cn/article/3287
 安卓智能地图开发与实施十九:符号与渲染器 - ArcGIS Runtime SDK for Android(Version 100.1.0) :http://zhihu.esrichina.com.cn/article/3286
文章来源:http://blog.csdn.net/allenlu2008/article/details/71112432

2 个评论

您好,感谢您的分享,我下载了链接里提供的好几个demo,最后同步完成后,都会报
library "libPVRDebugger.so" not found的错误,好奇怪啊
是我错了,搞了半天是魅族系统有问题,我换了华为的手机和小米的手机都可以,抱歉抱歉

要回复文章请先登录注册