|
POST
|
It looks like you can use AccountStore in Xamarin Forms. You can use AddCredential to set credentials for your app but be sure each credential have their ServiceUri property also set so that Authentication Manager will know to use this credential for the given endpoint.
... View more
08-10-2018
11:16 AM
|
0
|
1
|
1226
|
|
POST
|
In v100.3, SketchEditor was enhanced to show draw feedback, which allows you to see how the geometry will look like before the vertex is committed/inserted as you interactively drag it. Is this what you're looking for? The symbols to update if you don't like this default symbology is FeedbackFill/Line/VertexSymbol in SketchEditor.Style.
... View more
08-10-2018
10:52 AM
|
0
|
4
|
2483
|
|
POST
|
Hi Karin, Thank you for this clarification. It's actually by design that EditConfiguration properties are determined at run-time based on SketchCreationMode parameter. For example, SketchCreationMode.Polygon will enable AllowVertexEditing whereas SketchCreationMode.Point or SketchCreationMode.FreehandPolygon will disable this. You can still overwrite these properties in XAML through binding, or <CheckBox IsChecked="{Binding ElementName=MyMapView, Path=SketchEditor.EditConfiguration.RequireSelectionBeforeDrag, Mode=TwoWay}"
Content="RequireSelectionBeforeDrag"/> in code, after StartAsync var drawTask = MyMapView.SketchEditor.StartAsync(SketchCreationMode.Polygon);
MyMapView.SketchEditor.EditConfiguration.RequireSelectionBeforeDrag = false;
var geometry = await drawTask; However if EditConfiguration is also passed as parameter to StartAsync, we honor the properties set as much as the geometry type or creation mode would allow. You brought up a fair point though that there are EditConfiguration properties like RequireSelectionByDrag that don't necessarily depend on the geometry type or creation mode which we probably should not overwrite. I have logged an issue to address this. Thank you both for your feedback.
... View more
08-10-2018
10:31 AM
|
2
|
0
|
1522
|
|
POST
|
RequireSelectionBeforeDrag=False should allow you to drag the geometry or vertices provided move gesture hit the geometry outline or vertex. Perhaps the difference is that in v10.x, geometry can be moved even if you hit the fill/center of polygon feature. We already have an open design issue to reconsider this behavior.
... View more
08-08-2018
12:39 PM
|
0
|
2
|
1522
|
|
POST
|
We are still working on a toolkit for this but you should be able to do something like this now with v100.3 providing your own UI. In this sample, we use identify to get to the popup and callout to display basic information on the feature. Once info button is clicked, you can have a viewer that binds to PopupManager properties like DisplayedFields. It's still work in progress but something like this for your UI. The relevant code that you should be able to use now are these.. private RuntimeImage PopupImage { get; } = new RuntimeImage(new Uri("pack://application:,,,/Samples/PopupViewer/info.png"));
private async void mapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
{
try
{
var result = await mapView.IdentifyLayersAsync(e.Position, 3, false);
var popup = GetPopup(result);
if(popup != null)
{
if (popup.PopupDefinition != null && !popup.PopupDefinition.ShowEditSummary)
popup.PopupDefinition.ShowEditSummary = true;
var callout = new CalloutDefinition(popup.GeoElement);
callout.Tag = popup;
callout.ButtonImage = PopupImage;
callout.OnButtonClick = new Action<object>((s) =>
{
popupViewer.Visibility = Visibility.Visible;
popupViewer.DataContext = new PopupManager(s as Popup);
});
mapView.ShowCalloutForGeoElement(popup.GeoElement, e.Position, callout);
}
else
{
popupViewer.DataContext = null;
popupViewer.Visibility = Visibility.Collapsed;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().Name);
}
}
private Popup GetPopup(IdentifyLayerResult result)
{
if (result == null)
{
return null;
}
var popup = result.Popups.FirstOrDefault();
if (popup != null)
{
return popup;
}
var geoElement = result.GeoElements.FirstOrDefault();
if (geoElement != null)
{
if (result.LayerContent is IPopupSource)
{
var popupDefinition = ((IPopupSource)result.LayerContent).PopupDefinition;
if (popupDefinition != null)
{
return new Popup(geoElement, popupDefinition);
}
}
return Popup.FromGeoElement(geoElement);
}
return null;
}
private Popup GetPopup(IEnumerable<IdentifyLayerResult> results)
{
if (results == null)
{
return null;
}
foreach (var result in results)
{
var popup = GetPopup(result);
if (popup != null)
{
return popup;
}
foreach (var subResult in result.SublayerResults)
{
popup = GetPopup(subResult);
if (popup != null)
{
return popup;
}
}
}
return null;
} and this, you can certainly improve how you present the fields. <ItemsControl x:Name="popupViewer" ItemsSource="{Binding DisplayedFields}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding Field.Label}" Foreground="Gray" />
<TextBlock Text="{Binding FormattedValue}" TextWrapping="Wrap" Grid.Row="1"/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>x
... View more
08-08-2018
10:12 AM
|
0
|
1
|
901
|
|
POST
|
I tried your code and it works for me. With RequireSelectionBeforeDrag=True (default), you'll need to select the handle for vertex, scale, rotate, geometry outline before you're able to move them. Maybe you're attempting to drag another vertex while the last one is selected? If you expect the handles to move with pointer or touch gesture move, you can set this to property to false so it does not require you to tap on the handle first.
... View more
08-07-2018
11:18 AM
|
1
|
1
|
1357
|
|
POST
|
SketchEditor can also be used for editing existing geometries in a FeatureCollectionLayer. You can look at the following sample. Code below is applicable to other FeatureTable types. However, identify logic here is specific to FeatureCollectionLayer where feature is expected to be part of SubLayerResult. However you get the feature, from an identify or query, you can hide the original feature and pass along its geometry to SketchEditor. When edit is completed, you can update the feature and reset its visibility on the layer. You can either wire up SketchEditor.CompleteCommand or programmatically call SketchEditor.Stop. public MainWindow()
{
InitializeComponent();
var map = new Map(Basemap.CreateTopographic());
var g = new Graphic()
{
Geometry = new Polygon(new MapPoint[] {
new MapPoint(0, 0),
new MapPoint(-1, 0),
new MapPoint(-1, 1),
new MapPoint(0, 1)
}, SpatialReferences.Wgs84),
};
g.Attributes["created"] = DateTimeOffset.UtcNow;
g.Attributes["edited"] = DateTimeOffset.UtcNow;
var table = new FeatureCollectionTable(new[] { g },
new[] { Field.CreateDate("created"), Field.CreateDate("edited") })
{
Renderer = new SimpleRenderer(new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Color.Red, null))
};
var layer = new FeatureCollectionLayer(new FeatureCollection(new[] { table }));
map.OperationalLayers.Add(layer);
MyMapView.Map = map;
MyMapView.GeoViewTapped += OnGeoViewTapped;
MyMapView.GeoViewDoubleTapped += (s, e) =>
{
if (MyMapView.SketchEditor.Geometry != null)
{
e.Handled = true;
MyMapView.SketchEditor.Stop();
}
};
}
private async void OnGeoViewTapped(object sender, GeoViewInputEventArgs e)
{
var result = await MyMapView.IdentifyLayersAsync(e.Position, 2, false);
var layerResult = result?.FirstOrDefault(r => r.SublayerResults.Any(s => s.GeoElements.Any()))?.SublayerResults?.FirstOrDefault(s => s.GeoElements.Any());
var layer = layerResult?.LayerContent as FeatureLayer;
var feature = layerResult?.GeoElements?.FirstOrDefault() as Feature;
var table = feature?.FeatureTable as FeatureCollectionTable;
if (feature?.Geometry == null || table == null || layer == null)
return;
try
{
layer.SetFeatureVisible(feature, false);
var geometry = feature.Geometry;
var project = !MyMapView.SpatialReference.IsEqual(geometry.SpatialReference);
if (project)
{
geometry = GeometryEngine.Project(geometry, MyMapView.SpatialReference);
}
geometry = await MyMapView.SketchEditor.StartAsync(geometry);
if(project)
{
geometry = GeometryEngine.Project(geometry, feature.Geometry.SpatialReference);
}
feature.Geometry = geometry;
feature.Attributes["edited"] = DateTimeOffset.UtcNow;
await table.UpdateFeatureAsync(feature);
}
catch(TaskCanceledException)
{ }
catch(Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().Name);
}
finally
{
if(layer != null && feature != null)
layer.SetFeatureVisible(feature, true);
}
}
... View more
08-06-2018
11:26 AM
|
1
|
3
|
1357
|
|
POST
|
TaskCanceledException is expected when SketchEditor.StartAsync is called while it has not yet completed. Perhaps your edit cancels draw that is also triggered by MouseDown? Where you call SketchEditor.StartAsync, you can surround this with try-catch TaskCanceledException, you can check here SketchEditor properties and possibly determine if you were in the middle of draw or edit? Or perhaps add a check in your MouseDown event handler if SketchEditor is active `if(SketchEditor.Geometry != null) return`. There can only be one active sketch in your MapView, so you can either cancel or suspend one before starting the other; otherwise, the active sketch will be canceled.
... View more
08-06-2018
10:15 AM
|
1
|
0
|
894
|
|
POST
|
Thanks for confirming. I just logged MeasureToolbar bug here. Not having any mode selected, should not have interfered with current SketchEditor. However, the behavior where the measure draw feedback disappears once another SketchEditor becomes active is by design. MapView can only be assigned one SketchEditor at a given time. If you don't want the other SketchEditor draw session to be canceled, you can disable it first and assign to MapView once your draw/edit session is over. You can do this by keeping reference to the current SketchEditor. public MainWindow()
{
InitializeComponent();
_sketchEditor = MyMapView.SketchEditor;
MyMapView.Map = new Map(Basemap.CreateTopographic());
}
private readonly SketchEditor _sketchEditor;
private async void OnDraw(object sender, RoutedEventArgs e)
{
SketchEditor otherSketchEditor = null;
if (MyMapView.SketchEditor != _sketchEditor)
{
otherSketchEditor = MyMapView.SketchEditor;
otherSketchEditor.IsVisible = false;
otherSketchEditor.IsEnabled = false;
MyMapView.SketchEditor = _sketchEditor;
}
try
{
MyMapView.SketchEditor.IsVisible = true;
var geometry = await MyMapView.SketchEditor.StartAsync(SketchCreationMode.Rectangle, false);
var _ = MyMapView.SetViewpointAsync(new Viewpoint(geometry));
}
catch (TaskCanceledException)
{
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().Name);
}
if(otherSketchEditor != null)
{
otherSketchEditor.IsVisible = true;
otherSketchEditor.IsEnabled = true;
MyMapView.SketchEditor = otherSketchEditor;
}
}
... View more
08-02-2018
11:02 AM
|
1
|
1
|
2059
|
|
POST
|
Hi Vijit, I think I know what the problem is now that you mention MeasureToolbar. Can you check and set ` MyMapView.SketchEditor.IsVisible = true;`. The measure toolbar hides active editors when enabled, but this should only happen when a specific mode is selected.
... View more
08-01-2018
11:31 AM
|
1
|
3
|
2059
|
|
POST
|
Can you confirm that commenting out `GraphicsOverlays.Clear()` or replacing this with `RemoveAt` fixes the issue? Thanks. I'm not able to reproduce the bug with v100.3, only in earlier version do I get no draw feedback once I've called GraphicsOverlays.Clear. I wanted to confirm so I can better help you, it might be a different issue you are hitting. public MainWindow()
{
InitializeComponent();
MyMapView.Map = new Map(Basemap.CreateTopographic());
}
private void OnDraw(object sender, RoutedEventArgs e)
{
MyMapView.GraphicsOverlays.Clear();
MyMapView.SketchEditor.StartAsync(SketchCreationMode.Rectangle, false);
}
... View more
08-01-2018
10:42 AM
|
0
|
0
|
459
|
|
POST
|
I see so you're not able to see the rectangle as it is drawn. What version of the api are you using? If it's earlier than v100.3, you might be hitting a bug on clearing GraphicsOverlays where sketch layer also gets removed. If you have in your code `MyMapView.GraphicsOverlays.Clear()`, the workaround is to replace this line with for (var counter = MyMapView.GraphicsOverlays.Count; counter > 0; counter--)
MyMapView.GraphicsOverlays.RemoveAt(counter);
... View more
08-01-2018
10:36 AM
|
0
|
2
|
459
|
|
POST
|
Outside SketchEditor, there already is built-in feature that allows you to zoom-in/out by rectangle. It looks like this and can be used in combination with key press. Shift to zoom-in, Shift+Ctrl to zoom-out. GeoView.ViewpointChanged event will be raised and you can GetCurrentViewpoint then to add target geometry to your map. If you wish to call SetViewpoint yourself like you are doing now and need the geometry result from rectangle sketch to remain on your map, you will need to add this to your GraphicsOverlay. You can use any symbol that matches the type of geometry. Rectangle will be a polygon so any fill symbol will do. public MainWindow()
{
InitializeComponent();
MyMapView.Map = new Map(Basemap.CreateTopographic());
MyMapView.GraphicsOverlays.Add(new GraphicsOverlay());
}
private async void OnTest(object sender, RoutedEventArgs e)
{
try
{
var geometry = await MyMapView.SketchEditor.StartAsync(SketchCreationMode.Rectangle, false);
var overlay = MyMapView.GraphicsOverlays.FirstOrDefault();
if (overlay == null)
return;
var symbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Color.Transparent,
new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 2));
overlay.Graphics.Add(new Graphic(geometry, symbol));
var _ = MyMapView.SetViewpointAsync(new Viewpoint(geometry));
}
catch (TaskCanceledException)
{
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().Name);
}
}
... View more
07-31-2018
11:16 AM
|
0
|
4
|
2059
|
|
POST
|
Thanks for your feedback. We don't assign a name to this GraphicsOverlay but some other characteristics of it is it will always have just one selected graphic which gets added after a successful identify on tapped event. You can use Linq query to get it once then clear Graphics or toggle visibility when MeasureToolbar is no longer active. var overlay = mapView.GraphicsOverlays.FirstOrDefault(o => string.IsNullOrEmpty(o.Id) && o.Graphics.Count == 1 && o.Graphics[0].IsSelected);
overlay?.Graphics?.Clear(); I hope this works for you too. Another way would be to get it once from GraphicsOverlays.CollectionChanged event after GeoViewTapped but perhaps it's better to just use code above. private Task<GraphicsOverlay> GetMeasureResultOverlayAsync()
{
var tcs = new TaskCompletionSource<GraphicsOverlay>();
GraphicsOverlay overlay = null;
EventHandler<GeoViewInputEventArgs> tappedHandler = null;
NotifyCollectionChangedEventHandler collectionChangedHandler = null;
tappedHandler = (s, e) =>
{
if (collectionChangedHandler == null)
{
collectionChangedHandler = (a, b) =>
{
if (overlay == null && b.NewItems?.Count == 1)
{
overlay = b.NewItems[0] as GraphicsOverlay;
if(string.IsNullOrEmpty(overlay.Id) && overlay.Graphics.Count == 1 && overlay.Graphics[0].IsSelected)
{
mapView.GeoViewTapped -= tappedHandler;
mapView.GraphicsOverlays.CollectionChanged -= collectionChangedHandler;
tcs.TrySetResult(overlay);
}
}
};
mapView.GraphicsOverlays.CollectionChanged += collectionChangedHandler;
}
};
mapView.GeoViewTapped += tappedHandler;
return tcs.Task;
}
... View more
07-24-2018
03:50 PM
|
0
|
0
|
747
|
|
POST
|
Hi Paul and Matthew, Thank you for your feedback. I'm able to reproduce the bug and we'll look into getting it fixed in future releases of the API. It appears that GetDataAsync on secured portal item only work in UWP if DefaultChallengeHandler is used (setting OAuth is skipped). The underlying HttpClient is different and EnsureSuccessStatusCode in UWP may throw `Response status code does not indicate success: 400 (Bad Request)`. Apparently it's the Authorization header it doesn't like. You can use the following workaround, meanwhile. Only for UWP, remove authorization header for the GetDataAsync request. #if NETFX_CORE
EventHandler<HttpRequestMessage> handler = (s, e) =>
{
if ((e.Headers?.Authorization?.Scheme == "Bearer") && e.RequestUri.OriginalString.Contains("/data"))
e.Headers.Authorization = null;
};
ArcGISHttpClientHandler.HttpRequestBegin += handler;
#endif
var data = await item.GetDataAsync();
#if NETFX_CORE
ArcGISHttpClientHandler.HttpRequestBegin -= handler;
#endif
... View more
07-11-2018
04:45 PM
|
3
|
4
|
9660
|
| 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
|