forked from Esri/arcgis-maps-sdk-dotnet-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSurfacePlacements.xaml.cs
105 lines (84 loc) · 4.62 KB
/
SurfacePlacements.xaml.cs
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// 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 Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Symbology;
using Esri.ArcGISRuntime.UI;
using System;
using System.Drawing;
namespace ArcGISRuntime.UWP.Samples.SurfacePlacements
{
[ArcGISRuntime.Samples.Shared.Attributes.Sample(
"Surface placement",
"GraphicsOverlay",
"This sample demonstrates how to position graphics using different Surface Placements.",
"")]
public sealed partial class SurfacePlacements
{
public SurfacePlacements()
{
InitializeComponent();
Initialize();
}
private void Initialize()
{
// Create new Scene
Scene myScene = new Scene
{
// Set Scene's base map property
Basemap = Basemap.CreateImagery()
};
// Create a camera with coordinates showing layer data
Camera camera = new Camera(53.04, -4.04, 1300, 0, 90.0, 0);
// Assign the Scene to the SceneView
MySceneView.Scene = myScene;
// Create ElevationSource from elevation data Uri
ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource(
new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"));
// Add elevationSource to BaseSurface's ElevationSources
MySceneView.Scene.BaseSurface.ElevationSources.Add(elevationSource);
// Set view point of scene view using camera
MySceneView.SetViewpointCameraAsync(camera);
// Create overlays with elevation modes
GraphicsOverlay drapedOverlay = new GraphicsOverlay();
drapedOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Draped;
MySceneView.GraphicsOverlays.Add(drapedOverlay);
GraphicsOverlay relativeOverlay = new GraphicsOverlay();
relativeOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative;
MySceneView.GraphicsOverlays.Add(relativeOverlay);
GraphicsOverlay absoluteOverlay = new GraphicsOverlay();
absoluteOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Absolute;
MySceneView.GraphicsOverlays.Add(absoluteOverlay);
// Create point for graphic location
MapPoint point = new MapPoint(-4.04, 53.06, 1000, camera.Location.SpatialReference);
// Create a red circle symbol
SimpleMarkerSymbol circleSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.FromArgb(255, 255, 0, 0), 10);
// Create a text symbol for each elevation mode
TextSymbol drapedText = new TextSymbol("DRAPED", Color.FromArgb(255, 255, 255, 255), 10,
Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center,
Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle);
drapedText.OffsetY += 20;
TextSymbol relativeText = new TextSymbol("RELATIVE", Color.FromArgb(255, 255, 255, 255), 10,
Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center,
Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle);
relativeText.OffsetY += 20;
TextSymbol absoluteText = new TextSymbol("ABSOLUTE", Color.FromArgb(255, 255, 255, 255), 10,
Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center,
Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle);
absoluteText.OffsetY += 20;
// Add the point graphic and text graphic to the corresponding graphics overlay
drapedOverlay.Graphics.Add(new Graphic(point, circleSymbol));
drapedOverlay.Graphics.Add(new Graphic(point, drapedText));
relativeOverlay.Graphics.Add(new Graphic(point, circleSymbol));
relativeOverlay.Graphics.Add(new Graphic(point, relativeText));
absoluteOverlay.Graphics.Add(new Graphic(point, circleSymbol));
absoluteOverlay.Graphics.Add(new Graphic(point, absoluteText));
}
}
}