Command AddVertex

4907
12
11-12-2014 12:41 AM
JonasLeksell
New Contributor II

Hi All,

We are trying to use the
command AddVertex to edit existing polygons and like to add this using XAML
code: e.g. <Button Content="Add Vertex" Command="{Binding
AddVertex}" CommandParameter="{Binding GPSPosition}" … /> where
GPSPosition is a function in the code behind. However using the command
parameter with the gps function or not we seem not to be able to get this
button to activate when editing.

Has anyone looked at this
Before and have a solution on this? Or know if we are addressing this the wrong way?

Tags (1)
0 Kudos
12 Replies
MartinBrzezinka
New Contributor

Thank you for your answer.


Yes, the geometry is being edited on the map. The workflow in both cases is as follows:

User has a map in one layer, user drawn lines and polygons in another.

User selects a line or polygon to INTERACTIVELLY edit it with mouse or touch.

This triggers a call to async MapView.Editor.EditGeometryAsync(geometry);
Buttons connected to MapView.Editor's ICommands are being enabled and disabled automatically.

This works fine for all graphics and all buttons (ICommands),
EXCEPT for just AddVertex on existing lines/polygons being edited.

image026.jpg

Our editing is done by calling an asyncronous method EditGeometryAsync

so I don't really see how do we jack in the PolygonBuilder there?

Our AddVertex button adds a GPS position which is just a regular MapPoint.

And as I said, it's working fine when drawing a new line or polygon.

But when editing an existing one, the AddVertex button won't ever get enabled.

This seems to be due to a limitation inside the Editor
depending on which EditorMode is on, Draw or EditGraphic.

Second question remains:

how do we tell the Editor where to add the new point when editing interactivelly?
User selects a node in a line or polygon.
User needs to INTERACTIVELLY (by clicking on AddVertex button)

add the new point after that selected node,
not at the end of the line as it is by default.

I can see that here we could use the PolygonBuilder to add a point where we want to.
The trouble is that property Editor.VertexPosition which I understand holds the highlighted node, is private.
Problem #2 is that at the same time, user needs to be able to

interactivelly edit the line, i.e. drag nodes with mouse

so we must use the asynchronous method and leave control over to the Editor, don't we?

0 Kudos
AnttiKajanus1
Occasional Contributor III

I had finally time to check this today.

In case one, it's true that AddVertex is not available on when editing existing geometry. Currently there is no easy way to say for the editor that add new vertex after selected one while Editor is active so I created new issue for that.

If you are doing editing, you can get vertex position reported back from the editor using following code but I'm not sure if that helps in this case.

Progress<GeometryEditStatus> progress = new Progress<GeometryEditStatus>();
progress.ProgressChanged += progress_ProgressChanged;
...
var geometry = await MyMapView.Editor.EditGeometryAsync(feature.Geometry, null, progress);

private void progress_ProgressChanged(object sender, GeometryEditStatus e)
{
     // do stuff
}
MartinBrzezinka
New Contributor

Thank you Antti,

I look forward to get this fixed in the next release.

0 Kudos