// The graphic can be drawn with a DataContracts.Geometry object // using AddGraphic(DataContracts.Geometry, Symbol, MapTip, // IEnumerable<KeyValuePair<string,object>> Attributes) GraphicsManager graphicsManager = GraphicManagerFactory.CreateGraphicsManager(); graphicsManager.AddGraphic(geometry, null, null, null); // or with a Feature using AddGraphic(Feature, Symbol, MapTip) graphicsManager.AddGraphic(feature, null, null);
bool isDrawing = false; GraphicsManager graphicsManager = GraphicManagerFactory.CreateGraphicsManager(); GeometrySelectionService geometryService = new GeometrySelectionService( new GeometrySelectionServiceConfiguration { ShowLabels = true, Color = Colors.Green });
private void DrawCompleteCallback(DataContracts.Geometry geometry) { isDrawing = false; graphicsManager.AddGraphic(geometry, SymbolManager.GetFillSymbol("#FF0000"), null, null); }
if (isDrawing) { geometryService.CancelSelection(); } isDrawing = true; // This example uses the DrawCompleteCallback geometryService.SelectGeometry(GeometryType.Polyline, DrawCompleteCallback); // The same thing using a lambda expression geometryService.SelectGeometry(GeometryType.Polyline, g => { // The drawing is done, so set the flag and add the graphic to the map. // Note that the symbol, map tip, and attributes can also be set on the drawing object here. isDrawing = false; graphicsManager.AddGraphic(g, null, null, null); });
private void GeometryChangeDelegate(object sender, GeometryChangedEventArgs e) { // We can get a reference to the geometry being drawn from the GeometryChangedEventArgs DataContracts.Geometry envelope = e.CurrentGeometry; // And do something with the object as it's being drawn. The following uses the MeasureManager to // calculcate the perimiter and area of the envelope. DataContracts.Geometry polygon = GeometryTranslator.ConvertEnvelopeToPolygon(envelope); Area = Math.Round(MeasureManager.GetMeasureManager(_linearUnit, _areaUnit).GetPolygonArea(polygon), 2).ToString(); Perimeter = Math.Round(MeasureManager.GetMeasureManager(_linearUnit, _areaUnit).GetPerimeter(polygon), 2).ToString(); }
geometryService.SelectGeometry(GeometryType.Box, DrawCompleteCallback, "Select geometry for measurement.", GeometryChangeDelegate, Unit.Mile, SquareUnit.SquareMile);