Click or drag to resize

EnvelopeBuilder Class

Builder for creating Envelope instances.
Inheritance Hierarchy
SystemObject
  Esri.ArcGISRuntime.GeometryGeometryBuilderEnvelope
    Esri.ArcGISRuntime.GeometryEnvelopeBuilder

Namespace:  Esri.ArcGISRuntime.Geometry
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.9.0
Syntax
public sealed class EnvelopeBuilder : GeometryBuilder<Envelope>

The EnvelopeBuilder type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleEnvelopeBuilder(Envelope)
Initializes a new instance of the EnvelopeBuilder class from an existing Envelope.
Public methodCode exampleEnvelopeBuilder(SpatialReference)
Initializes a new instance of the EnvelopeBuilder class with a SpatialReference and empty geometry.
Public methodEnvelopeBuilder(MapPoint, MapPoint)
Initializes a new instance of the EnvelopeBuilder class from two diagonal corner MapPoints.
Public methodEnvelopeBuilder(MapPoint, Double, Double)
Initializes a new instance of the EnvelopeBuilder class from a center point, with a defined width and height.
Public methodEnvelopeBuilder(Double, Double, Double, Double)
Initializes a new instance of the EnvelopeBuilder class from given diagonal x/y corner coordinates.
Public methodEnvelopeBuilder(MapPoint, Double, Double, Double)
Initializes a new instance of the EnvelopeBuilder class from a center point, with defined width, height, and depth.
Public methodEnvelopeBuilder(Double, Double, Double, Double, SpatialReference)
Initializes a new instance of the EnvelopeBuilder class from given diagonal x/y corner coordinates and a SpatialReference.
Top
Properties
  NameDescription
Public propertyCenter
Gets the center point of the builder's envelope.
Public propertyDepth
Gets the depth (ZMax - ZMin) for this builder's envelope.
Public propertyCode exampleExtent
Gets the extent for the geometry in the builder.
(Inherited from GeometryBuilderT.)
Public propertyHasM
Gets a value indicating if the geometry builder has M.
(Inherited from GeometryBuilderT.)
Public propertyHasZ
Gets a value indicating if the geometry builder has Z.
(Inherited from GeometryBuilderT.)
Public propertyHeight
Gets the height of the builder's envelope (along Y-axis).
Public propertyIsEmpty
Check if a geometry builder is empty or not.
(Inherited from GeometryBuilderT.)
Public propertyIsSketchValid
Gets a flag indicating if this builder contains sufficient points to show a valid graphical sketch.
(Inherited from GeometryBuilderT.)
Public propertyMMax
Gets maximum M (measure) value for this builder's envelope.
Public propertyMMin
Gets minimum M (measure) value for this builder's envelope.
Public propertySpatialReference
Gets the SpatialReference for the geometry being built.
(Inherited from GeometryBuilderT.)
Public propertyWidth
Gets the width of the builder's envelope (along X-axis).
Public propertyXMax
Gets or sets the max coordinate along X-axis (upper right corner) for this builder's envelope.
Public propertyXMin
Gets or sets the min coordinate along X-axis (lower left corner) for this builder's envelope.
Public propertyYMax
Gets or sets the max coordinate along Y-axis (upper right corner) for this builder's envelope.
Public propertyYMin
Gets or sets the min coordinate along Y-axis (lower left corner) for this builder's envelope.
Public propertyZMax
Gets or sets the max coordinate along Z-axis for this builder's envelope.
Public propertyZMin
Gets or sets the min coordinate along Z-axis for this builder's envelope.
Top
Methods
  NameDescription
