美文网首页
2023-02-10 ArcGIS三维加载天地图底图

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

作者: 谦谦行者 | 来源:发表于2023-02-09 16:53 被阅读0次
    // 去除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)
                }
            })
    

    相关文章

      网友评论

          本文标题:2023-02-10 ArcGIS三维加载天地图底图

          本文链接:https://www.haomeiwen.com/subject/swhhkdtx.html