ThinkGeo.com    |     Documentation    |     Premium Support

Draw a line programatically

Hello,


Could you provide a code example on how to draw a line programatically using two points?



Steve,


Please see below for an example:


InMemoryFeatureLayer inMemoryLayer1 = new InMemoryFeatureLayer();
            inMemoryLayer1.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = new LineStyle(new GeoPen(GeoColor.SimpleColors.Red));
            inMemoryLayer1.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            Collection<Vertex> vertexes = new Collection<Vertex>();
            vertexes.Add(new Vertex(22.29, -28.68));
            vertexes.Add(new Vertex(30.06, -25.91));


            LineShape lineShape = new LineShape(vertexes);
            inMemoryLayer1.InternalFeatures.Add(new Feature(lineShape));
            winformsMap1.DynamicOverlay.Layers.Add("line", inMemoryLayer1);