Public methodCenterAt
Centers the envelope over the given MapPoint.
Public methodChangeAspectRatio
Adjust the envelope's aspect ratio to match the ratio of the given width and height.
Public methodStatic memberCreateWithM(Double, Double, Double, Double, Double, Double)
Creates an EnvelopeBuilder based on the given x, y, and m values.
Public methodStatic memberCreateWithM(Double, Double, Double, Double, Double, Double, SpatialReference)
Creates an EnvelopeBuilder based on the given x, y, and m values in the given SpatialReference.
Public methodStatic memberCreateWithM(Double, Double, Double, Double, Double, Double, Double, Double)
Creates an EnvelopeBuilder based on the given x, y, z, and m values.
Public methodStatic memberCreateWithM(Double, Double, Double, Double, Double, Double, Double, Double, SpatialReference)
Creates an EnvelopeBuilder based on the given x, y, z, and m values in the given SpatialReference.
Public methodCode exampleExpand(Double)
Scales the envelope by the given factor.
Public methodExpand(MapPoint, Double)
Scales the envelope around an anchor point by the given factor.
Public methodOffsetBy
Moves the builder's envelope by the given offsets in the x and y dimensions.
Public methodReplaceGeometry
Replace the geometry in the builder to the new geometry.
(Inherited from GeometryBuilderT.)
Public methodSetM
Set both M (measure) values for the builder's envelope.
Public methodSetXY
Set the x and y values for the builder's envelope.
Public methodSetZ
Set both Z values for the builder's envelope.
Public methodCode exampleToGeometry
Returns a Geometry instance representing the current state of the builder
(Inherited from GeometryBuilderT.)
Public methodCode exampleUnionOf(Envelope)
Finds the union of this builder's envelope and the given envelope. This builder's envelope is updated with the result.
Public methodUnionOf(MapPoint)
Finds the union of this envelope and the given MapPoint. This builder's envelope is updated with the result.
Top
Remarks
Use the EnvelopeBuilder Class to to create and/or modify an Envelope shape. The builder is best suited for editing workflows where the user may be adding, inserting or removing parts of an Envelope geometry interactively. Envelopes are based upon the parent Geometry Class. The Geometry Class is immutable which means that you can not change its shape once it is created. Hence the EnvelopeBuilder provides the way to make changes when working with an Envelope. Use the ToGeometry Method to get the Envelope geometry from the builder.
Examples

WPF

Example Name: AddGraphicsWithSymbols

Use a symbol style to display a graphic on a graphics overlay.

Code example screen shot.

C#
// Copyright 2018 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.Drawing;

