void trackOverlay_TrackEnded (object sender, TrackEndedTrackInteractiveOverlayEventArgs e) { InMemoryFeatureLayer memLayer = new InMemoryFeatureLayer(); if (wpfMap1.TrackOverlay.TrackMode == TrackMode.Polygon) { PolygonShape polygonShape = (PolygonShape)e.TrackShape; memLayer.InternalFeatures.Add(new Feature(polygonShape)); MessageBox.Show("The polygone is saved in memory!"); } else MessageBox.Show("The line zone is not saved!"); LayerOverlay inmemoryOverlay = new LayerOverlay(); inmemoryOverlay.Layers.Add("PolyLayer", memLayer); wpfMap1.Overlays.Add("PolyLayer", inmemoryOverlay); } private void btnSaveZones_Click(object sender, RoutedEventArgs e) { polygfts = polygLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns); if (wpfMap1.TrackOverlay.TrackMode == TrackMode.Polygon) FeatureLayer polyArea = wpfMap1.FindFeatureLayer( "PolyLayer"); if (polyArea != null ) { CovertPolygonLayerToZones(zoneDef, polyArea); MessageBox.Show("Polygon Processing Done." ); } else MessageBox.Show("Polygon Processing cannot be Done." ); } private void CovertPolygonLayerToZones(PolygonZone zoneDef, FeatureLayer polygLayer) // version 1 { int fcount = wpfMap1.TrackOverlay.TrackShapeLayer.InternalFeatures.Count; polygLayer.FeatureSource.Open(); IEnumerable allPolygons = polygLayer.FeatureSource .GetAllFeatures(ReturningColumnsType.AllColumns) .OfType (); MultipolygonShape mpolyg = new MultipolygonShape(allPolygons); // nothing found in mpolyg, Collection polyg= mpolyg.Polygons; for (int i=0;i vtxs=polyg[i].OuterRing.Vertices; // this caused "Index was out of range" runtime problem } catch (Exception e) { MessageBox.Show(ex.ToString(),"Exception"); } } } private void ConvertPolygonLayerToZones(PolygonZone zoneDef, FeatureLayer polygLayer) // version 2 { int fcount = wpfMap1.TrackOverlay.TrackShapeLayer.InternalFeatures.Count; wpfMap1.TrackOverlay.TrackShapeLayer.FeatureSource.Open(); IEnumerable allPolygons = wpfMap1.TrackOverlay.TrackShapeLayer.FeatureSource .GetAllFeatures(ReturningColumnsType.AllColumns).OfType(); MultipolygonShape mpolyg = new MultipolygonShape(allPolygons); // nothing found in mpolyg, Collection polyg= mpolyg.Polygons; for (int i=0;i vtxs=polyg[i].OuterRing.Vertices; // this caused "Index was out of range" runtime problem } catch (Exception e) { MessageBox.Show(ex.ToString(),"Exception"); } } } // The save button is clicked to save the polygon drawn on the map. // I have tried version 1 and version 2 of the method but same exception happens. It seems that the multipolygonshape // instance doesn't contain any info on the polygon drawn on the map, which is supposed to be // captured either by my trackOverlay_TrackEnded method or captured internally by ThinkGeo TrackShapeLayer. // Please point out mistakes in the code and indicate the corrections accordingly. Thanks.