ArcGIS for Android 实现地图基本操作

时间:2021-06-13 23:50:10   收藏:0   阅读:28

地图基本操作

1.前期项目准备

1.1. 创建新工程

技术分享图片

技术分享图片

1.2. 添加ArcGIS SDK

1.3. 添加MapView地图控件

1.4 数据准备

IDEA中点击菜单中的viewtool windowsdevice file explorer,打开如下视图,找到mnt下的sdcard,这个就是我们的手机常用的存储位置。

技术分享图片

sdcard中新建文件夹,并upload地图文件,此处上传shape fileTPKMMPK文件

技术分享图片

2.添加界面操作

2.1 定义文本

strings.xml中完成文本的定义(规范化做法,其实也不是必须这样,这样可便于日后维护,比如更换界面语言)

<resources>
    <string name="app_name">EX03</string>
    <string name="btnZoomIn">放大</string>
    <string name="btnZoomOut">缩小</string>
    <string name="btnRotation">旋转</string>
    <string name="btnScale">缩放</string>
    <string name="btnLayers">图层</string>
</resources>

技术分享图片

2.2 设计界面

打开activity_main.xml,可切换设计界面和代码界面进行设计。此处先在mapView中添加一个LinearLayout horizontal,再在LinearLayout horizontal中添加button,并修改属性。

xml文件如下:

    <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        <Button
                android:text="@string/btnZoomIn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:layout_weight="1" tools:ignore="ButtonStyle"
                android:id="@+id/buttonZoomIn"/>
        <Button
                android:text="@string/btnZoomOut"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:id="@+id/buttonZoomOut" android:layout_weight="1"
                tools:ignore="ButtonStyle"/>
        <Button
                android:text="@string/btnRotation"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:id="@+id/buttonRotation" android:layout_weight="1"
                tools:ignore="ButtonStyle"/>
        <Button
                android:text="@string/btnScale"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:id="@+id/buttonScale" android:layout_weight="1"
                tools:ignore="ButtonStyle"/>
        <Button
                android:text="@string/btnLayers"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:id="@+id/buttonLayers" android:layout_weight="1"
                tools:ignore="ButtonStyle"/>
    </LinearLayout>

技术分享图片

3. 添加方法支持

3.1 加载在线地图

技术分享图片

3.2 完善放大方法

技术分享图片

3.3 完善缩小方法

技术分享图片

3.4 完善旋转方法

技术分享图片

3.5 完善图层管理方法

点击运行后,Android模拟器中将打开生成的App

技术分享图片

技术分享图片

3.6 完善比例尺方法

技术分享图片

原文:https://www.cnblogs.com/jiujiubashiyi/p/14881122.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!