在arcgis地图上简单添加一个图层

Add a feature layer,这次来个简单的arcgis学习例子。在arcgis地图上简单添加一个图层展示。

一、创建一个基图

 // create a map with the BasemapStyle topographic
    val map = ArcGISMap(BasemapStyle.ARCGIS_TOPOGRAPHIC)
     // set the map to be displayed in the layout's MapView
    mapView.map = map
    这里也可以是下面方式来创建基图
val url = "http://map.geoq.cn/arcgis/rest/services/ChinaOnlineCommunity/MapServer"
   //val url = "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
    val arcGISTiledLayer = ArcGISTiledLayer(url)
    val map = ArcGISMap(Basemap(arcGISTiledLayer))

二、设置一个展示目标位置

// set the viewpoint, Viewpoint(latitude, longitude, scale)
        mapView.setViewpoint(Viewpoint(34.0270, -118.8050, 200000.0))

三、创建一个新的图层

// create the service feature table
        val serviceFeatureTable =
            ServiceFeatureTable("https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0")

四、把这个图层加入到地图的操作图层组中

// create the feature layer using the service feature table
    val featureLayer = FeatureLayer(serviceFeatureTable)
    map.operationalLayers.add(featureLayer)

五、完整代码如下

// set up your map here. You will call this method from onCreate()
private fun setupMap() {
    // create a map with the BasemapStyle topographic
    val map = ArcGISMap(BasemapStyle.ARCGIS_TOPOGRAPHIC)

    // create the service feature table
    val serviceFeatureTable =
        ServiceFeatureTable("https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0")

    // create the feature layer using the service feature table
    val featureLayer = FeatureLayer(serviceFeatureTable)
    map.operationalLayers.add(featureLayer)

    // set the map to be displayed in the layout's MapView
    mapView.map = map

    // set the viewpoint, Viewpoint(latitude, longitude, scale)
    mapView.setViewpoint(Viewpoint(34.0270, -118.8050, 200000.0))

}

arcgis英文官方参考文档
https://developers.arcgis.com/android/layers/tutorials/add-a-feature-layer/
有一起学习ARCGIS的朋友,可以一起多交流。
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值