|
POST
|
I'm not able to reproduce the issue with the following services and code. What version of the API are you using? and what layer type? In sample below, I am using FeatureLayer with the same SpatialReferences as you have. The reported FullExtent for each layer matches the map. Envelope envelope = null;
MyMapView.LayerViewStateChanged += (s, e) =>
{
var error = e.LayerViewState.Error ?? e.Layer.LoadError;
if(error != null)
{
MessageBox.Show(error.Message, error.GetType().Name);
return;
}
if (e.Layer is FeatureLayer && e.LayerViewState.Status != LayerViewStatus.Loading && e.Layer.FullExtent != null && !e.Layer.FullExtent.IsEmpty)
{
var extent = e.Layer.FullExtent;
if (envelope == null)
envelope = extent;
else
{
envelope = GeometryEngine.Union(envelope, extent)?.Extent;
}
if (envelope != null)
{
System.Diagnostics.Debug.WriteLine(extent);
MyMapView.SetViewpoint(new Viewpoint(envelope));
}
}
};
var map = new Map(Basemap.CreateTopographic());
map.OperationalLayers.Add(new FeatureLayer(new Uri("http://zimas.lacity.org/arcgis/rest/services/B_ZONING/MapServer/0")) { Id = "2229" });
map.OperationalLayers.Add(new FeatureLayer(new Uri("https://gis-public.co.san-diego.ca.us/arcgis/rest/services/rov/sdvote_politicalbounds/MapServer/0")) { Id = "2230" });
MyMapView.Map = map; You may be using service metadata, LayerInfo.Extent, which is not projected. Before you can perform a union of two extents, you must put them in the same projection. You can then use GeometryEngine.Project var extent = (((FeatureLayer)e.Layer).FeatureTable as ArcGISFeatureTable)?.Extent;
if (envelope == null)
envelope = extent;
else if(!envelope.SpatialReference.IsEqual(extent.SpatialReference))
{
var projectedExtent = GeometryEngine.Project(extent, envelope.SpatialReference);
envelope = GeometryEngine.Union(envelope, projectedExtent)?.Extent;
}
else
{
envelope = GeometryEngine.Union(envelope, extent)?.Extent;
}
if (extent != null)
{
System.Diagnostics.Debug.WriteLine(extent);
MyMapView.SetViewpoint(new Viewpoint(envelope));
}
... View more
08-27-2018
10:00 AM
|
2
|
1
|
1480
|
|
POST
|
Thank you, we should fix that in our LayerLegend. I just logged this issue Meanwhile, you can update the Template style by adding this resource <Grid.Resources>
<Style TargetType="esriTK:LayerLegend">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<ItemsControl x:Name="ItemsList"
ItemTemplate="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ItemTemplate}"
ItemsPanel="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ItemsPanel}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
... View more
08-23-2018
04:24 PM
|
0
|
0
|
1098
|
|
POST
|
Thank you for reporting this, it's been logged and fixed in our current builds to address this user feedback. You may want to use PropertyChanged for Geometry meanwhile. However, do you mean to update feature's geometry before sketch has completed? You can use set SketchEditor.Style Fill/Line/Marker/Selected symbols if you just need the temporary graphic of SketchEditor to match your feature's symbology.
... View more
08-23-2018
03:52 PM
|
0
|
1
|
1134
|
|
POST
|
Legend will use the same symbology applied to the features so if you set FeatureLayer.Renderer on one of them to differentiate between the two. For example, ((FeatureLayer)e.Layer).Renderer = new SimpleRenderer(new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Diamond, Color.Blue, 10d)) { Label = "New Label" }; Legend will pick up this new symbol and label. What platform are you using?
... View more
08-23-2018
02:16 PM
|
0
|
2
|
1098
|
|
POST
|
You are correct that object data type in Attributes dictionary imply any user-defined type may be supported as well. This was also possible in v10.x releases at least in the context of Graphics. But with v100.x, creation of fields (which defines the columns of database table) are limited to types ArcGIS Server support, which means the Attributes (which represent row values) follow this same restriction.
... View more
08-23-2018
02:09 PM
|
1
|
0
|
1286
|
|
POST
|
Attributes in v100.x only support the following data types https://developers.arcgis.com/net/latest/wpf/api-reference//html/T_Esri_ArcGISRuntime_Data_FieldType.htm with the exception of Geometry, Xml, Raster, Blob. If you have a user-defined enum, you can cast it to int to allow you to store it in graphic.Attribute. graphic.Attributes[_adHocGraphicTypeAttributeName] = (int)AdHocGraphicTypeEnum.UserSketch; and evaluate its value by casting it back to the enum type. if( (AdHocGraphicTypeEnum) graphic.Attributes[_adHocGraphicTypeAttributeName] == AdHocGraphicTypeEnum.UserSketch) {...}
... View more
08-23-2018
12:51 PM
|
1
|
2
|
1286
|
|
POST
|
I have logged a new issue for us. I'm able to consistently reproduce on Windows 7 although sometimes it takes a while to reproduce but haven't yet seen it happen on Windows 10. That's why I have a strong suspicion it has to do with the events. Perhaps a single click registers as double click. Regardless, API should still not crash. I have no math behind this but for my testing, adding an insignificant delay (await Task.Delay(25)) before evaluating PointCount allows point to be added before sketch is completed which seems to avoid the crash.
... View more
08-17-2018
03:22 PM
|
0
|
1
|
2618
|
|
POST
|
Thank you for providing us repro code. I'm still unable to reproduce on my Windows 10 machine but I was able to repro on Windows 7 machine. The issue we had logged previously for Windows 7 was also triple-tap/click and the customer's use case was identical to yours they'd restart editor after it has completed. Instead of subscribing to MouseDoubleClick or GeoViewDoubleTapped right away, can you do this only prior to starting editor and unhooking when done? You can then use this task below for button clicked, SpatialReferenceChanged, or GeoViewDoubleTapped handler. I've seen this to prevent crash on Windows 7. private async Task RestartDrawAsync()
{
try
{
this.MyMapView.GeoViewDoubleTapped += this.MyMapViewOnGeoViewDoubleTapped;
// Initial start of the SketchEditor, it gets restarted after the completion.
await this.MyMapView.SketchEditor.StartAsync(SketchCreationMode.Polyline).ConfigureAwait(true);
}
catch (TaskCanceledException)
{
// Happens when canceling SketchEditor.
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().Name);
}
finally
{
this.MyMapView.GeoViewDoubleTapped -= this.MyMapViewOnGeoViewDoubleTapped;
}
} Alternatively, you can mark event handled if SketchEditor is enabled/active this.MyMapView.GeoViewTapped += (s, e) => { e.Handled = MyMapView.SketchEditor.IsEnabled && MyMapView.SketchEditor.CancelCommand.CanExecute(null); };
... View more
08-16-2018
03:03 PM
|
0
|
3
|
2618
|
|
POST
|
I see, `drawAndEdit:false` completes when the expected gesture occurs (tap for Point, double-tap for Polyline/Polygon/ touch up for shapes drawn by drag) but it's CompleteCommand that checks for minimum set of vertices. We'll get this check added in here as well. There is already an existing issue logged for this. Thanks for clarification.
... View more
08-15-2018
10:19 AM
|
0
|
0
|
2451
|
|
POST
|
I'm not able to reproduce. SketchEditor appear to have been started by SketchCreationMode, it doesn't look like it had input geometry. I may be missing something in my repro. Can you share SketchEditConfiguration parameters? I tried to simplify it down to this. I also tried starting editor from button click but I haven't seen it crash on stop or start. MyMapView.Map = new Map(SpatialReferences.Wgs84);
MyMapView.MouseDoubleClick += (a, b) =>
{
if ((MyMapView.SketchEditor.Geometry as Polygon)?.Parts?.FirstOrDefault()?.PointCount >= 4
&& MyMapView.SketchEditor.CompleteCommand.CanExecute(null))
MyMapView.SketchEditor.CompleteCommand.Execute(null);
};
MyMapView.SpatialReferenceChanged += async (s, e) =>
{
var config = new SketchEditConfiguration();
var geom = await MyMapView.SketchEditor.StartAsync(SketchCreationMode.Polygon, config).ConfigureAwait(true);
MessageBox.Show(geom.ToJson());
}; Could this be specific to Windows 7? I seem to recall now that we had issues with detecting double click on Windows 7. One of the related issues in the past had this workaround: private static int DoubleTapInMs = 550;
private static int TapTolerance = 100;
private int _lastTapTimestamp = int.MinValue;
private Point _lastTapPosition;
private void TheMap_PreviewStylusSystemGesture(object sender, StylusSystemGestureEventArgs e)
{
if (e.SystemGesture == SystemGesture.Tap)
{
var position = e.GetPosition(this);
var currentTimeStamp = e.Timestamp;
var elapsedTimeInMs = currentTimeStamp - _lastTapTimestamp;
double distance = Math.Pow(position.X - _lastTapPosition.X, 2) + Math.Pow(position.Y - _lastTapPosition.Y, 2);
_lastTapTimestamp = currentTimeStamp;
_lastTapPosition = position;
if (elapsedTimeInMs < DoubleTapInMs && distance < TapTolerance)
{
e.Handled = true;
if (TheMap.Editor.Complete.CanExecute(null))
TheMap.Editor.Complete.Execute(null);
}
}
}
... View more
08-15-2018
10:05 AM
|
0
|
5
|
2618
|
|
POST
|
Oh that should not have happened, thank you for reporting this! I have logged an issue to fix NullRef exception. The optional `drawAndEdit` parameter is to complete the task as soon as something is drawn. In the case of Polygon, after double-tap occurs and there's at least 3 vertices, it will be completed without going to edit mode or requiring Stop/Complete to be called. Since you plan to complete the draw programmatically given your specific condition, you can alternatively use EditConfiguration to disable the edits you don't need, or var config = new SketchEditConfiguration()
{
AllowVertexEditing = false,
AllowMove = false,
AllowRotate = false,
ResizeMode = SketchResizeMode.None
};
var geom = await MyMapView.SketchEditor.StartAsync(SketchCreationMode.Polygon, config); you can change the symbols in the Style. MyMapView.SketchEditor.Style.ShowNumbersForVertices = false;
MyMapView.SketchEditor.Style.SelectionColor = Color.Red;
MyMapView.SketchEditor.Style.SelectedVertexSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Red, 1);
MyMapView.SketchEditor.Style.VertexSymbol = null;
MyMapView.SketchEditor.Style.MidVertexSymbol = null;
var geom = await MyMapView.SketchEditor.StartAsync(SketchCreationMode.Polygon); We still need to fix the NullRef ex but meanwhile you have the option to use any of the above suggestions.
... View more
08-14-2018
01:11 PM
|
1
|
2
|
2451
|
|
POST
|
I see. You can programmatically call insert or move vertex. Moving the selected vertex during MouseMove, ManipulationDelta, TouchMove, or any event you see fit, should show the connecting line between last committed vertex to where you're moving cursor/touch point to. Something like this, but you have to find the right condition that works for you to differentiate between insert/move. int vertexCount = 0;
MyMapView.MouseMove += (s, e) =>
{
if (!MyMapView.SketchEditor.IsEnabled || MyMapView.SketchEditor.Geometry == null)
return;
var location = MyMapView.ScreenToLocation(e.GetPosition(MyMapView));
if ((MyMapView.SketchEditor.Geometry as Polygon)?.Parts?.FirstOrDefault()?.PointCount <= vertexCount)
MyMapView.SketchEditor.InsertVertexAfterSelectedVertex(location);
else
MyMapView.SketchEditor.MoveSelectedVertex(location);
};
MyMapView.GeoViewTapped += (s, e) =>
{
vertexCount++;
};
... View more
08-13-2018
12:18 PM
|
0
|
2
|
2482
|
|
POST
|
Whether you use CompleteCommand or Stop, SketchEditor.Geometry is expected to be cleared or set back to null since the SketchEditor.StartAsync would have already returned with resulting geometry. You probably have code similar to this. Geometry property or GeometryChanged are meant for tracking geometry as it gets created/updated. But it would be the result of StartAsync that gives you end geometry from the completed draw/edit. MyMapView.Map = new Map(SpatialReferences.Wgs84);
MyMapView.GraphicsOverlays.Add(new GraphicsOverlay() { Renderer = new SimpleRenderer(new SimpleFillSymbol()) });
MyMapView.SketchEditor.GeometryChanged += (s, e) =>
{
if ((e.NewGeometry as Polygon)?.Parts?.FirstOrDefault()?.PointCount == 4)
{
//if (MyMapView.SketchEditor.CompleteCommand.CanExecute(null))
//{
// MyMapView.SketchEditor.CompleteCommand.Execute(null);
//}
MyMapView.SketchEditor.Stop();
// SketchEditor.Geometry is null here
}
};
MyMapView.SpatialReferenceChanged += async (s, e) =>
{
var overlay = MyMapView.GraphicsOverlays.FirstOrDefault();
try
{
// CompleteCommand or Stop will return resulting geometry here
var geom = await MyMapView.SketchEditor.StartAsync(SketchCreationMode.Polygon);
overlay.Graphics.Add(new Graphic(geom));
}
catch (TaskCanceledException) { }
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().Name);
}
}; Another way to do this if awaiting StartAsync is not an option for you... After checking you have at most 4 vertices and you know you will be completing the draw/edit, is to use SketchEditor.Geometry before CompleteCommand is executed or Stop is called.
... View more
08-13-2018
11:47 AM
|
1
|
4
|
2451
|
|
POST
|
Thank you for reporting this issue and offering us a workaround. It does appear GeometryChanged to be raised earlier with an old value for NewGeometry. I just logged the issue so we can work on getting this fixed in future releases of the API. The Undo/Redo for change in vertex positions however, appear to be working. But if you need to know when/what Geometry has changed to, GeometryChangedEventArgs.NewGeometry only reflects the change when a new vertex is added or a vertex gets deleted. May I ask what you're using SketchEditor.Geometry for? Would it be something where two-way binding to this property can be done or is it necessary to do in code-behind where you subscribe to PropertyChanged event? Thanks.
... View more
08-13-2018
11:00 AM
|
1
|
1
|
2241
|
|
POST
|
Thank you for this feedback. I tried to simplify the repro code and what I'm seeing is if the tap/click was done in quick succession to result in a double-tap zoom or had a flick to cause a pan, the point feature is not created. This may be because it did not trigger a tapped event after all. I tried enabling only one of two tests at a time to check. What platform are you using? Are you observing the map to zoom or pan when graphic is not added? MyMapView.Map = new Map(Basemap.CreateTopographic());
MyMapView.GraphicsOverlays.Add(new GraphicsOverlay() { Renderer = new SimpleRenderer(new SimpleMarkerSymbol()) });
MyMapView.SpatialReferenceChanged += async (s, e) =>
{
var overlay = MyMapView.GraphicsOverlays.FirstOrDefault();
// Test #1: SketchEditor
while (true)
{
var g = await MyMapView.SketchEditor.StartAsync(SketchCreationMode.Point, false);
overlay.Graphics.Add(new Graphic(g));
}
};
MyMapView.GeoViewTapped += (s, e) =>
{
// Test #2: GeoViewTapped event
// var overlay = MyMapView.GraphicsOverlays.FirstOrDefault();
// overlay.Graphics.Add(new Graphic(e.Location));
}; I don't see this when I disable zoom/pan. MyMapView.InteractionOptions = new MapViewInteractionOptions() { IsZoomEnabled = false, IsPanEnabled = false };
... View more
08-13-2018
10:24 AM
|
1
|
1
|
1042
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-11-2025 01:30 PM | |
| 1 | 06-06-2025 10:14 AM | |
| 1 | 03-17-2025 09:47 AM | |
| 1 | 07-24-2024 07:32 AM | |
| 1 | 04-05-2024 06:37 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-03-2025
08:39 PM
|