Click or drag to resize

Viewpoint Class

Used for specifying the view location of the MapView
Inheritance Hierarchy
SystemObject
  Esri.ArcGISRuntime.MappingViewpoint

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

The Viewpoint type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleViewpoint(Geometry)
Initializes a new instance of the Viewpoint class.
Public methodCode exampleViewpoint(Geometry, Camera)
Initializes a new instance of the Viewpoint class.
Public methodViewpoint(Geometry, Double)
Initializes a new instance of the Viewpoint class.
Public methodCode exampleViewpoint(MapPoint, Double)
Initializes a new instance of the Viewpoint class.
Public methodCode exampleViewpoint(Double, Double, Double)
Initializes a new instance of the Viewpoint class.
Public methodViewpoint(Geometry, Double, Camera)
Initializes a new instance of the Viewpoint class.
Public methodCode exampleViewpoint(MapPoint, Double, Camera)
Initializes a new instance of the Viewpoint class.
Public methodCode exampleViewpoint(MapPoint, Double, Double)
Initializes a new instance of the Viewpoint class.
Public methodViewpoint(Double, Double, Double, Camera)
Initializes a new instance of the Viewpoint class.
Public methodViewpoint(MapPoint, Double, Double, Camera)
Initializes a new instance of the Viewpoint class.
Top
Properties
  NameDescription
Public propertyCode exampleCamera
Gets the camera this view is requesting, or null if it hasn't one.
Public propertyRotation
Gets the scale this view is requesting, or null if this is an extent-based viewpoint.
Public propertyCode exampleTargetGeometry
Gets the target geometry this view is requesting.
Public propertyTargetScale
Gets the scale this view is requesting, or null if this is an extent-based viewpoint.
Top
Methods
  NameDescription
Public methodStatic memberFromJson
Creates a Viewpoint instance from JSON
Public methodToJson
Converts this instance to JSON
Top
Examples

Android

Example Name: RenderPictureMarkers

Use pictures for markers.

Code example screen shot.

C#
// Copyright 2016 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.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Symbology;
using Esri.ArcGISRuntime.UI;
using Esri.ArcGISRuntime.UI.Controls;
using System;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;

namespace ArcGISRuntime.Samples.RenderPictureMarkers
{
    [Activity (ConfigurationChanges=Android.Content.PM.ConfigChanges.Orientation | Android.Content.PM.ConfigChanges.ScreenSize)]
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        "Render picture markers",
        "Symbology",
        "This sample demonstrates how to create picture marker symbols from a URL and embedded resources.",
        "")]
    [ArcGISRuntime.Samples.Shared.Attributes.EmbeddedResource(@"PictureMarkerSymbols\pin_star_blue.png")]
    public class RenderPictureMarkers : Activity
    {
        // Hold a reference to the map view
        private MapView _myMapView;

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

            Title = "Render picture markers";

            // Create the UI, setup the control references and execute initialization
            CreateLayout();
            Initialize();
        }

        private async void Initialize()
        {
            // Create new Map with basemap
            Map myMap = new Map(Basemap.CreateTopographic());

            // Create and set initial map area
            Envelope initialLocation = new Envelope(
                -229835, 6550763, -222560, 6552021,
                SpatialReferences.WebMercator);
            myMap.InitialViewpoint = new Viewpoint(initialLocation);

            // Assign the map to the MapView
            _myMapView.Map = myMap;

            // Create overlay to where graphics are shown
            GraphicsOverlay overlay = new GraphicsOverlay();

            // Add created overlay to the MapView
            _myMapView.GraphicsOverlays.Add(overlay);

            // Add graphics using different source types
            CreatePictureMarkerSymbolFromUrl(overlay);
            try
            {
                await CreatePictureMarkerSymbolFromResources(overlay);
            }
            catch (Exception e)
            {
                new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show();
            }
        }

        private static void CreatePictureMarkerSymbolFromUrl(GraphicsOverlay overlay)
        {
            // Create uri to the used image
            Uri symbolUri = new Uri(
                "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Recreation/FeatureServer/0/images/e82f744ebb069bb35b234b3fea46deae");

            // Create new symbol using asynchronous factory method from uri.
            PictureMarkerSymbol campsiteSymbol = new PictureMarkerSymbol(symbolUri)
            {
                Width = 40,
                Height = 40
            };

            // Create location for the campsite
            MapPoint campsitePoint = new MapPoint(-223560, 6552021, SpatialReferences.WebMercator);

            // Create graphic with the location and symbol
            Graphic campsiteGraphic = new Graphic(campsitePoint, campsiteSymbol);

            // Add graphic to the graphics overlay
            overlay.Graphics.Add(campsiteGraphic);
        }

        private async Task CreatePictureMarkerSymbolFromResources(GraphicsOverlay overlay)
        {
            // Get current assembly that contains the image
            Assembly currentAssembly = Assembly.GetExecutingAssembly();

            // Get image as a stream from the resources
            // Picture is defined as EmbeddedResource and DoNotCopy
            Stream resourceStream = currentAssembly.GetManifestResourceStream(
                "ArcGISRuntime.Resources.PictureMarkerSymbols.pin_star_blue.png");

            // Create new symbol using asynchronous factory method from stream
            PictureMarkerSymbol pinSymbol = await PictureMarkerSymbol.CreateAsync(resourceStream);
            pinSymbol.Width = 50;
            pinSymbol.Height = 50;

            // Create location for the pint
            MapPoint pinPoint = new MapPoint(-226773, 6550477, SpatialReferences.WebMercator);

            // Create graphic with the location and symbol
            Graphic pinGraphic = new Graphic(pinPoint, pinSymbol);

            // Add graphic to the graphics overlay
            overlay.Graphics.Add(pinGraphic);
        }

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

            // Add the map view to the layout
            _myMapView = new MapView(this);
            layout.AddView(_myMapView);

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

