Reference: ESRI's Sketch Example:
Environment: iOS/Swift 3.0+
I notice that no overlays are used in the sketch, which uses the AGSSketchEditor.
However I believe I need the use of a graphics overlay object to display historical sketches.
Hence I've added the following:
private var myPolyLine:AGSPolyline?
private var graphicsOverlay = AGSGraphicsOverlay()
1) Making a copy of the sketch as a 'geometry':
@IBAction func clear() {
self.myPolyLine = self.sketchEditor.geometry!.copy() as? AGSPolyline
self.sketchEditor.clearGeometry()
}
2) Restoring the sketch after 'deleting' it:
case 3: // ...redraw
let lineSymbol = AGSSimpleLineSymbol(style: .solid, color: UIColor.red, width: 3)
self.graphicsOverlay.graphics.add(AGSGraphic(geometry: self.myPolyLine, symbol: lineSymbol, attributes: nil))
self.mapView.graphicsOverlays.add(self.graphicsOverlay)
I needed to create a graphics overlay to display the copy.
I can see the buildup of graphicOverlays.
So once I don't need this copy, I should REMOVE this particular overlay.
That is, each overlay would contain a previously-copied sketch and hence,
I should discard these overlays once not needed. Correct?
As for persistent storage: a AGSPolyline is an NSObject so I could serialize it for storage accordingly.
Is this the correct way for creating a persistent store of a sketch and handling old sketches via removing the overlays?