Click or drag to resize

Camera Class

Used for defining the perspective of a scene. It is a visual snapshot of an observation of the Earth with various layers displayed in a SceneView.
Inheritance Hierarchy
SystemObject
  Esri.ArcGISRuntime.MappingCamera

Namespace:  Esri.ArcGISRuntime.Mapping
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.7.0.0
Syntax
C#
public class Camera

The Camera type exposes the following members.

Constructors
  NameDescription
Public methodCamera(TransformationMatrix)
Initializes a new instance of the Camera class using a transformation matrix.
Public methodCode exampleCamera(MapPoint, Double, Double, Double)
Initializes a new instance of the Camera class.
Public methodCode exampleCamera(MapPoint, Double, Double, Double, Double)
Initializes a new instance of the Camera class.
Public methodCode exampleCamera(Double, Double, Double, Double, Double, Double)
Initializes a new instance of the Camera class.
Top
Properties
  NameDescription
Public propertyCode exampleHeading
Gets the heading property which represents the angle from north in an ENU (East, North, Up Ground reference frames). Value ranges from 0 to 360 degrees. To set the heading use the
Public propertyCode exampleLocation
Gets the point in space where the camera is located. To set the point use the Camera.MoveTo Method or establish the location as part of one of the Camera Constructors.
Public propertyCode examplePitch
Gets the pitch property which represents the angle of pitch applied to the camera with rotation around Y-axis in an ENU (East, North, Up Ground reference frames). Value ranges from 0 to 180 degrees, where 0 is looking straight down (center of the earth) and 180 looking straight up (towards outer space).
Public propertyCode exampleRoll
Gets the roll property which represents the angle of roll applied to the camera with rotation around X-axis in an ENU (East, North, Up Ground reference frames). Value ranges from 0 to 360 degrees, where 0 is horizontal.
Public propertyTransformation
Gets the camera's Transformation Matrix.
Top
Methods
  NameDescription
Public methodCode exampleElevate
Returns a new Camera with applied elevation.
Public methodIsEqual
Compares two cameras for equality.
Public methodMoveForward
Returns a new Camera with updated position.
Public methodMoveTo
Returns a new Camera with the a new center position. Location is the point in space where the camera is located. Setting the location can be done using this Method or establish the location as part of one of the Camera Constructors.
Public methodMoveToward
Returns a new Camera centered at calculated location.
Public methodRotateAround
Returns a new Camera with changes centered at specified location.
Public methodCode exampleRotateTo
Returns a new Camera with applied rotation.
Public methodZoomToward
Returns a new Camera centered at calculated location.
Top
Remarks

A Camera object can literally be thought of as a camera that one would look through to see a viewable extent and perspective of the Earth. Depending on how you hold the camera and how far away from the ground will determine what you can see. These positions of holding the camera represent the various Properties that you can set on the Camera object.

The Camera Class is immutable which means that you can not change its parameters once it is created. There are methods in the Camera class that would give you a new Camera with the adjusted parameters.

Examples

Android

Example Name: SceneLayerUrl

Display an ArcGIS scene layer from a URL.

Code example screen shot.

C#
// Copyright 2017 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.

using Android.App;
using Android.OS;
using Android.Widget;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.UI.Controls;
using System;
using Esri.ArcGISRuntime.Geometry;

namespace ArcGISRuntime.Samples.SceneLayerUrl
{
    [Activity (ConfigurationChanges=Android.Content.PM.ConfigChanges.Orientation | Android.Content.PM.ConfigChanges.ScreenSize)]
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        "ArcGIS scene layer (URL)",
        "Layers",
        "Display an ArcGIS Scene layer from a service.",
        "")]
    public class SceneLayerUrl : Activity
    {
        // Hold a reference to the scene view.
        private SceneView _mySceneView;

        // URL for a service to use as an elevation source.
        private readonly Uri _elevationSourceUrl = new Uri(
            "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer");

        // URL for the scene layer.
        private readonly Uri _serviceUri = new Uri(
            "https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Buildings_Portland/SceneServer");

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            Title = "ArcGIS scene layer (URL)";

            CreateLayout();
            Initialize();
        }

        private async void Initialize()
        {
            // Create new Scene.
            Scene myScene = new Scene {Basemap = Basemap.CreateImagery()};

            // Create and add an elevation source for the Scene.
            ArcGISTiledElevationSource elevationSrc = new ArcGISTiledElevationSource(_elevationSourceUrl);
            myScene.BaseSurface.ElevationSources.Add(elevationSrc);

            // Create new scene layer from the URL.
            ArcGISSceneLayer sceneLayer = new ArcGISSceneLayer(_serviceUri);

            // Add created layer to the operational layers collection.
            myScene.OperationalLayers.Add(sceneLayer);

            try
            {
                // Load the layer.
                await sceneLayer.LoadAsync();

                // Get the center of the scene layer.
                MapPoint center = (MapPoint)GeometryEngine.Project(sceneLayer.FullExtent.GetCenter(), SpatialReferences.Wgs84);

                // Create a camera with coordinates showing layer data.
                Camera camera = new Camera(center.Y, center.X, 225, 220, 80, 0);

                // Assign the Scene to the SceneView.
                _mySceneView.Scene = myScene;

                // Set view point of scene view using camera.
                await _mySceneView.SetViewpointCameraAsync(camera);
            }
            catch (Exception e)
            {
                new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show();
            }
        }

        private void CreateLayout()
        {
            // Create a new vertical layout for the app.
            LinearLayout layout = new LinearLayout(this) { Orientation = Orientation.Vertical };

            // Add the scene view to the layout.
            _mySceneView = new SceneView(this);
            layout.AddView(_mySceneView);

            // Show the layout in the app.
            SetContentView(layout);
        }
    }
}
Examples