Xamarin Forms Android

Example Name: RenderPictureMarkers

Use pictures for markers.

Code example screen shot.

C#
// Copyright 2016 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 System;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace ArcGISRuntime.Samples.RenderPictureMarkers
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        "Render picture markers",
        "Symbology",
        "This sample demonstrates how to create picture marker symbols from a URL and embedded resources.",
        "")]
    [ArcGISRuntime.Samples.Shared.Attributes.EmbeddedResource(@"PictureMarkerSymbols\pin_star_blue.png")]
    public partial class RenderPictureMarkers : ContentPage
    {
        public RenderPictureMarkers()
        {
            InitializeComponent();

            // Create the UI, setup the control references and execute initialization
            Initialize();
        }

        private async void Initialize()
        {
            // Create new Map with basemap
            Map myMap = new Map(Basemap.CreateTopographic());

            // Create and set initial map area
            Envelope initialLocation = new Envelope(
                -229835, 6550763, -222560, 6552021,
                SpatialReferences.WebMercator);
            myMap.InitialViewpoint = new Viewpoint(initialLocation);

            // Assign the map to the MapView
            MyMapView.Map = myMap;

            // Create overlay to where graphics are shown
            GraphicsOverlay overlay = new GraphicsOverlay();

            // Add created overlay to the MapView
            MyMapView.GraphicsOverlays.Add(overlay);

            // Add graphics using different source types
            CreatePictureMarkerSymbolFromUrl(overlay);
            try
            {
                await CreatePictureMarkerSymbolFromResources(overlay);
            }
            catch (Exception e)
            {
                await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK");
            }
        }

        private void CreatePictureMarkerSymbolFromUrl(GraphicsOverlay overlay)
        {
            // Create uri to the used image
            Uri symbolUri = new Uri(
                "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Recreation/FeatureServer/0/images/e82f744ebb069bb35b234b3fea46deae");

            // Create new symbol using asynchronous factory method from uri.
            PictureMarkerSymbol campsiteSymbol = new PictureMarkerSymbol(symbolUri)
            {
                Width = 40,
                Height = 40
            };

            // Create location for the campsite
            MapPoint campsitePoint = new MapPoint(-223560, 6552021, SpatialReferences.WebMercator);

            // Create graphic with the location and symbol
            Graphic campsiteGraphic = new Graphic(campsitePoint, campsiteSymbol);

            // Add graphic to the graphics overlay
            overlay.Graphics.Add(campsiteGraphic);
        }

        private async Task CreatePictureMarkerSymbolFromResources(GraphicsOverlay overlay)
        {
            Assembly currentAssembly = null;
#if WINDOWS_UWP
            // Get current assembly that contains the image
            currentAssembly = GetType().GetTypeInfo().Assembly;
#else
            // Get current assembly that contains the image
            currentAssembly = Assembly.GetExecutingAssembly();
#endif

            // Get image as a stream from the resources
            // Picture is defined as EmbeddedResource and DoNotCopy
            Stream resourceStream = currentAssembly.GetManifestResourceStream(
                "ArcGISRuntime.Resources.PictureMarkerSymbols.pin_star_blue.png");

            // Create new symbol using asynchronous factory method from stream
            PictureMarkerSymbol pinSymbol = await PictureMarkerSymbol.CreateAsync(resourceStream);
            pinSymbol.Height = 50;
            pinSymbol.Width = 50;

            // Create location for the pint
            MapPoint pinPoint = new MapPoint(-226773, 6550477, SpatialReferences.WebMercator);

            // Create graphic with the location and symbol
            Graphic pinGraphic = new Graphic(pinPoint, pinSymbol);

            // Add graphic to the graphics overlay
            overlay.Graphics.Add(pinGraphic);
        }
    }
}
XAML
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage 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:mapping="clr-namespace:Esri.ArcGISRuntime.Mapping;assembly=Esri.ArcGISRuntime" 
             x:Class="ArcGISRuntime.Samples.RenderPictureMarkers.RenderPictureMarkers">
  <Grid>
    <esriUI:MapView x:Name="MyMapView"/>
  </Grid>
