GeometryEditorToolbar - Add example#1450
Conversation
…ditorToolbar-Example
…ditorToolbar-Example
There was a problem hiding this comment.
Pull request overview
Adds a new Toolkit Examples app sample demonstrating how to use the new GeometryEditorToolbar component to edit existing point/line/polygon features in a web map.
Changes:
- Registers a new “Geometry Editor Toolbar” entry in the Examples list.
- Introduces
GeometryEditorToolbarExampleView, which identifies a tapped feature, starts aGeometryEditorwith its geometry, and overlaysGeometryEditorToolbarplus Save/Cancel controls. - Updates the Examples Xcode project to include the new source file.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Examples/ExamplesApp/Examples.swift | Adds the new example to the examples list. |
| Examples/Examples/GeometryEditorToolbarExampleView.swift | New SwiftUI example view showcasing GeometryEditorToolbar with identify + edit + save/cancel flow. |
| Examples/Examples.xcodeproj/project.pbxproj | Adds the new example file to the project and build sources. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| featureBeingEdited?.setVisible(true) | ||
| featureBeingEdited = nil |
There was a problem hiding this comment.
if let feature = featureBeingEdited.take() {
feature.setVisible(true)
}take it or leave it ;-)
| do { | ||
| try await saveEdits() | ||
| } catch { | ||
| self.errorDescription = "\(error)" |
There was a problem hiding this comment.
| self.errorDescription = "\(error)" | |
| errorDescription = "\(error)" |
| featureBeingEdited = feature | ||
| } | ||
|
|
||
| /// Saves the geometry editor edits to the feature being edited. |
There was a problem hiding this comment.
Maybe add a note to explain that the edits aren't applied to the feature service, and is only saved to the local feature table.
| featureBeingEdited.setVisible(true) | ||
| self.featureBeingEdited = nil |
There was a problem hiding this comment.
Should the featureBeingEdited becomes visible and the cache cleaned up after the featuretable.update succeeds?
| featureBeingEdited.setVisible(true) | ||
| self.featureBeingEdited = nil | ||
|
|
||
| try await featureBeingEdited.table?.update(featureBeingEdited) |
There was a problem hiding this comment.
Guard the table as well, so no need optional chaining.
rolson
left a comment
There was a problem hiding this comment.
Looks good. Did you consider building out a simple measure line or area experience instead of a feature editing experience? I wonder if that would simplify the code a bit and also allow the example to not depend on maintaining a feature service.
@rolson I didn't! My only thoughts against that is the current example represents a more common workflow, and it demonstrates that edit saving/discarding needs to happen at the app level. It would likely simplify the code, though, and I don't feel too strongly about it. Would you like me to go with the measure idea instead? |
I think it might be something to ask @dg0yal about. I'm ok either way, but not having to maintain a new service might be nice. |
I discussed this with Ryan and Divesh, and it was recommended to go with a simpler workflow, so I am closing this in favor of #1451, which uses the toolbar to create geometries for new graphics, rather than editing features from a feature service. The service will be deleted once it has been determined not to be needed for the upcoming Feature Editor example. Thank you both for your feedback on this! |
Description
This PR adds an example for the new
GeometryEditorToolbarcomponent. I created a new web map for the example (since I couldn't find anything with simple points, lines, and polygons), so let me know if you have any feedback on that as well: Points, Lines, and Polygons.Closes
swift/issues/7407.How To Test
Screenshots