Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Snap geometry edits sample to include geometry guides. #1527

Open
wants to merge 2 commits into
base: v.next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,71 @@
VerticalOptions="Center">
<ScrollView>
<VerticalStackLayout Margin="10">
<Grid ColumnDefinitions="auto,*">
<Label Padding="0,5"
FontAttributes="Bold"
FontSize="14"
Text="Snap settings" />
<Button Grid.Column="1"
Margin="20,0"
Clicked="EnableAllSnapSettingsButton_Click"
HorizontalOptions="End"
Text="Enable all"
VerticalOptions="Center" />
</Grid>
<VerticalStackLayout HeightRequest="130" WidthRequest="250">
<Grid ColumnSpacing="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Grid.Column="0"
Text="Snapping"
VerticalOptions="Center"
WidthRequest="160" />
<Switch Grid.Column="1"
HorizontalOptions="End"
IsToggled="{Binding GeometryEditor.SnapSettings.IsEnabled, Source={x:Reference MyMapView}}"
VerticalOptions="Center" />
</Grid>
<Grid ColumnSpacing="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Grid.Column="0"
Text="Geometry guides"
VerticalOptions="Center"
WidthRequest="160" />
<Switch Grid.Column="1"
HorizontalOptions="End"
IsEnabled="{Binding GeometryEditor.SnapSettings.IsEnabled, Source={x:Reference MyMapView}}"
IsToggled="{Binding GeometryEditor.SnapSettings.IsGeometryGuidesEnabled, Source={x:Reference MyMapView}}"
VerticalOptions="Center" />
</Grid>
<Grid ColumnSpacing="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Grid.Column="0"
Text="Feature snapping"
VerticalOptions="Center"
WidthRequest="160" />
<Switch Grid.Column="1"
HorizontalOptions="End"
IsEnabled="{Binding GeometryEditor.SnapSettings.IsEnabled, Source={x:Reference MyMapView}}"
IsToggled="{Binding GeometryEditor.SnapSettings.IsFeatureSnappingEnabled, Source={x:Reference MyMapView}}"
VerticalOptions="Center" />
</Grid>
</VerticalStackLayout>
<BoxView Margin="0,0,0,5"
HeightRequest="1"
Color="White" />
<Label Padding="0,5"
FontAttributes="Bold"
FontSize="14"
Text="Select snap sources" />
Text="Snap sources" />
<Grid ColumnDefinitions="auto,*">
<Label Grid.Column="0"
Text="Point layers:"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,15 @@ private void ResetFromEditingSession()
_selectedGraphic = null;
}

#region Enable Sources Button Handlers
#region Enable Snapping Button Handlers
// Enable all point layer snap sources.
private void EnableAllSnapSettingsButton_Click(object sender, EventArgs e)
{
_geometryEditor.SnapSettings.IsEnabled = true;
_geometryEditor.SnapSettings.IsGeometryGuidesEnabled = true;
_geometryEditor.SnapSettings.IsFeatureSnappingEnabled = true;
}

// Enable all point layer snap sources.
private void EnableAllPointSnapSourceButton_Click(object sender, EventArgs e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A field worker can create new features by editing and snapping the vertices of a

To create a geometry, press the create button to choose the geometry type you want to create (i.e. points, multipoints, polyline, or polygon) and interactively tap and drag on the map view to create the geometry.

To configure snapping, press the snap settings button to enable or disable snapping and choose which snap sources to snap to.
Snap settings can be configured by enabling and disabling snapping, feature snapping, geometry guides and snap sources.

To interactively snap a vertex to a feature or graphic, ensure that snapping is enabled for the relevant snap source and move the mouse pointer or drag a vertex to nearby an existing feature or graphic. When the pointer is close to that existing geoelement, the edit position will be adjusted to coincide with (or snap to), edges and vertices of its geometry. Tap or release the touch pointer to place the vertex at the snapped location.

Expand All @@ -31,7 +31,8 @@ To save your edits, press the save button.
3. Create a `GeometryEditor` and connect it to the map view.
4. Call `SyncSourceSettings` after the map's operational layers are loaded and the geometry editor has connected to the map view.
5. Set `SnapSettings.IsEnabled` and `SnapSourceSettings.IsEnabled` to true for the `SnapSource` of interest.
6. Start the geometry editor with a `GeometryType`.
6. Toggle geometry guides using `SnapSettings.IsGeometryGuidesEnabled` and feature snapping using `SnapSettings.IsFeatureSnappingEnabled`.
7. Start the geometry editor with a `GeometryType`.

## Relevant API

Expand All @@ -57,6 +58,8 @@ To snap to polygon and polyline layers, the recommended approach is to set the `

Snapping can be used during interactive edits that move existing vertices using the `VertexTool` or `ReticleVertexTool`. It is also supported for adding new vertices for input devices with a hover event (such as a mouse move without a mouse button press). Using the `ReticleVertexTool` to add and move vertices allows users of touch screen devices to clearly see the visual cues for snapping.

Geometry guides are enabled by default when snapping is enabled. These allow for snapping to a point coinciding with, parallel to, perpendicular to or extending an existing geometry.

## Tags

edit, feature, geometry editor, graphics, layers, map, snapping
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading