I'm looking for an example of creating a LineShape using the following constructor:
LineShape Constructor(Generic IEnumerable)
I'm hoping that I can pass in a collection of vertices and have a multi-point LineShape created. I can't get it to work, so I either don't understand this constructor or I've got more issues.
Pulling relevant parts of the code (and somewhat simplifying):
I like the second option for my case, but I’m getting an exception that I don’t understand. I tried searching the forum for the error message, but I keep getting a forum error. :D
“The given key was not present in the dictionary.”
I believe this is happening at the layer refresh call.
Is there something obvious that this usually means?
I also cannot reproduce your problem exactly, here is my code below:
private void button1_Click(object sender, EventArgs e) { Collection<Vertex> verteices1 = new Collection<Vertex>(); verteices1.Add(new Vertex(0.2, 0.5)); verteices1.Add(new Vertex(0.8, 60.2)); verteices1.Add(new Vertex(1.8, 70.1)); LineShape lineShape2 = new LineShape(verteices1); Feature feature = new Feature(lineShape2); InMemoryFeatureLayer inMemoryLayer = new InMemoryFeatureLayer(); inMemoryLayer.InternalFeatures.Add("Test", feature); inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.FromArgb(100, GeoColor.StandardColors.RoyalBlue); inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color = GeoColor.StandardColors.Blue; inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.OuterPen = new GeoPen(GeoColor.FromArgb(200, GeoColor.StandardColors.Red), 5); inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.SymbolPen = new GeoPen(GeoColor.FromArgb(255, GeoColor.StandardColors.Green), 8); inMemoryLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
LayerOverlay staticOverlay = new LayerOverlay(); staticOverlay.Layers.Add("InMemoryFeatureLayer", inMemoryLayer); winformsMap1.Overlays.Add(staticOverlay); winformsMap1.CurrentExtent = new RectangleShape(0, 100, 100, 0); winformsMap1.Refresh(); }
According to my test, it can work fine, I cannot find out any exceptions, please review your code or send us your sample so that we can reproduce this problem exactly,