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

     在地图开发中,我们熟悉的有高德、百度与腾讯地图,另外还有Google地图等,都提供了比较全面的SDK。而对于Arcgis开发地图还是比较陌生。本着好奇的态度学习对Arcgis的开发。

     Android Arcgis开发首先要下载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();
}
      运行项目,效果图如下。Arcgis 在Studio中基本配置就到这里。

  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值