|
POST
|
No problem at all. It wasn't a waste of time. You actively checked other ways to create geodatabase and query related features and those were very good feedback. I'm glad it's working for you too.
... View more
09-26-2017
02:21 PM
|
0
|
1
|
3088
|
|
POST
|
Thanks, Chad for the geodatabase. I'm unable to repro with v100.1. It seems like the first relationship reports no related features and the rest of the tables have at least one related feature. Is this what you'd expect with your data? I used the following code.. similar code for Xamarin Android, slight differences would be namespace how you retrieve file path and display alert messages. public MainWindow()
{
InitializeComponent();
MyMapView.Map = new Map(Basemap.CreateTopographic());
MyMapView.LayerViewStateChanged += OnLayerViewStateChanged;
MyMapView.GeoViewTapped += OnGeoViewTapped;
}
private async void OnGeoViewTapped(object sender, GeoViewInputEventArgs e)
{
try
{
var results = await MyMapView.IdentifyLayersAsync(e.Position, 2, false);
var layerResult = results?.FirstOrDefault(f =>
f.LayerContent is FeatureLayer &&
((FeatureLayer)f.LayerContent).FeatureTable is ArcGISFeatureTable &&
f.GeoElements.Any());
if (layerResult == null)
return;
var layer = (FeatureLayer)layerResult.LayerContent;
var table = (ArcGISFeatureTable)layer.FeatureTable;
var feature = (ArcGISFeature)layerResult.GeoElements.FirstOrDefault();
var queryResults = await table.QueryRelatedFeaturesAsync(feature);
foreach (var r in queryResults.ToArray())
{
MessageBox.Show($"Feature with ID `{feature.Attributes[table.ObjectIdField]}` has `{r.Count()}` related features from `{r.RelatedTable.TableName}`.");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().Name);
}
}
private void OnLayerViewStateChanged(object sender, LayerViewStateChangedEventArgs e)
{
var error = e.LayerViewState.Error ?? e.Layer.LoadError;
if (error != null)
MessageBox.Show(error.Message, error.GetType().Name);
}
private async void OnLoad(object sender, RoutedEventArgs e)
{
try
{
var geodatabase = await Geodatabase.OpenAsync(@"E:\dev\palmbeach.geodatabase");
var extent = geodatabase.GenerateGeodatabaseExtent as Envelope;
foreach(var table in geodatabase.GeodatabaseFeatureTables)
{
await table.LoadAsync();
if (table.HasGeometry)
{
if (extent == null || extent.IsEmpty)
extent = table.Extent;
else
extent = GeometryEngine.CombineExtents(extent, table.Extent);
MyMapView.Map.OperationalLayers.Add(new FeatureLayer(table));
}
else
MyMapView.Map.Tables.Add(table);
if (extent != null && !extent.IsEmpty)
await MyMapView.SetViewpointAsync(new Viewpoint(extent));
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().Name);
}
}
... View more
09-26-2017
12:57 PM
|
2
|
4
|
3088
|
|
POST
|
Sure that will be helpful, thanks! We will investigate, it sounds like a different issue then.
... View more
09-25-2017
09:16 AM
|
0
|
6
|
3088
|
|
POST
|
Hi Chad, The workflow you mentioned, consuming runtime content from ArcMap, should have also worked. I just checked that the issue Nagma referenced had something to do with related tables not participating in the same map which is why no related features were returned. This is a requirement per https://developers.arcgis.com/net/latest/wpf/api-reference//html/M_Esri_ArcGISRuntime_Data_ArcGISFeatureTable_QueryRelatedFeaturesAsync.htm. Are your related tables all part of the same map? Thanks.
... View more
09-22-2017
02:55 PM
|
0
|
8
|
3088
|
|
POST
|
Hi, I'm sorry for the delay in reply. The IReadOnlyList<RelatedFeatureQueryResult>, result object from awaiting QueryRelatedFeaturesAsync, is a collection of iterator of features. In any platform, you can do something like this to access the related features and their attributes. In the original sample Result is a TreeView and individual template binds to table name and feature attributes. var queryResults = await table.QueryRelatedFeaturesAsync(feature);
var resultCollection = queryResults.ToArray();
foreach (var queryResult in resultCollection)
{
foreach(var f in queryResult)
{
var sft = (ServiceFeatureTable)f.FeatureTable;
var id = (long)f.Attributes[sft.ObjectIdField];
}
}
... View more
09-20-2017
11:02 AM
|
0
|
15
|
5552
|
|
POST
|
I think you can use GeometryEngine methods then to see if your selection rectangle intersects with the graphic geometries. private async void OnSelect(object sender, RoutedEventArgs e)
{
try
{
var rectangle = await MyMapView.SketchEditor.StartAsync(SketchCreationMode.Rectangle, false);
foreach (var overlay in MyMapView.GraphicsOverlays)
{
foreach (var graphic in overlay.Graphics)
graphic.IsSelected = GeometryEngine.Intersects(graphic.Geometry, rectangle);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().Name);
}
}
... View more
09-08-2017
12:14 PM
|
0
|
2
|
2708
|
|
POST
|
As Joe already mentioned, FeatureLayer popup can be configured on the web map. But you can also configure it in the client. For example, try the following code (see current value of popup): MyMapView.Map = new Map(new Uri("https://www.arcgis.com/home/webmap/viewer.html?webmap=ff0e158ffb184e41b8cea71ebda3eb67"));
MyMapView.LayerViewStateChanged += (s, e) =>
{
if (e.Layer is FeatureLayer && e.LayerViewState.Status == LayerViewStatus.Active)
{
var popup = ((FeatureLayer)e.Layer).PopupDefinition;
}
};
}
private void OnLoad(object sender, RoutedEventArgs e)
{
var layer = new FeatureLayer(new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/0"));
layer.PopupDefinition = new PopupDefinition() { Title = "My Title" };
layer.PopupDefinition.Fields.Add(new PopupField() { Label = "description", FieldName = "description ", IsEditable = true, IsVisible = true, StringFieldOption = PopupStringFieldOption.SingleLine });
MyMapView.Map.OperationalLayers.Add(layer);
}
... View more
09-08-2017
12:01 PM
|
1
|
1
|
2643
|
|
POST
|
The v100.x equivalent for this method is IdentifyGraphicsOverlayAsync providing a tolerance parameter will create the rectangle with this height and width, you can also provide the number of maximum results you want returned. There's also an overload for identifying all graphics overlays versus this one where hit test (or identify) will be done on specified graphics overlay only.
... View more
09-08-2017
11:42 AM
|
0
|
4
|
2708
|
|
POST
|
Oh I see, sorry I misunderstood. Rotate with scale cannot keep the rectangle shape but you can probably add your logic in SketchEditor.GeometryChanged event handler, perhaps? You have access to e.NewGeometry then and can do a check whether it's still rectangle shape and maybe call SketchEditor.ReplaceGeometry with the closest rectangle shape. I am not sure if there are any GeometryEngine methods (if any) that can help with those calculations, but I hope that helps. MyMapView.SketchEditor.GeometryChanged += SketchEditor_GeometryChanged;
}
private void SketchEditor_GeometryChanged(object sender, GeometryChangedEventArgs e)
{
var geometry = e.NewGeometry;
if(!IsRectangle(geometry))
MyMapView.SketchEditor.ReplaceGeometry(ToRectangle(geometry));
}
... View more
09-08-2017
11:28 AM
|
0
|
0
|
1698
|
|
POST
|
You can pass SketchEditConfiguration to SketchEditor.StartAsync. Without this optional parameter, sketch editor will enable/disable certain editing capabilities based on the SketchCreationMode or geometry. While you've created a rectangle shape, it's still treated according to its type (Polygon) so all vertex editing and rotate which you may not want for your rectangle shape will be enabled by default. xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
<Grid>
<esri:MapView x:Name="MyMapView" GeoViewTapped="MyMapView_GeoViewTapped" />
<StackPanel VerticalAlignment="Top"
HorizontalAlignment="Right">
<Button Content="Draw"
Click="OnDraw" />
<Button Content="Complete"
Command="{Binding ElementName=MyMapView, Path=SketchEditor.CompleteCommand}" />
</StackPanel>
</Grid> public MainWindow()
{
InitializeComponent();
MyMapView.Map = new Map(Basemap.CreateTopographic());
MyMapView.GraphicsOverlays.Add(new GraphicsOverlay() { Renderer = new SimpleRenderer(new SimpleFillSymbol(SimpleFillSymbolStyle.Cross, Colors.DarkGreen, null)) });
}
private async void OnDraw(object sender, RoutedEventArgs e)
{
try
{
var config = new SketchEditConfiguration()
{
AllowRotate = false,
AllowMove = false,
AllowVertexEditing = false,
ResizeMode = SketchResizeMode.Stretch
};
var geometry = await MyMapView.SketchEditor.StartAsync(SketchCreationMode.Rectangle, config);
MyMapView.GraphicsOverlays.FirstOrDefault()?.Graphics?.Add(new Graphic(geometry));
}
catch (TaskCanceledException) { }
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().Name);
}
}
private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
{
Graphic graphic = null;
try
{
if (MyMapView.SketchEditor.CancelCommand.CanExecute(null))
return;
var result = await MyMapView.IdentifyGraphicsOverlaysAsync(e.Position, 2, false);
graphic = result.FirstOrDefault()?.Graphics?.FirstOrDefault();
if (graphic == null)
return;
graphic.IsVisible = false;
var config = new SketchEditConfiguration()
{
AllowRotate = false,
AllowMove = false,
AllowVertexEditing = false,
ResizeMode = SketchResizeMode.Stretch
};
var geometry = await MyMapView.SketchEditor.StartAsync(graphic.Geometry, SketchCreationMode.Rectangle, config);
graphic.Geometry = geometry;
}
catch (TaskCanceledException) { }
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().Name);
}
finally
{
if (graphic != null)
graphic.IsVisible = true;
}
}
... View more
09-08-2017
10:07 AM
|
1
|
0
|
1698
|
|
POST
|
It is an intentional change for v100+. Were there specific binding scenarios that you're unable to do now? If yes, please share so we can try and accommodate in the future. Meanwhile, you can try the following code. You should still be able to do binding to Layer properties. xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
<Grid>
<esri:MapView x:Name="MyMapView" />
<StackPanel VerticalAlignment="Top"
HorizontalAlignment="Right">
<ItemsControl ItemsSource="{Binding ElementName=MyMapView, Path=Map.AllLayers}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition MinWidth="50" />
</Grid.ColumnDefinitions>
<CheckBox IsChecked="{Binding IsVisible, Mode=TwoWay}"
Content="{Binding Name}" />
<Slider Value="{Binding Opacity, Mode=TwoWay}"
Minimum="0"
Maximum="1"
Grid.Column="1"/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</Grid> public MainWindow()
{
InitializeComponent();
MyMapView.Map = new Map(Basemap.CreateTopographic());
MyMapView.Map.OperationalLayers.Add(new ArcGISMapImageLayer(new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer")));
MyMapView.Map.OperationalLayers.Add(new FeatureLayer(new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/0")) { Name = "Wildfire" });
}
... View more
09-08-2017
09:42 AM
|
0
|
1
|
2532
|
|
POST
|
The following code works for me, `T` here is just a png with BuildAction=Embedded Resource. `Forum` was my project namespace. I think the reason it didn't work for you is because you have a PictureFillSymbol for MapPoint geometry. Did you mean to use PictureMarkerSymbol then? MyMapView.Map = new Map(Basemap.CreateTopographic());
MyMapView.GraphicsOverlays.Add(new GraphicsOverlay());
MyMapView.GeoViewTapped += async (s, e) =>
{
var overlay = MyMapView.GraphicsOverlays.FirstOrDefault();
var resourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Forum.T.png");
var runtimeimage = await RuntimeImage.FromStreamAsync(resourceStream);
overlay.Graphics.Add(new Graphic(GeometryEngine.Buffer(e.Location, 1000), new PictureFillSymbol(runtimeimage)));
MyMapView.SetViewpoint(new Viewpoint(overlay.Extent));
};
... View more
09-07-2017
05:19 PM
|
0
|
1
|
1530
|
|
POST
|
`GeoViewTapped` is the correct event. `CreateFeature`, `AddFeatureAsync`, and `ApplyEditsAsync` are all the right methods. Are you getting any error message from `ApplyEditsAsync`? I'm curious why you don't add the layer to your map before creating and adding the feature. You can try the following sample code. When layer is added to the map, the map will load the layer and the layer will load the table, so you won't need to explicitly call `LoadAsync`. public MainWindow()
{
InitializeComponent();
MyMapView.GeoViewTapped += MyMapView_GeoViewTapped;
MyMapView.Map = new Map(Basemap.CreateTopographic());
MyMapView.Map.OperationalLayers.Add(new FeatureLayer(new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Notes/FeatureServer/0")));
}
private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
{
try
{
var layer = MyMapView.Map.OperationalLayers.FirstOrDefault() as FeatureLayer;
var table = layer.FeatureTable as ServiceFeatureTable;
var template = table.FeatureTemplates.FirstOrDefault() ?? table.FeatureTypes.FirstOrDefault(t => t.Templates.Any()).Templates.FirstOrDefault();
var feature = table.CreateFeature(template);
feature.Geometry = e.Location;
await table.AddFeatureAsync(feature);
var edits = await table.ApplyEditsAsync();
var editResult = edits.FirstOrDefault(r => r is FeatureEditResult && r.CompletedWithErrors || r.Error != null);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().Name);
}
}
... View more
08-07-2017
10:11 AM
|
1
|
2
|
2060
|
|
POST
|
You can check for `CanEditAttachments` to know if you're able to add/update/delete attachments for the specified feature. You can also check the result of `ApplyEditsAsync` to know whether any of the edit operation failed. if (feature.CanEditAttachments)
await feature.AddAttachmentAsync("test.png", "image/png", bytes);
var table = layer.FeatureTable as ServiceFeatureTable;
var edits = await table.ApplyEditsAsync();
var editResult = edits.FirstOrDefault(r => r is FeatureEditResult && ((FeatureEditResult)r).AttachmentResults.FirstOrDefault(ar => ar.CompletedWithErrors || ar.Error != null) != null) as FeatureEditResult;
In your code, is ` App._file.Name` full file name including path? This should be file name with extension. And the `contentType` parameter should be one of the MIME types that your server support. (i.e. image/png, text/plain, etc.)
... View more
08-07-2017
09:52 AM
|
1
|
1
|
2410
|
|
POST
|
AddVertex and DeleteVertex commands can be activated using buttons just like Undo/Redo/Cancel/Complete commands. They are only enabled for Polyline/Polygon geometries though with provided CommandParameter. DeleteVertex will act on selected vertex (red highlight) and/or given index. <Button Content="Undo"
Command="{Binding ElementName=MyMapView, Path=Editor.Undo}" />
<Button Content="Redo"
Command="{Binding ElementName=MyMapView, Path=Editor.Redo}" />
<Button Content="Delete"
Command="{Binding ElementName=MyMapView, Path=Editor.DeleteVertex}" />
<Button Content="Add"
Command="{Binding ElementName=MyMapView, Path=Editor.AddVertex}" />
<Button Content="Cancel"
Command="{Binding ElementName=MyMapView, Path=Editor.Cancel}" />
<Button Content="Complete"
Command="{Binding ElementName=MyMapView, Path=Editor.Complete}" /> Programmatically, you can invoke them using the following code: // `mapPoint` will be added after selected vertex
if (MyMapView.Editor.AddVertex.CanExecute(mapPoint))
MyMapView.Editor.AddVertex.Execute(mapPoint);
// `index` to delete specific vertex or
// `null` to delete selected vertex
if (MyMapView.Editor.DeleteVertex.CanExecute(index))
MyMapView.Editor.DeleteVertex.Execute(index); You may also use Polyline/PolygonBuilder which also has methods for Add/RemovePoint.
... View more
08-07-2017
09:26 AM
|
0
|
1
|
2828
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | a month ago | |
| 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 |
| Online Status |
Offline
|
| Date Last Visited |
4 weeks ago
|