Add a layer to visualize 3D tiles data that conforms to the OGC 3D Tiles specification.

Use case
In addition to offering a 3D view, a 3D tiles layer can assist in performing visual analysis, such as line of sight analysis. A line of sight analysis can be used to assess whether a view is obstructed between an observer and a target.
How to use the sample
When loaded, the sample will display a scene with an Ogc3DTilesLayer. Pan around and zoom in to observe the scene of the Ogc3DTilesLayer. Notice how the layer’s level of detail changes as you zoom in and out from the layer.
How it works
- Create a
Scene. - Create an
Ogc3DTilesLayerwith the URL to a 3D tiles layer service. - Add the layer to the scene’s operational layers.
Relevant API
- Camera
- Ogc3DTilesLayer
- SceneView
About the data
A layer to visualize 3D tiles data that conforms to the OGC 3D Tiles specification. As of 200.4, it supports analyses like viewshed and line of sight, but does not support other operations like individual feature identification.
The 3D Tiles Open Geospatial Consortium (OGC) specification defines a spatial data structure and a set of tile formats designed for streaming and rendering 3D geospatial content. A 3D Tiles data set, known as a tileset, defines one or more tile formats organized into a hierarchical spatial data structure. For more information, see the OGC 3D Tiles specification.
Additional information
This sample uses the GeoView-Compose Toolkit module to be able to implement a composable SceneView.
Tags
3d tiles, geoview-compose, layers, OGC, OGC API, scene, service
Sample Code
/* Copyright 2024 Esri * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */
package com.esri.arcgismaps.sample.add3dtileslayer
import android.os.Bundleimport androidx.activity.ComponentActivityimport androidx.activity.compose.setContentimport androidx.activity.enableEdgeToEdgeimport androidx.compose.material3.MaterialThemeimport androidx.compose.material3.Surfaceimport androidx.compose.runtime.Composableimport com.arcgismaps.ApiKeyimport com.arcgismaps.ArcGISEnvironmentimport com.esri.arcgismaps.sample.add3dtileslayer.screens.MainScreenimport com.esri.arcgismaps.sample.sampleslib.theme.SampleAppTheme
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // authentication with an API key or named user is // required to access basemaps and other location services ArcGISEnvironment.apiKey = ApiKey.create(BuildConfig.ACCESS_TOKEN)
enableEdgeToEdge() setContent { SampleAppTheme { Add3DTilesLayerApp() } } }
@Composable private fun Add3DTilesLayerApp() { Surface( color = MaterialTheme.colorScheme.background ) { MainScreen( sampleName = getString(R.string.add_3d_tiles_layer_app_name) ) } }}/* Copyright 2024 Esri * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */
package com.esri.arcgismaps.sample.add3dtileslayer.components
import android.app.Applicationimport androidx.lifecycle.AndroidViewModelimport com.arcgismaps.mapping.ArcGISSceneimport com.arcgismaps.mapping.ArcGISTiledElevationSourceimport com.arcgismaps.mapping.BasemapStyleimport com.arcgismaps.mapping.Viewpointimport com.arcgismaps.mapping.layers.Ogc3DTilesLayerimport com.arcgismaps.mapping.view.Cameraimport com.arcgismaps.toolkit.geoviewcompose.SceneViewProxy
class SceneViewModel(application: Application) : AndroidViewModel(application) {
// Create a SceneViewProxy which is passed to the composable SceneView val sceneViewProxy = SceneViewProxy()
// Create a scene with a dark gray basemap that gets passed to the composable SceneView. val scene = ArcGISScene(BasemapStyle.ArcGISDarkGray).apply {
// Add an elevation source to the scene's base surface. baseSurface.elevationSources.add( ArcGISTiledElevationSource( "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer" ) )
// Add a 3D tiles layer to the scene. The URL points to a 3D tiles layer that shows // buildings in Stuttgart, Germany. operationalLayers.add( Ogc3DTilesLayer( "https://tiles.arcgis.com/tiles/ZQgQTuoyBrtmoGdP/arcgis/rest/services/Stuttgart/3DTilesServer/tileset.json" ) )
// Set the initial viewpoint of the scene. The viewpoint is set to a location in Stuttgart. initialViewpoint = Viewpoint( latitude = 48.8466, longitude = 9.1627, scale = 1000.0, camera = Camera( latitude = 48.84553, longitude = 9.16275, altitude = 450.0, heading = 0.0, pitch = 60.0, roll = 0.0 ) ) }}/* Copyright 2024 Esri * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */
package com.esri.arcgismaps.sample.add3dtileslayer.screens
import androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.paddingimport androidx.compose.material3.Scaffoldimport androidx.compose.runtime.Composableimport androidx.compose.ui.Modifierimport androidx.lifecycle.viewmodel.compose.viewModelimport com.arcgismaps.toolkit.geoviewcompose.SceneViewimport com.esri.arcgismaps.sample.add3dtileslayer.components.SceneViewModelimport com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBar
/** * Main screen layout for the sample app */@Composablefun MainScreen(sampleName: String) { // create a ViewModel to handle SceneView interactions val sceneViewModel = viewModel<SceneViewModel>()
Scaffold( topBar = { SampleTopAppBar(title = sampleName) }, content = { SceneView( modifier = Modifier .fillMaxSize() .padding(it), sceneViewProxy = sceneViewModel.sceneViewProxy, arcGISScene = sceneViewModel.scene ) } )}