Add a polygon to a map

Select platform: Android iOS

You can add a polygon to a 3D map.

A map view showing a polygon

The following code sample demonstrates how use the Polygon struct to add a 3D polygon and position it in 3D space.

Swift

          Map(mode: .hybrid) {
            Polygon(
              outerCoordinates: [
                .init(latitude: 37.7749, longitude: -122.4194, altitude: 0),
                .init(latitude: 37.7740, longitude: -122.4184, altitude: 0),
                .init(latitude: 37.7750, longitude: -122.4174, altitude: 0),
              ]
            )
          }