namespace ArcGISRuntime.WPF.Samples.AddGraphicsWithSymbols
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        name: "Add graphics with symbols",
        category: "GraphicsOverlay",
        description: "Use a symbol style to display a graphic on a graphics overlay.",
        instructions: "Observe the graphics on the map.",
        tags: new[] { "SimpleFillSymbol", "SimpleLineSymbol", "SimpleMarkerSymbol" })]
    public partial class AddGraphicsWithSymbols
    {
        // Create the graphics overlay
        private readonly GraphicsOverlay _overlay = new GraphicsOverlay();

        public AddGraphicsWithSymbols()
        {
            InitializeComponent();

            Initialize();
        }

        private void Initialize()
        {
            // Create the map
            Map myMap = new Map(BasemapType.Oceans, 56.075844, -2.681572, 14);

            // Add the map to the map view
            MyMapView.Map = myMap;

            // Add the graphics overlay to the map view
            MyMapView.GraphicsOverlays.Add(_overlay);

            // Call functions to create the graphics
            CreatePoints();
            CreatePolygon();
            CreatePolyline();
            CreateText();

            // Update the extent to encompass all of the symbols
            SetExtent();
        }

        private void CreatePoints()
        {
            // Create a red circle simple marker symbol
            SimpleMarkerSymbol redCircleSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.FromArgb(0xFF, 0xFF, 0x00, 0x00), 10);

            // Create graphics and add them to graphics overlay
            Graphic graphic = new Graphic(new MapPoint(-2.72, 56.065, SpatialReferences.Wgs84), redCircleSymbol);
            _overlay.Graphics.Add(graphic);

            graphic = new Graphic(new MapPoint(-2.69, 56.065, SpatialReferences.Wgs84), redCircleSymbol);
            _overlay.Graphics.Add(graphic);

            graphic = new Graphic(new MapPoint(-2.66, 56.065, SpatialReferences.Wgs84), redCircleSymbol);
            _overlay.Graphics.Add(graphic);

            graphic = new Graphic(new MapPoint(-2.63, 56.065, SpatialReferences.Wgs84), redCircleSymbol);
            _overlay.Graphics.Add(graphic);
        }

        private void CreatePolyline()
        {
            // Create a purple simple line symbol
            SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.FromArgb(0xFF, 0x80, 0x00, 0x80), 4);

            // Create a new point collection for polyline
            Esri.ArcGISRuntime.Geometry.PointCollection points = new Esri.ArcGISRuntime.Geometry.PointCollection(SpatialReferences.Wgs84)
            {
                // Create and add points to the point collection
                new MapPoint(-2.715, 56.061),
                new MapPoint(-2.6438, 56.079),
                new MapPoint(-2.638, 56.079),
                new MapPoint(-2.636, 56.078),
                new MapPoint(-2.636, 56.077),
                new MapPoint(-2.637, 56.076),
                new MapPoint(-2.715, 56.061)
            };

            // Create the polyline from the point collection
            Polyline polyline = new Polyline(points);

            // Create the graphic with polyline and symbol
            Graphic graphic = new Graphic(polyline, lineSymbol);

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

        private void CreatePolygon()
        {
            // Create a green simple line symbol
            SimpleLineSymbol outlineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.FromArgb(0xFF, 0x00, 0x50, 0x00), 1);

            // Create a green mesh simple fill symbol
            SimpleFillSymbol fillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.DiagonalCross, Color.FromArgb(0xFF, 0x00, 0x50, 0x00), outlineSymbol);

            // Create a new point collection for polygon
            Esri.ArcGISRuntime.Geometry.PointCollection points = new Esri.ArcGISRuntime.Geometry.PointCollection(SpatialReferences.Wgs84)
            {
                // Create and add points to the point collection
                new MapPoint(-2.6425, 56.0784),
                new MapPoint(-2.6430, 56.0763),
                new MapPoint(-2.6410, 56.0759),
                new MapPoint(-2.6380, 56.0765),
                new MapPoint(-2.6380, 56.0784),
                new MapPoint(-2.6410, 56.0786)
            };

            // Create the polyline from the point collection
            Polygon polygon = new Polygon(points);

            // Create the graphic with polyline and symbol
            Graphic graphic = new Graphic(polygon, fillSymbol);

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

        private void CreateText()
        {
            // Create two text symbols
            TextSymbol bassRockTextSymbol = new TextSymbol("Black Rock", Color.Blue, 10,
                Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Left, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Bottom);

            TextSymbol craigleithTextSymbol = new TextSymbol("Craigleith", Color.Blue, 10,
                Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Right, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Top);

            // Create two points
            MapPoint bassPoint = new MapPoint(-2.64, 56.079, SpatialReferences.Wgs84);
            MapPoint craigleithPoint = new MapPoint(-2.72, 56.076, SpatialReferences.Wgs84);

            // Create two graphics from the points and symbols
            Graphic bassRockGraphic = new Graphic(bassPoint, bassRockTextSymbol);
            Graphic craigleithGraphic = new Graphic(craigleithPoint, craigleithTextSymbol);

            // Add graphics to the graphics overlay
            _overlay.Graphics.Add(bassRockGraphic);
            _overlay.Graphics.Add(craigleithGraphic);
        }

        private void SetExtent()
        {
            // Get all of the graphics contained in the graphics overlay
            GraphicCollection myGraphicCollection = _overlay.Graphics;

            // Create a new envelope builder using the same spatial reference as the graphics
            EnvelopeBuilder myEnvelopeBuilder = new EnvelopeBuilder(SpatialReferences.Wgs84);

            // Loop through each graphic in the graphic collection
            foreach (Graphic oneGraphic in myGraphicCollection)
            {
                // Union the extent of each graphic in the envelope builder
                myEnvelopeBuilder.UnionOf(oneGraphic.Geometry.Extent);
            }

            // Expand the envelope builder by 30%
            myEnvelopeBuilder.Expand(1.3);

            // Adjust the viewable area of the map to encompass all of the graphics in the
            // graphics overlay plus an extra 30% margin for better viewing
            MyMapView.SetViewpointAsync(new Viewpoint(myEnvelopeBuilder.Extent));
        }
    }
}
XAML
<UserControl x:Class="ArcGISRuntime.WPF.Samples.AddGraphicsWithSymbols.AddGraphicsWithSymbols"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <esri:MapView x:Name="MyMapView"/>
    </Grid>

</UserControl>
See Also
Additional Examples
Hyperlink to ExampleDescription
AddGraphicsWithSymbolsUse a symbol style to display a graphic on a graphics overlay.
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.
ClipGeometryClip a geometry with another geometry.
EditAndSyncFeaturesSynchronize offline edits with a feature service.
ExportTilesDownload tiles to a local tile cache file stored on the device.
FeatureLayerQueryFind features in a feature table which match an SQL query.
FindRouteDisplay directions for a route between two points.
GenerateGeodatabaseGenerate a local geodatabase from an online feature service.