2023-02-10 ArcGIS三维加载天地图底图

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

        val scene = ArcGISScene()
        // 设置加载天地图---影像
        val webTiledLayer =
            TianDiTuMethodsClass.CreateTianDiTuTiledLayer(TianDiTuMethodsClass.LayerType.TIANDITU_IMAGE_MERCATOR)
      // 矢量:TianDiTuMethodsClass.LayerType.TIANDITU_VECTOR_MERCATOR

        val webTiledLayer1 =
           TianDiTuMethodsClass.CreateTianDiTuTiledLayer(TianDiTuMethodsClass.LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_MERCATOR)
      // 矢量:TianDiTuMethodsClass.LayerType.TIANDITU_VECTOR_ANNOTATION_CHINESE_MERCATOR
        val requestConfiguration = RequestConfiguration().apply {
            headers["referer"] = "http://www.arcgis.com"
        }
        webTiledLayer.requestConfiguration = requestConfiguration
        webTiledLayer1.requestConfiguration = requestConfiguration
        webTiledLayer.loadAsync()
        webTiledLayer1.loadAsync()
        val basemap = Basemap(webTiledLayer)
        basemap.baseLayers.add(webTiledLayer1)
        scene.basemap = basemap
    // 加载自己的地图
    val arcGISMapImageLayer =
            ArcGISMapImageLayer("http://......./MapServer")
        arcGISMapImageLayer.loadAsync()
    scene.operationalLayers.add(arcGISMapImageLayer)
        sceneView.scene = scene

    //  控制地图视角
    //  前两个是经纬度,后几个是角度
      val camera = Camera(36.53481, 115.47989, 2000.0, 345.0, 0.0, 0.0)
        sceneView.setViewpointCamera(camera) 
/**
*     设置底图点击事件
*/
    sceneView.setOnTouchListener(object : DefaultSceneViewOnTouchListener(sceneView){
            override fun onSingleTapConfirmed(e: MotionEvent?): Boolean {
                e ?:return false
                val mapPoint = android.graphics.Point(e.x.toInt(), e.y.toInt())
                val listListenableFuture = sceneView.identifyGraphicsOverlaysAsync(mapPoint,
                    12.0,false,5)
                listListenableFuture.addDoneListener{
                    try {
                        val results = listListenableFuture.get()
                        for (result in results) {
                            for (graphic in result.graphics) {
                                
                                val stationCode = graphic.attributes["name"].toString()

                                ToastUtils.showToast(this@TestActivity,"$stationCode")
                            }
                        }

                    } catch (e: Exception) {

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

推荐阅读更多精彩内容