Is there any example for adding features with GeometryTyp polygon in combination with SketchEditor?
I studied this example with GeometryTyp point: Add features (Feature Service) | ArcGIS for Developers , but I've not found a comparable example for GeometryTyp polygon.
Solved! Go to Solution.
Hi again,
Polygon inherits from Geometry so you can cast your geometry to a polygon once you're happy it is a polygon. Use code looking something like:
if (sketchGeometry.getGeometryType() == GeometryType.POLYGON) { Polygon polygon = (Polygon) sketchGeometry; }
or
if (sketchGeometry instanceof Polygon) { Polygon polygon = (Polygon) sketchGeometry; }
Hope this helps!
Trevor
Thank you very much for your reply, but how can I convert the sketchGeometry to a Polygon to save it in a FeatureLayer?
Geometry sketchGeometry = mSketchEditor.getGeometry();
Hi again,
Polygon inherits from Geometry so you can cast your geometry to a polygon once you're happy it is a polygon. Use code looking something like:
if (sketchGeometry.getGeometryType() == GeometryType.POLYGON) { Polygon polygon = (Polygon) sketchGeometry; }
or
if (sketchGeometry instanceof Polygon) { Polygon polygon = (Polygon) sketchGeometry; }
Hope this helps!
Trevor
Thank you very much! It's solved.
How to fix this problem?