Skip to content

GeometryEditorToolbar - Add example#1450

Closed
CalebRas wants to merge 8 commits into
FeatureEditorfrom
Caleb/GeometryEditorToolbar-Example
Closed

GeometryEditorToolbar - Add example#1450
CalebRas wants to merge 8 commits into
FeatureEditorfrom
Caleb/GeometryEditorToolbar-Example

Conversation

@CalebRas

Copy link
Copy Markdown
Collaborator

Description

This PR adds an example for the new GeometryEditorToolbar component. 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

  1. Tap on the map to identify a feature to edit.
  2. Edit the feature's geometry using the geometry editor and the geometry editor toolbar controls.
  3. Use the save and cancel buttons in the system bottom toolbar to finish editing.

Screenshots

Simulator Screenshot - iPhone 17 Pro - 2026-05-22 at 14 06 13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 a GeometryEditor with its geometry, and overlays GeometryEditorToolbar plus 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.

Comment thread Examples/Examples/GeometryEditorToolbarExampleView.swift
Comment thread Examples/Examples/GeometryEditorToolbarExampleView.swift
Comment thread Examples/Examples/GeometryEditorToolbarExampleView.swift
@CalebRas CalebRas requested review from rolson and yo1995 May 22, 2026 22:07
Comment on lines +90 to +91
featureBeingEdited?.setVisible(true)
featureBeingEdited = nil

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

            if let feature = featureBeingEdited.take() {
                feature.setVisible(true)
            }

take it or leave it ;-)

do {
try await saveEdits()
} catch {
self.errorDescription = "\(error)"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.errorDescription = "\(error)"
errorDescription = "\(error)"

featureBeingEdited = feature
}

/// Saves the geometry editor edits to the feature being edited.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +139 to +140
featureBeingEdited.setVisible(true)
self.featureBeingEdited = nil

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guard the table as well, so no need optional chaining.

Comment thread Examples/Examples/GeometryEditorToolbarExampleView.swift

@rolson rolson left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@CalebRas

Copy link
Copy Markdown
Collaborator Author

Did you consider building out a simple measure line or area experience instead of a feature editing experience?

@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?

@rolson

rolson commented May 26, 2026

Copy link
Copy Markdown
Collaborator

Did you consider building out a simple measure line or area experience instead of a feature editing experience?

@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.

@CalebRas

Copy link
Copy Markdown
Collaborator Author

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!

@CalebRas CalebRas closed this May 26, 2026
@CalebRas CalebRas deleted the Caleb/GeometryEditorToolbar-Example branch May 26, 2026 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants