Add 3D tiles layer

View on GitHub

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

Image of Add 3D tiles layer sample

Use case

One possible use case is that when added to a scene, 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

  1. Create a scene.
  2. Create an OGC3DTilesLayer with the URL to a 3D tiles layer service.
  3. Add the layer to the scene's operational layers.

Relevant API

  • OGC3DTilesLayer
  • SceneView

About the data

A layer to visualize 3D tiles data that conforms to the OGC 3D Tiles specification. As of ArcGIS Maps SDK for Swift 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.

Tags

3d tiles, layers, OGC, OGC API, scene, service

Sample Code

Add3DTilesLayerView.swift
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// 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
//
//   https://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.

import ArcGIS
import SwiftUI

struct Add3DTilesLayerView: View {
    /// A scene with dark gray basemap and an OGC 3D tiles layer.
    @State private var scene: ArcGIS.Scene = {
        // Creates a scene and sets an initial viewpoint.
        let scene = Scene(basemapStyle: .arcGISDarkGray)
        let camera = Camera(
            latitude: 48.84553,
            longitude: 9.16275,
            altitude: 350,
            heading: 0,
            pitch: 75,
            roll: 0
        )
        scene.initialViewpoint = Viewpoint(boundingGeometry: camera.location, camera: camera)

        // Creates a surface and adds an elevation source.
        let surface = Surface()
        surface.addElevationSource(ArcGISTiledElevationSource(url: .worldElevationService))

        // Sets the surface to the scene's base surface.
        scene.baseSurface = surface

        // Creates an OGC 3D tiles layer from a 3D tiles service URL.
        let ogc3DTileslayer = OGC3DTilesLayer(url: .stuttgart3DTiles)

        // Adds the layer to the scene's operational layers.
        scene.addOperationalLayer(ogc3DTileslayer)
        return scene
    }()

    var body: some View {
        SceneView(scene: scene)
    }
}

private extension URL {
    /// The URL of a Stuttgart, Germany city 3D tiles service.
    static var stuttgart3DTiles: URL {
        URL(string: "https://tiles.arcgis.com/tiles/ZQgQTuoyBrtmoGdP/arcgis/rest/services/Stuttgart/3DTilesServer/tileset.json")!
    }

    /// The URL of the Terrain 3D ArcGIS REST Service.
    static var worldElevationService: URL {
        URL(string: "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")!
    }
}

#Preview {
    Add3DTilesLayerView()
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.