1、导入框架(可以在官网上找最新框架)
implementation 'com.esri.arcgisruntime:arcgis-android:100.7.0'
2、设置布局
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Map3DActivity">
<com.esri.arcgisruntime.mapping.view.SceneView
android:id="@+id/sceneview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
3、在Activity设置一下
private void iniMap() {
SceneView sceneview = findViewById(R.id.sceneview);
sceneview.setAttributionTextVisible(false);//隐藏esri的log
ArcGISScene arcGISScene = new ArcGISScene();
ArcGISTiledLayer arcGISTiledLayer = new ArcGISTiledLayer("https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer");
arcGISScene.setBasemap(new Basemap(arcGISTiledLayer));
sceneview.setScene(arcGISScene);
String elevation_image_service = "http://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer";
//将在线服务作为高程表面
ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource(elevation_image_service);
arcGISScene.getBaseSurface().getElevationSources().add(elevationSource);
String brest_buildings = "http://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Buildings_Brest/SceneServer";
//向场景中添加一个用于查看建筑物的场景服务
ArcGISSceneLayer sceneLayer = new ArcGISSceneLayer(brest_buildings);
arcGISScene.getOperationalLayers().add(sceneLayer);
Camera camera = new Camera(48.388, -4.454, 200, 345, 65, 0);
sceneview.setViewpointCamera(camera);
}
到此就可以查看3D效果了。