Hello,
Sorry for my english.
i have a Problem with to draw lines.I have .tif maps with world files. Now I want draw a Track on the map with gps-coordinates. The coordinates come from a Database.
How can I do that?
Draw lines
Marcel,
Thanks for post!
Here is the sample code how to implement it with Map Suite Desktop.
private void ZoomInAndZoomOut_Load(object sender, EventArgs e)
{
// The background world layer
ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"…\SampleData\Data\Countries02.shp");
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
// Add the background layer to map
winformsMap1.StaticOverlay.Layers.Add(“WorldLayer”, worldLayer);
// The gps coordinate you get from your database, to form the track
Collection<Vertex> vertices = new Collection<Vertex>();
vertices.Add(new Vertex(0, 0));
vertices.Add(new Vertex(10, 10));
// …
// Create a feature based on the coordinates you goe
Feature feature = new Feature(new LineShape(vertices));
// Add the track line to an inmemory layer, and set the way how to render it
InMemoryFeatureLayer inMemoryFeatureLayer = new InMemoryFeatureLayer();
inMemoryFeatureLayer.InternalFeatures.Add(feature.Id, feature);
inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.Red, 10, true);
inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
// Add the layer to map
winformsMap1.DynamicOverlay.Layers.Add(inMemoryFeatureLayer);
winformsMap1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);
winformsMap1.CurrentExtent = new RectangleShape(-180.0, 83.0, 180.0, -90.0);
winformsMap1.Refresh();
}
And here is the result.
Ben