Xamarin Forms Android

Example Name: ScenePropertiesExpressions

Update the orientation of a graphic using scene property rotation expressions.

Code example screen shot.

C#
// Copyright 2019 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.

using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Symbology;
using Esri.ArcGISRuntime.UI;
using Xamarin.Forms;

namespace ArcGISRuntimeXamarin.Samples.ScenePropertiesExpressions
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        "Scene properties expressions",
        "GraphicsOverlay",
        "Update the orientation of a graphic using scene property rotation expressions.",
        "",
        "rotation", "expression", "heading", "pitch", "scene", "3D", "symbology")]
    public partial class ScenePropertiesExpressions : ContentPage
    {
        public ScenePropertiesExpressions()
        {
            InitializeComponent();
            Initialize();
        }

        private void Initialize()
        {
            // Set up the scene with an imagery basemap.
            MySceneView.Scene = new Scene(Basemap.CreateImagery());

            // Set the initial viewpoint for the scene.
            MapPoint point = new MapPoint(83.9, 28.4, 1000, SpatialReferences.Wgs84);
            Camera initialCamera = new Camera(point, 1000, 0, 50, 0);
            MySceneView.SetViewpointCamera(initialCamera);

            // Create a graphics overlay.
            GraphicsOverlay overlay = new GraphicsOverlay();
            overlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative;
            MySceneView.GraphicsOverlays.Add(overlay);

            // Add a renderer using rotation expressions.
            SimpleRenderer renderer = new SimpleRenderer();
            renderer.SceneProperties.HeadingExpression = "[HEADING]";
            renderer.SceneProperties.PitchExpression = "[PITCH]";

            // Apply the renderer to the graphics overlay.
            overlay.Renderer = renderer;

            // Create a red cone graphic.
            SimpleMarkerSceneSymbol coneSymbol = SimpleMarkerSceneSymbol.CreateCone(Color.Red, 100, 100);
            coneSymbol.Pitch = -90;
            MapPoint conePoint = new MapPoint(83.9, 28.41, 200, SpatialReferences.Wgs84);
            Graphic cone = new Graphic(conePoint, coneSymbol);

            // Add the cone graphic to the overlay.
            overlay.Graphics.Add(cone);

            // Listen for changes in slider values and update graphic properties.
            HeadingSlider.ValueChanged += (sender, e) => { cone.Attributes["HEADING"] = HeadingSlider.Value; };
            PitchSlider.ValueChanged += (sender, e) => { cone.Attributes["PITCH"] = PitchSlider.Value; };
        }
    }
}
XAML
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    x:Class="ArcGISRuntimeXamarin.Samples.ScenePropertiesExpressions.ScenePropertiesExpressions"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms"
    xmlns:resources="clr-namespace:Forms.Resources;assembly=ArcGISRuntime">
    <RelativeLayout>
        <esriUI:SceneView
            x:Name="MySceneView"
            Style="{StaticResource MapWithFormStyle}"
            ViewInsets="0" />
        <resources:ResponsiveFormContainer x:Name="FormContainer">
            <StackLayout>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="200" />
                    </Grid.ColumnDefinitions>
                    <Label
                        Grid.Column="0"
                        Style="{StaticResource LabelStyle}"
                        Text="Heading:" />
                    <Slider
                        x:Name="HeadingSlider"
                        Grid.Column="1"
                        Maximum="360"
                        MaximumTrackColor="Black"
                        Minimum="0"
                        MinimumTrackColor="Black" />
                </Grid>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="200" />
                    </Grid.ColumnDefinitions>
                    <Label
                        Grid.Column="0"
                        Style="{StaticResource LabelStyle}"
                        Text="Pitch:" />
                    <Slider
                        x:Name="PitchSlider"
                        Grid.Column="1"
                        Maximum="90"
                        MaximumTrackColor="Black"
                        Minimum="-90"
                        MinimumTrackColor="Black" />
                </Grid>
            </StackLayout>
        </resources:ResponsiveFormContainer>
    </RelativeLayout>
</ContentPage>
See Also
Additional Examples
Hyperlink to ExampleDescription
AddAnIntegratedMeshLayerView an integrated mesh layer from a scene service.
ChangeAtmosphereEffectChanges the appearance of the atmosphere in a scene.
CreateTerrainSurfaceFromRasterUse a terrain surface with elevation described by a raster file.
CreateTerrainSurfaceFromTilePackageSet the terrain surface with elevation described by a local tile package.
DisplaySceneDisplay a scene with a terrain surface and some imagery.
DistanceMeasurementMeasure distances between two points in 3D.
EditKmlGroundOverlayEdit the values of a KML ground overlay.
FeatureLayerRenderingModeSceneRender features in a scene statically or dynamically by setting the feature layer rendering mode.
GetElevationAtPointGet the elevation for a given point on a surface in a scene.
LineOfSightLocationPerform a line of sight analysis between two points in real time.
ListKmlContentsList the contents of a KML file. KML files can contain a hierarchy of features, including network links to other KML content.
SceneLayerSelectionIdentify GeoElements in a scene layer.
SceneLayerUrlDisplay an ArcGIS scene layer from a URL.
ScenePropertiesExpressionsUpdate the orientation of a graphic using scene property rotation expressions.
SceneSymbolsShow various kinds of 3D symbols in a scene.
SurfacePlacementsPosition graphics relative to a surface using different surface placement modes.
TerrainExaggerationConfigure the vertical exaggeration of terrain (the ground surface) in a scene.
ViewshedCameraAnalyze the viewshed for a camera. A viewshed shows the visible and obstructed areas from an observer's vantage point.
ViewshedLocationPerform a viewshed analysis from a defined vantage point. Viewshed analyses have several configuration options that are demonstrated in this sample.