Does ESRI have the ability to allow free-form drawing (a.k.a. 'doodling') within a layer?
That is, where the user's finger movement is recorded into a path as can be done within iOS's Core Graphics: var simplePath = UIBezierPath() ... etc.?
Scenario: I wish to doodle annotations (drawing) on an overlay and be able to store & recover such doodle.
How would/could that be arranged?
Yes - you can use the AGSSketchEditor with the creation mode of
AGSSketchCreationModeFreehandPolyline or
AGSSketchCreationModeFreehandPolygon.
Here is a sample that is using vertex editing. But change the creation mode to one of the above (ie .freehandPolyline) and you can sketch lines on the map.
Thanks for the quick response!
I'm going to play with this per your directive.
Ric.
1. AGSSketchEditor has a "style" property which has a "feedbackLineSymbol" property. You can set that to whatever line symbol you want. It defaults to a dashed symbol.
2. You can save the resulting geometry, which will be a Polygon or Polyline as JSON. They support AGSJSONSerializable. From there you can store it in user defaults or however you want. And then re-hydrate the geometry from JSON later.
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?
You don't need to copy the geometry, it's immutable.
GraphicsOverlays can be re-used, and you can remove/add graphics from them.