Arcgis runtime for Android 100.5 (二) 基本用例

(一) 环境配置

上篇介绍了开发环境的配置,现在写个最基本的用法

  1. 布局文件中使用
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.esri.arcgisruntime.mapping.view.MapView
        android:id="@+id/mapView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</RelativeLayout>
  1. 代码中
class TestActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_test)
         /**
         * 地图类型
         * 中心点纬度
         * 中心点经度
         * 地图显示级别
         */
        val arcGISMap = ArcGISMap(Basemap.Type.TOPOGRAPHIC, 39.914271,  116.405419, 10)
        mapView.map = arcGISMap

    }
    override fun onPause() {
        super.onPause()
        mapView.pause()
    }

    override fun onResume() {
        super.onResume()
        mapView.resume()
    }

    override fun onDestroy() {
        super.onDestroy()
        mapView.dispose()
    }
}

运行需要网络权限
运行效果

运行效果

可以看到,底图已经加载出来了,这里加载的是Arcgis内置的一些底图
去除上方水印和下方logo

         //去除水印
        ArcGISRuntimeEnvironment
               .setLicense("runtimelite,1000,rud4449636536,none,NKMFA0PL4S0DRJE15166")
        //去除logo
        mapView.isAttributionTextVisible = false

去除水印效果

Basemap.Type 的类型可以查看官方api提供的地图类型介绍 传送门
Arcgis内置了一些可以直接使用的地图

        val arcGISMap1 = ArcGISMap(Basemap.createImagery())
        val arcGISMap2 = ArcGISMap(Basemap.createStreetsVector())
        val arcGISMap3 = ArcGISMap(Basemap.createTopographic())
        ***
       //初始化可见区域
        val targetExtent = Envelope(
            -13639984.0, 4537387.0, -13606734.0, 4558866.0,
            SpatialReferences.getWebMercator()
        )
        arcGISMap3.initialViewpoint = Viewpoint(targetExtent)
        mapView.map = arcGISMap3

(三) 加载基础地图

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。