Hi Yale,
I have no problem in saving and displaying the saved polyzon as shown in the following code. My problem is: after showing the saved polygon, i cannot apply the "Track&Edit Shape" functionality of MapSuite 4.0 to edit the polygon.Could you tell me which statement should be added in the t label1_Click below to achieve the edit goal?
Thanks a lot for your guidance.
Franklin
void trackOverlay_TrackEnded(object sender, TrackEndedTrackInteractiveOverlayEventArgs e)
{
PolygonShape polygonShape = (PolygonShape)e.TrackShape;
Collection<dbfcolumn></dbfcolumn> dbfColumns = new Collection<dbfcolumn></dbfcolumn>();
dbfColumns.Add(new DbfColumn("POLYID", DbfColumnType.String, 10, 0));
dbfColumns.Add(new DbfColumn("NAME", DbfColumnType.String, 10, 0));
Feature editFeature = new Feature((PolygonShape)e.TrackShape); // I am not sure how to do this properly.
editFeature.ColumnValues.Add("Name", "Yale"); // as suggested
ShapeFileFeatureLayer.CreateShapeFile(ShapeFileType.Polygon, @"C:\testOnload\testLoad.shp", dbfColumns, Encoding.UTF8, OverwriteMode.DoNotOverwrite);
ShapeFileFeatureLayer shapeFileFetureLayer = new ShapeFileFeatureLayer(@"C:\testOnload\testLoad.shp", ShapeFileReadWriteMode.ReadWrite);
try
{
shapeFileFetureLayer.Open();
shapeFileFetureLayer.EditTools.BeginTransaction();
shapeFileFetureLayer.EditTools.Add(polygonShape);
TransactionResult result = shapeFileFetureLayer.EditTools.CommitTransaction();
}
finally
{
shapeFileFetureLayer.Close();
}
}
// The code below is used to display the saved shape.
private void label1_Click(object sender, EventArgs e)
{
winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"C:\testOnload\testLoad.shp");
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(100, GeoColor.SimpleColors.Black));
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
LayerOverlay layerOverlay = new LayerOverlay();
// Add the shapefile layer to the layer overlay
layerOverlay.Layers.Add(worldLayer);
winformsMap1.Overlays.Add(layerOverlay);
winformsMap1.Refresh();
}