You can programmatically create different types of 3D symbols and add them to a scene at specified locations. You could do this to call attention to the prominence of a location.
How to use the sample
When the scene loads, note the different types of 3D symbols that you can create.
How it works
Create a GraphicsOverlay.
Create various simple marker scene symbols by specifying different styles and colors, and a height, width, depth, and anchor position of each.
Create a new Graphic object for each symbol.
Add the graphics to the graphics overlay with graphicsOverlay.getGraphics().add(graphic).
Add the graphics overlay to the scene view with sceneView.getGraphicsOverlays().add(graphicsOverlay).
Relevant API
Graphic
GraphicsOverlay
SceneSymbol.AnchorPosition
SimpleMarkerSceneSymbol
SimpleMarkerSceneSymbol.Style
About the data
This sample shows arbitrary symbols in an empty scene with an imagery basemap.
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
/* 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.
*
*/package com.esri.arcgisruntime.sample.scenesymbols;
import android.graphics.Color;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import com.esri.arcgisruntime.ArcGISRuntimeEnvironment;
import com.esri.arcgisruntime.geometry.Point;
import com.esri.arcgisruntime.geometry.SpatialReferences;
import com.esri.arcgisruntime.mapping.ArcGISScene;
import com.esri.arcgisruntime.mapping.ArcGISTiledElevationSource;
import com.esri.arcgisruntime.mapping.Basemap;
import com.esri.arcgisruntime.mapping.BasemapStyle;
import com.esri.arcgisruntime.mapping.Surface;
import com.esri.arcgisruntime.mapping.view.Camera;
import com.esri.arcgisruntime.mapping.view.Graphic;
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay;
import com.esri.arcgisruntime.mapping.view.LayerSceneProperties;
import com.esri.arcgisruntime.mapping.view.SceneView;
import com.esri.arcgisruntime.symbology.SceneSymbol;
import com.esri.arcgisruntime.symbology.SimpleMarkerSceneSymbol;
publicclassMainActivityextendsAppCompatActivity{
private SceneView mSceneView;
@OverrideprotectedvoidonCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// authentication with an API key or named user is required to access basemaps and other// location services ArcGISRuntimeEnvironment.setApiKey(BuildConfig.API_KEY);
// get a reference to the scene view mSceneView = findViewById(R.id.sceneView);
// create a scene and add it to the scene view ArcGISScene scene = new ArcGISScene(BasemapStyle.ARCGIS_IMAGERY);
mSceneView.setScene(scene);
// add base surface for elevation datafinal Surface surface = new Surface();
ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource(
getString(R.string.elevation_image_service_url));
surface.getElevationSources().add(elevationSource);
scene.setBaseSurface(surface);
// add a camera and initial camera position Camera camera = new Camera(28.9, 45, 12000, 0, 45, 0);
mSceneView.setViewpointCamera(camera);
// add graphics overlay(s) GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
graphicsOverlay.getSceneProperties().setSurfacePlacement(LayerSceneProperties.SurfacePlacement.ABSOLUTE);
mSceneView.getGraphicsOverlays().add(graphicsOverlay);
int[] colors = { Color.RED, Color.GREEN, Color.BLUE, Color.MAGENTA, Color.CYAN, Color.WHITE };
SimpleMarkerSceneSymbol.Style[] symbolStyles = SimpleMarkerSceneSymbol.Style.values();
// for each symbol style (cube, cone, cylinder, diamond, sphere, tetrahedron)for (int i = 0; i < symbolStyles.length; i++) {
SimpleMarkerSceneSymbol simpleMarkerSceneSymbol = new SimpleMarkerSceneSymbol(symbolStyles[i], colors[i], 200,
200, 200, SceneSymbol.AnchorPosition.CENTER);
Graphic graphic = new Graphic(new Point(44.975 + .01 * i, 29, 500, SpatialReferences.getWgs84()),
simpleMarkerSceneSymbol);
graphicsOverlay.getGraphics().add(graphic);
}
}
@OverrideprotectedvoidonPause(){
mSceneView.pause();
super.onPause();
}
@OverrideprotectedvoidonResume(){
super.onResume();
mSceneView.resume();
}
@OverrideprotectedvoidonDestroy(){
mSceneView.dispose();
super.onDestroy();
}
}