I'm getting this error on my refresh call and can't see where it is coming from:
"The given key was not present in the dictionary"
I've tried to snip out all relevant code here...
Initialization:
// INIT ThinkGeo MapSuite
try {
winformsMap.MapUnit = GeographyUnit.DecimalDegree;
winformsMap.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.DeepOcean);
winformsMap.CenterAt(new PointShape(-76.286, 36.827));
winformsMap.ZoomToScale(winformsMap.ZoomLevelSet.ZoomLevel11.Scale);
worldMapKitRenderLayer = new WorldMapKitRenderLayer(@"D:\data\ThinkGeo\ThinkGeoWorldMapKit");
worldMapKitRenderLayer.LoadLayers();
LayerOverlay worldMapKitRenderLayerOverlay = new LayerOverlay();
worldMapKitRenderLayerOverlay.Layers.Add(worldMapKitRenderLayer);
winformsMap.Overlays.Add(worldMapKitRenderLayerOverlay);
InMemoryFeatureLayer tracksFriendlyInMemoryFeatureLayer = new InMemoryFeatureLayer();
tracksFriendlyInMemoryFeatureLayer.Open();
tracksFriendlyInMemoryFeatureLayer.Columns.Add(new FeatureSourceColumn("Label"));
tracksFriendlyInMemoryFeatureLayer.Close();
tracksFriendlyInMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = new TextStyle("Label", new GeoFont("Verdana", 10, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColor.StandardColors.White));
tracksFriendlyInMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.BestPlacement = true;
tracksFriendlyInMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.PointPlacement = PointPlacement.CenterRight;
tracksFriendlyInMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.HaloPen = new GeoPen(GeoColor.StandardColors.Black, 1); tracksFriendlyInMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.OuterPen = new GeoPen(GeoColor.StandardColors.DarkGreen, 2);
tracksFriendlyInMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(PointSymbolType.Square, new GeoSolidBrush(GeoColor.StandardColors.Green), new GeoPen(GeoColor.StandardColors.DarkGreen, 2), 10);
tracksFriendlyInMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
LayerOverlay tracksFriendlyLayerOverlay = new LayerOverlay();
tracksFriendlyLayerOverlay.Layers.Add(tracksFriendlyInMemoryFeatureLayer);
winformsMap.Overlays.Add("Tracks|Friendly", tracksFriendlyLayerOverlay);
winformsMap.Refresh();
} catch (Exception Exception) {
log.Enqueue("Problem initializing mapping tools: " + Exception.Message);
}
Inside update map timer:
try {
winformsMap.Overlays["Tracks|Friendly"].Lock.EnterWriteLock();
LayerOverlay trackLayerOverlay = (LayerOverlay)winformsMap.Overlays["Tracks|Friendly"];
InMemoryFeatureLayer trackInMemoryFeatureLayer = (InMemoryFeatureLayer)trackLayerOverlay.Layers[0];
trackInMemoryFeatureLayer.InternalFeatures.Clear();
for (int i = 0; i < MAX_TARGETS; i++) {
if (!(hideUnknownTracks && targets<i>.trackClass == trackClassificationEnum.UNKNOWN)) {
if ((targets<i>.timeLapseComms < TARGET_DROP_TIMEOUT && targets<i>.trackStatus == trackStatusEnum.TARGET_ACTIVE) || i == selectedIconTrackIndex) {
Feature feature = new Feature(new PointShape(targets<i>.longitude, targets<i>.latitude));
if (targets<i>.ais.isValid) {
feature.ColumnValues.Add("Label", targets<i>.ais.name);
} else {
feature.ColumnValues.Add("Label", targets<i>.ID);
}
trackInMemoryFeatureLayer.InternalFeatures.Add("Tracks|Friendly|Icon|" + targets<i>.ID, feature);
if (targets<i>.trackHistory.Count > 5) {
feature = new Feature(new LineShape(targets<i>.trackHistory));
trackInMemoryFeatureLayer.InternalFeatures.Add("Tracks|Friendly|Trail|" + targets<i>.ID, feature);
}
}
}
}
} catch (Exception ex) {
log.Enqueue("ERROR: Problem updating track icons. - " + ex.Message);
} finally {
winformsMap.Overlays["Tracks|Friendly"].Lock.ExitWriteLock();
}
winformsMap.Refresh((LayerOverlay)winformsMap.Overlays["Tracks|Friendly"]);
Where trackHistory is a Vertex Collection.
If I comment the "add lineshape feature" line, the code works fine showing tracks from our AIS receiver, otherwise I get the error after building up enough track history.
I know this is a pretty inefficient way to do this, but until I get a better understanding of MapSuite, this is how I can best understand what is going on.