public Task <Geometry> Edit(List <Ham.SpatialBase.Point> points, bool isClosed, EditableFeatureLayerOptions options = null) { if (points == null || points.Count < 1) { return(new Task <Geometry>(null)); } if (options == null) { options = new EditableFeatureLayerOptions(); } var type = points.Count == 1 ? GeometryType.Point : (isClosed ? GeometryType.Polygon : GeometryType.LineString); Geometry geometry = new Geometry(points.ToArray(), type); return(Edit(geometry, options)); }
public static ILegendCommand CreateSelectByDrawing <T>(MapPresenter map, VectorLayer layer) where T : class, ISqlGeometryAware { var result = new LegendCommand() { PathMarkup = IRI.Jab.Common.Assets.ShapeStrings.Appbar.appbarVectorPenConvert, Layer = layer, ToolTip = "انتخاب عوارض محدودهٔ ترسیم", }; result.Command = new RelayCommand(async param => { var options = EditableFeatureLayerOptions.CreateDefaultForDrawing(false, false); options.IsOptionsAvailable = false; var drawingResult = await map.GetDrawingAsync(Model.DrawMode.Polygon, options); if (!drawingResult.HasNotNullResult()) { return; } var features = layer.GetFeatures <T>(drawingResult.Result.AsSqlGeometry()); if (features == null) { return; } var newLayer = new Model.Map.SelectedLayer <T>(layer) { ShowSelectedOnMap = true }; if (features != null) { newLayer.Features = new System.Collections.ObjectModel.ObservableCollection <T>(features); } map.AddSelectedLayer(newLayer); }); return(result); }
public async Task <Geometry> Edit(Geometry geometry, EditableFeatureLayerOptions options) { //this.IsEditMode = true; Geometry result = null; if (this.RequestEdit != null) { result = await RequestEdit(geometry, options); } else { result = await new Task <Geometry>(null); } //this.IsEditMode = false; return(result); }
public DrawingLayer(DrawMode mode, Transform toScreen, Func <double, double> screenToMap, sb.Point startMercatorPoint, EditableFeatureLayerOptions options) { this._mode = mode; sb.GeometryType type; switch (mode) { case DrawMode.Point: type = sb.GeometryType.Point; break; case DrawMode.Polyline: type = sb.GeometryType.LineString; break; case DrawMode.Polygon: type = sb.GeometryType.Polygon; break; case DrawMode.Rectange: case DrawMode.Freehand: default: throw new NotImplementedException(); } //var options = new EditableFeatureLayerOptions() { IsVerticesLabelVisible = isEdgeLengthVisible }; this._editableFeatureLayer = new EditableFeatureLayer("edit", new List <sb.Point>() { startMercatorPoint }, toScreen, screenToMap, type, options) { ZIndex = int.MaxValue }; this._editableFeatureLayer.OnRequestFinishDrawing += (sender, e) => { this.OnRequestFinishDrawing.SafeInvoke(this); }; this._editableFeatureLayer.RequestFinishEditing = g => { this.RequestFinishEditing?.Invoke(g); }; this._editableFeatureLayer.RequestCancelDrawing = () => { this.RequestCancelDrawing?.Invoke(); }; this.VisibleRange = ScaleInterval.All; this.VisualParameters = new VisualParameters(mode == DrawMode.Polygon ? new SolidColorBrush(Colors.YellowGreen) : null, new SolidColorBrush(Colors.Blue), 3, 1); }