In the previous chapters, we've been looking at ArcGIS Runtime at a high level. It's time to go at this from a different angle. In this chapter, we're going to go down to the lowest level of the ArcGIS Runtime and discuss geometry so that we can build any kind of shape, and then we're going to discuss how we display the geometry by setting up the symbology. We will discuss how to make geometrical objects from scratch and how to apply them to entire layers, whether they come from online services or data stored locally on disk. We'll discuss the following topics:
Before we discuss geometry, we need to talk about what you assign geometry to. Basically, you are going to assign geometry to a graphic or a geodatabase feature.
As you can see in the diagram, the GeodatabaseFeature
and Graphic
classes inherit from the abstract class called Feature
. A Feature
class has geometry and attributes (fields) and comes from either a feature service (online), Runtime geodatabase (offline), or some other source, such as a shapefile. A graphic can be added to GraphicsLayer
or GraphicsOverlay
. The big difference between a Graphic
and a Feature
class is that a Feature
class is persisted to FeatureLayer
, either in a web service or to disk. A Graphic
class is stored in
GraphicsLayer
or GraphicsOverlay
, but is not persisted. Both the GeodatabaseFeature
and Graphic
classes can have their geometry set like this:
// Create a new Graphic. Graphic graphic = new Graphic(); // Create a new MapPoint and set it to the Graphics geometry. MapPoint mapPoint = new MapPoint(0, 0, 10000, Geometry.SpatialReferences.Wgs84); graphic.Geometry = mapPoint;
As shown here, a Graphic
class is created along with a MapPoint
geometry. The MapPoint
geometry is then assigned to the Geometry
property of Graphic
, which allows the graphic to be placed in its correct location. Once that is done, it can be added to GraphicsLayer
or GraphicsOverlay
. Geometry can also be assigned to a GeodatabaseFeature
class in a very similar fashion, but this is typically done interactively using the editor of MapView
.
18.117.188.138