Features graphics Geometries
目录
Features graphics Geometries
Geometries
Geometries的基础作用
Envelope
// Envelope with bounding coords defined in longitude and latitude
var areaOfInterest = new Envelope(-117.85, 32.20, -116.50, 33.45, SpatialReferences.Wgs84);
// Envelope with lower-left (southwest) and upper-right (northeast) points
var southwestPoint = new MapPoint(-117.85, 32.20, SpatialReferences.Wgs84);
var northeastPoint = new MapPoint(-116.50, 33.45, SpatialReferences.Wgs84);
var env = new Envelope(southwestPoint, northeastPoint);
Point
// create a point with x, y, and z coordinate values using the WGS 1984 coordinate system
var saltLakeCity = new MapPoint(-111.88, 40.75, 1320, SpatialReferences.Wgs84);
经纬度的话为(latitude, longitude)
Multipoint
var pointCollection = new MapPoint[] { southwestPoint, northeastPoint, saltLakeCity };
var oneMultipoint = new Multipoint(pointCollection, SpatialReferences.Wgs84);
遍历Multipoint
foreach (var pt in oneMultipoint.Points)
{
var coordValues = string.Format("x: {0} y: {1} z: {2}", pt.X, pt.Y, pt.Z);
Debug.WriteLine(coordValues);
}
Polyline
// define some map points (airports: LA, Chicago, Paris)
var laxPoint = new MapPoint(-118.408, 33.943, SpatialReferences.Wgs84);
var ordPoint = new MapPoint(-87.905, 41.979, SpatialReferences.Wgs84);
var orlyPoint = new MapPoint(2.379, 48.723, SpatialReferences.Wgs84);
// add the points to a collection
var stops = new MapPoint[] { laxPoint, ordPoint, orlyPoint };
// create a new Polyline from the points
var myFlightPath = new Esri.ArcGISRuntime.Geometry.Polyline(stops);
Polygon
// create a point collection; add each corner of the state of Colorado
var coloradoCorners = new Esri.ArcGISRuntime.Geometry.PointCollection(SpatialReferences.Wgs84);
coloradoCorners.Add(-109.048, 40.998);
coloradoCorners.Add(-102.047, 40.998);
coloradoCorners.Add(-102.037, 36.989);
coloradoCorners.Add(-109.048, 36.998);
// create a new polygon from the point collection
var coloradoPoly = new Esri.ArcGISRuntime.Geometry.Polygon(coloradoCorners);
Multipart (Polygon and Polyline)
// loop through all points (vertices) in all parts of a Polygon
foreach (var part in hawaiiPoly.Parts)
{
foreach (var pt in part.Points)
{
// read the point coordinates
var coordValues = string.Format("x: {0} y: {1} z: {2}", pt.X, pt.Y, pt.Z);
Debug.WriteLine(coordValues);
}
}
Features和graphics的关系
Features和graphics组成
Features and graphics are similar to one another in that they both have a geometry and attributes, this is represented by the geo-element interface which they both implement.
graph LR
geometry --> Features/graphics
attributes --> Features/graphics
Features和graphics比较
Features和graphics的展示依赖
graph LR
features-->Feature_layers
Feature_layers --> feature_table
graph LR
MapView -->map
MapView -->graphic_overlays
graphic_overlays-->graphics
graphic_overlays在所有layer上面
创建features
// define an online data source (ServiceFeatureTable)
var uri = new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/SF311/FeatureServer/0");
var incidentsFeatureTable = new ServiceFeatureTable(uri);
// await loading of the table then check the load status
await incidentsFeatureTable.LoadAsync();
if(incidentsFeatureTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded)
{
// create a new feature layer, pass the service feature table to the constructor
var incidentsLayer = new Esri.ArcGISRuntime.Mapping.FeatureLayer(incidentsFeatureTable);
// add the feature layer to the map
MyMapView.Map.OperationalLayers.Add(incidentsLayer);
}
创建graphics
private void DrawLineGraphic(Polyline polylineShape)
{
// get the first graphics overlay in the map view
var myGraphics = MyMapView.GraphicsOverlays[0];
// define a line symbol (dashed blue)
var lineSymbol = new SimpleLineSymbol();
lineSymbol.Color = Colors.Blue;
lineSymbol.Style = SimpleLineSymbolStyle.Dash;
lineSymbol.Width = 2;
// create a new graphic; set the Geometry and Symbol
var lineGraphic = new Esri.ArcGISRuntime.UI.Graphic();
lineGraphic.Geometry = polylineShape;
lineGraphic.Symbol = lineSymbol;
// add the graphic to the graphics overlay
myGraphics.Graphics.Add(lineGraphic);
}