</ContentPage>
See Also
Additional Examples
Hyperlink to ExampleDescription
AddEncExchangeSetDisplay nautical charts per the ENC specification.
AddGraphicsWithSymbolsUse a symbol style to display a graphic on a graphics overlay.
AnalyzeHotspotsUse a geoprocessing service and a set of features to identify statistically significant hot spots and cold spots.
Animate3DGraphicAn `OrbitGeoElementCameraController` follows a graphic while the graphic's position and rotation are animated.
AuthorMapCreate and save a map as an ArcGIS `PortalItem` (i.e. web map).
BufferListGenerate multiple individual buffers or a single unioned buffer around multiple points.
ChangeBlendRendererBlend a hillshade with a raster by specifying the elevation data. The resulting raster looks similar to the original raster, but with some terrain shading, giving it a textured look.
ChangeEncDisplaySettingsConfigure the display of ENC content.
ChangeFeatureLayerRendererChange the appearance of a feature layer with a renderer.
ChangeSublayerRendererApply a renderer to a sublayer.
ChangeViewpointSet the map view to a new viewpoint.
ClipGeometryClip a geometry with another geometry.
CustomDictionaryStyleUse a custom dictionary style (.stylx) to symbolize features using a variety of attribute values.
DisplayKmlLoad and display KML from a URL, a local file, or a portal item.
DisplayKmlNetworkLinks Display a file with a KML network link.
DisplayLayerViewStateView the status of the layers on the map.
EditAndSyncFeaturesSynchronize offline edits with a feature service.
EditKmlGroundOverlayEdit the values of a KML ground overlay.
ExportTilesDownload tiles to a local tile cache file stored on the device.
FeatureLayerDefinitionExpressionLimit the features to display on the map using a definition expression.
FeatureLayerDictionaryRendererConvert features into graphics to show them with mil2525d symbols.
FeatureLayerQueryFind features in a feature table which match an SQL query.
FeatureLayerRenderingModeMapRender features statically or dynamically by setting the feature layer rendering mode.
FeatureLayerRenderingModeSceneRender features in a scene statically or dynamically by setting the feature layer rendering mode.
FeatureLayerSelectionSelect features in a feature layer.
FeatureLayerUrlShow a feature layer on a map using the URL to the service.
FindAddressFind the location for an address.
FindPlaceFind places of interest near a location or within a specific area.
FindRouteDisplay directions for a route between two points.
FindServiceAreaFind the service area within a network from a given point.
GenerateGeodatabaseGenerate a local geodatabase from an online feature service.
GenerateOfflineMapTake a web map offline.
GenerateOfflineMapWithOverridesUse the `OfflineMapTask` with overrides to take a webmap offline. The overrides workflow allows you to adjust the settings used for taking each layer in the map offline. For a simple example of how you take a map offline, please consult the "Generate Offline Map" sample.
GeodatabaseTransactionsThis sample demonstrates how to manage edits to a local geodatabase inside of transactions.
GeoViewSyncKeep the view points of two views (a MapView and a SceneView in this case) synchronized with each other.
GetElevationAtPointGet the elevation for a given point on a surface in a scene.
GroupLayersGroup a collection of layers together and toggle their visibility as a group.
IdentifyKmlFeaturesThis sample demonstrates how to identify features in a KML layer. Identified feature attributes are displayed in a callout to simulate a popup.
IdentifyLayersIdentify features in all layers in a map. MapView supports identifying features across multiple layers. Because some layer types have sublayers, the sample recursively counts results for sublayers within each layer.
LineOfSightGeoElementShow a line of sight between two moving objects.
ListKmlContentsList the contents of a KML file. KML files can contain a hierarchy of features, including network links to other KML content.
ListTransformationsGet a list of suitable transformations for projecting a geometry between two spatial references with different horizontal datums.
ManageBookmarksAccess and create bookmarks on a map.
MapImageLayerTablesFind features in a spatial table related to features in a non-spatial table.
MapImageSublayerQueryFind features in a sublayer based on attributes and location.
OfflineBasemapByReferenceUse the `OfflineMapTask` to take a web map offline, but instead of downloading an online basemap, use one which is already on the device.
OfflineGeocodeGeocode addresses to locations and reverse geocode locations to addresses offline.
OfflineRoutingSolve a route on-the-fly using offline data.
QueryFeatureCountAndExtentZoom to features matching a query and count the features in the current visible extent.
RasterHillshadeUse a hillshade renderer on a raster.
RasterLayerGeoPackageOpen a `GeoPackage`, obtain a raster from the package, and display the table as a `RasterLayer`.
RasterRenderingRuleDisplay a raster on a map and apply different rendering rules to that raster.
RasterRgbRendererUse an `RGBRenderer` on a `RasterLayer`. An `RGBRenderer` is used to adjust the color bands of a multispectral image.
RenderPictureMarkersUse pictures for markers.
RenderSimpleMarkersShow a simple marker symbol on a map.
RouteAroundBarriersFind a route that reaches all stops without crossing any barriers.
SelectEncFeaturesSelect features in an ENC layer.
ServiceFeatureTableCacheDisplay a feature layer from a service using the **on interaction cache** feature request mode.
ServiceFeatureTableManualCacheDisplay a feature layer from a service using the **manual cache** feature request mode.
ServiceFeatureTableNoCacheDisplay a feature layer from a service using the **no cache** feature request mode.
SetInitialMapAreaDisplay the map at an initial viewpoint representing a bounding geometry.
SetMinMaxScaleRestrict zooming between specific scale ranges.
SimpleRenderersDisplay common symbols for all graphics in a graphics overlay with a renderer.
StatisticalQueryQuery a table to get aggregated statistics back for a specific field.
StyleWmsLayerDiscover available styles and apply them to WMS sublayers.
SymbolizeShapefileDisplay a shapefile with custom symbology.
TraceUtilityNetworkDiscover connected features in a utility network using connected, subnetwork, upstream, and downstream traces.
ViewPointCloudDataOfflineDisplay local 3D point cloud data.
WmsIdentifyIdentify features in a WMS layer and display the associated popup content.
WMSLayerUrlDisplay a WMS layer using a WMS service URL.
WmsServiceCatalogConnect to a WMS service and show the available layers and sublayers. Layers are shown in a hierarchy. Selecting a group layer will recursively select all sublayers for display.