Editing and Saving polygons to SQL Server

685
1
02-03-2020 11:43 PM
Labels (1)
DanieBester
New Contributor II

I am using the Sketch on map WPF project - Sketch on map | ArcGIS for Developers 

I added functionality to save polygons to a SQL database (as a Geography spatial type), and redisplay them again on the map. 

The way I am doing this is through the MyMapView_GeoViewTapped. Every time the user clicks the MapView, I record the point (lon & lat). Once they click on Complete, I save the polygon as a Geography object using those points.

After loading these polygons again from the database and displaying them on the map, I want the user to be able to edit them and save the updated polygon to the database.

I thought I could maybe do this through the MyMapView_GeoViewTapped event, as in just update the individual point that was changed, but it doesn't fire when I drag a vertex. So I don't have access to the new point.

I was thinking once the user clicks Complete, I can just access all the points from the MyMapView.SketchEditor.Geometry object, and then save the object with the updated points. If this was possible I wouldn't need even need MyMapView_GeoViewTapped for initial saves. But I noticed that the Geometry object doesn't give me access to all the individual points. 

Is there any way to access all the points of the polygon once the user clicks on Complete? I need all the lon&lat pairs to save the Geography object to the database.

Tags (2)
1 Reply
DanieBester
New Contributor II

I think I will just save the Geometry object as JSON. That will be easier.