ArcGIS for Android 10.2.9(1):开发环境配置

ArcGIS官网

官方文档

API

开发环境集成(2中方式)

一.Gradle (推荐)

  1. 使用以下代码示例将Maven存储库的URL和ArcGIS Runtime SDK for Android依赖项添加到项目中。Esri的存储库不是开源的,所以你必须指定一个URL

    在项目的build.grade:

allprojects {
    repositories {
        google()
        jcenter()

        // Add the following ArcGIS repository
        maven {
            url 'https://esri.bintray.com/arcgis'
        }
    }
}

2.添加依赖

 // Add ArcGIS Runtime SDK for Android dependency
    implementation 'com.esri.arcgis.android:arcgis-android:10.2.9'

3.应用程序模块build.gradle文件,在android块内

packagingOptions { 
    exclude 'META-INF/LGPL2.1' 
    exclude 'META-INF/LICENSE' 
    exclude 'META-INF/NOTICE' 
}

4.添加权限

  <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

二.集成方式二:下载sdk

三.入门案例

布局文件:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
    tools:context="com.example.administrator.arcgis1029.Main2Activity">

    <com.esri.android.map.MapView
        android:id="@+id/mapview"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </com.esri.android.map.MapView>

</android.support.constraint.ConstraintLayout>

在MainActivity中获取控件,并添加一个开放的网络图层。利用ArcGISTiledMapServiceLayer图层添加。

public class Main2Activity extends AppCompatActivity {

    private MapView mMapView;

    private String mapServerUrl = "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";
    //private String mapServerUrl = "http://192.168.1.228:6080/arcgis/rest/services/jcsj/dzdt/MapServer";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);

        mMapView = (MapView) findViewById(R.id.mapview);

        ArcGISTiledMapServiceLayer arcGISTiledMapServiceLayer = new ArcGISTiledMapServiceLayer(mapServerUrl);
        mMapView.addLayer(arcGISTiledMapServiceLayer);
    }

    protected void onResume() {
        super.onResume();
        mMapView.unpause();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mMapView.pause();
    }
}

运行项目,效果图如下:
这里写图片描述

也可以在布局文件中直接指定位置:

<com.esri.android.map.MapView
  android:id="@+id/map"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  mapoptions.MapType="Streets"
  mapoptions.center="34.056215, -117.195668"
  mapoptions.ZoomLevel="16">
</com.esri.android.map.MapView>

这里写图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值