public static Map InitializeMap() { //Initialize a new map based on the simple map Map map = new Map(); //Set up countries layer SharpMap.Layers.VectorLayer layCountries = new SharpMap.Layers.VectorLayer("Countries"); //Set the datasource to a shapefile in the App_data folder layCountries.DataSource = new SharpMap.Data.Providers.ShapeFile("GeoData/World/countries.shp", true); //Set fill-style to green layCountries.Style.Fill = new SolidBrush(Color.Green); //Set the polygons to have a black outline layCountries.Style.Outline = System.Drawing.Pens.Black; layCountries.Style.EnableOutline = true; layCountries.SRID = 4326; map.Layers.Add(layCountries); //set up cities layer SharpMap.Layers.VectorLayer layCities = new SharpMap.Layers.VectorLayer("Cities"); //Set the datasource to a shapefile in the App_data folder layCities.DataSource = new SharpMap.Data.Providers.ShapeFile("GeoData/World/cities.shp", true); layCities.Style.SymbolScale = 0.8f; layCities.MaxVisible = 40; layCities.SRID = 4326; map.Layers.Add(layCities); //Set up a country label layer SharpMap.Layers.LabelLayer layLabel = new SharpMap.Layers.LabelLayer("Country labels"); layLabel.DataSource = layCountries.DataSource; layLabel.Enabled = true; layLabel.LabelColumn = "Name"; layLabel.Style = new SharpMap.Styles.LabelStyle(); layLabel.Style.ForeColor = Color.White; layLabel.Style.Font = new Font(FontFamily.GenericSerif, 12); layLabel.Style.BackColor = new System.Drawing.SolidBrush(Color.FromArgb(128, 255, 0, 0)); layLabel.MaxVisible = 90; layLabel.MinVisible = 30; layLabel.Style.HorizontalAlignment = SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Center; layLabel.SRID = 4326; layLabel.MultipartGeometryBehaviour = SharpMap.Layers.LabelLayer.MultipartGeometryBehaviourEnum.Largest; map.Layers.Add(layLabel); //Set up a city label layer SharpMap.Layers.LabelLayer layCityLabel = new SharpMap.Layers.LabelLayer("City labels"); layCityLabel.DataSource = layCities.DataSource; layCityLabel.Enabled = true; layCityLabel.LabelColumn = "Name"; layCityLabel.Style = new SharpMap.Styles.LabelStyle(); layCityLabel.Style.ForeColor = Color.Black; layCityLabel.Style.Font = new Font(FontFamily.GenericSerif, 11); layCityLabel.MaxVisible = layLabel.MinVisible; layCityLabel.Style.HorizontalAlignment = SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Left; layCityLabel.Style.VerticalAlignment = SharpMap.Styles.LabelStyle.VerticalAlignmentEnum.Bottom; layCityLabel.Style.Offset = new PointF(3, 3); layCityLabel.Style.Halo = new Pen(Color.Yellow, 2); layCityLabel.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; layCityLabel.SmoothingMode = SmoothingMode.AntiAlias; layCityLabel.SRID = 4326; layCityLabel.LabelFilter = SharpMap.Rendering.LabelCollisionDetection.ThoroughCollisionDetection; layCityLabel.Style.CollisionDetection = true; map.Layers.Add(layCityLabel); //Set a gradient theme on the countries layer, based on Population density //First create two styles that specify min and max styles //In this case we will just use the default values and override the fill-colors //using a colorblender. If different line-widths, line- and fill-colors where used //in the min and max styles, these would automatically get linearly interpolated. VectorStyle min = new VectorStyle(); VectorStyle max = new VectorStyle(); //Create theme using a density from 0 (min) to 400 (max) GradientTheme popdens = new GradientTheme("PopDens", 0, 400, min, max); //We can make more advanced coloring using the ColorBlend'er. //Setting the FillColorBlend will override any fill-style in the min and max fills. //In this case we just use the predefined Rainbow colorscale popdens.FillColorBlend = SharpMap.Rendering.Thematics.ColorBlend.Rainbow5; layCountries.Theme = popdens; //Lets scale the labels so that big countries have larger texts as well LabelStyle lblMin = new LabelStyle(); LabelStyle lblMax = new LabelStyle(); lblMin.ForeColor = Color.Black; lblMin.Font = new Font(FontFamily.GenericSerif, 6); lblMax.ForeColor = Color.Blue; lblMax.BackColor = new SolidBrush(Color.FromArgb(128, 255, 255, 255)); lblMin.BackColor = lblMax.BackColor; lblMax.Font = new Font(FontFamily.GenericSerif, 9); layLabel.Theme = new GradientTheme("PopDens", 0, 400, lblMin, lblMax); //Lets scale city icons based on city population //cities below 1.000.000 gets the smallest symbol, and cities with more than 5.000.000 the largest symbol VectorStyle citymin = new VectorStyle(); VectorStyle citymax = new VectorStyle(); string iconPath = "Images/icon.png"; if (!File.Exists(iconPath)) { throw new Exception(String.Format("Error file '{0}' could not be found, make sure it is at the expected location", iconPath)); } citymin.Symbol = new Bitmap(iconPath); citymin.SymbolScale = 0.5f; citymax.Symbol = new Bitmap(iconPath); citymax.SymbolScale = 1f; layCities.Theme = new GradientTheme("Population", 1000000, 5000000, citymin, citymax); //limit the zoom to 360 degrees width map.MaximumZoom = 360; map.BackColor = Color.LightBlue; map.Zoom = 30; map.Center = new SharpMap.Geometries.Point(0, 0); return map; }
private static SharpMap.Map InitializeMapOsmWithXls(float angle) { var map = new SharpMap.Map(); var tileLayer = new SharpMap.Layers.TileAsyncLayer(new BruTile.Web.OsmTileSource(), "TileLayer - OSM with XLS"); map.BackgroundLayer.Add(tileLayer); //Get data from excel var xlsPath = string.Format(XlsConnectionString, System.IO.Directory.GetCurrentDirectory(), "GeoData\\Cities.xls"); var ds = new System.Data.DataSet("XLS"); using (var cn = new System.Data.OleDb.OleDbConnection(xlsPath)) { cn.Open(); using (var da = new System.Data.OleDb.OleDbDataAdapter(new System.Data.OleDb.OleDbCommand("SELECT * FROM [Cities$]", cn))) da.Fill(ds); } #if !DotSpatialProjections //The SRS for this datasource is EPSG:4326, therefore we need to transfrom it to OSM projection var ctf = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory(); var cf = new ProjNet.CoordinateSystems.CoordinateSystemFactory(); var epsg4326 = cf.CreateFromWkt("GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]"); var epsg3857 = cf.CreateFromWkt("PROJCS[\"Popular Visualisation CRS / Mercator\", GEOGCS[\"Popular Visualisation CRS\", DATUM[\"Popular Visualisation Datum\", SPHEROID[\"Popular Visualisation Sphere\", 6378137, 0, AUTHORITY[\"EPSG\",\"7059\"]], TOWGS84[0, 0, 0, 0, 0, 0, 0], AUTHORITY[\"EPSG\",\"6055\"]],PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\", \"8901\"]], UNIT[\"degree\", 0.0174532925199433, AUTHORITY[\"EPSG\", \"9102\"]], AXIS[\"E\", EAST], AXIS[\"N\", NORTH], AUTHORITY[\"EPSG\",\"4055\"]], PROJECTION[\"Mercator\"], PARAMETER[\"False_Easting\", 0], PARAMETER[\"False_Northing\", 0], PARAMETER[\"Central_Meridian\", 0], PARAMETER[\"Latitude_of_origin\", 0], UNIT[\"metre\", 1, AUTHORITY[\"EPSG\", \"9001\"]], AXIS[\"East\", EAST], AXIS[\"North\", NORTH], AUTHORITY[\"EPSG\",\"3857\"]]"); var ct = ctf.CreateFromCoordinateSystems(epsg4326, epsg3857); foreach (System.Data.DataRow row in ds.Tables[0].Rows) { if (row["X"] == DBNull.Value || row["Y"] == DBNull.Value) continue; var coords = new[] { Convert.ToDouble(row["X"]), Convert.ToDouble(row["Y"])}; coords = ct.MathTransform.Transform(coords); row["X"] = coords[0]; row["Y"] = coords[1]; } #else var epsg4326 = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984; var epsg3857 = DotSpatial.Projections.ProjectionInfo.FromEsriString("PROJCS[\"Popular Visualisation CRS / Mercator\", GEOGCS[\"Popular Visualisation CRS\", DATUM[\"Popular Visualisation Datum\", SPHEROID[\"Popular Visualisation Sphere\", 6378137, 0, AUTHORITY[\"EPSG\",\"7059\"]], TOWGS84[0, 0, 0, 0, 0, 0, 0], AUTHORITY[\"EPSG\",\"6055\"]],PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\", \"8901\"]], UNIT[\"degree\", 0.0174532925199433, AUTHORITY[\"EPSG\", \"9102\"]], AXIS[\"E\", EAST], AXIS[\"N\", NORTH], AUTHORITY[\"EPSG\",\"4055\"]], PROJECTION[\"Mercator\"], PARAMETER[\"False_Easting\", 0], PARAMETER[\"False_Northing\", 0], PARAMETER[\"Central_Meridian\", 0], PARAMETER[\"Latitude_of_origin\", 0], UNIT[\"metre\", 1, AUTHORITY[\"EPSG\", \"9001\"]], AXIS[\"East\", EAST], AXIS[\"North\", NORTH], AUTHORITY[\"EPSG\",\"3857\"]]"); foreach (System.Data.DataRow row in ds.Tables[0].Rows) { if (row["X"] == DBNull.Value || row["Y"] == DBNull.Value) continue; var coords = new[] { Convert.ToDouble(row["X"]), Convert.ToDouble(row["Y"])}; DotSpatial.Projections.Reproject.ReprojectPoints(coords, null, epsg4326, epsg3857, 0, 1); row["X"] = coords[0]; row["Y"] = coords[1]; } #endif //Add Rotation Column ds.Tables[0].Columns.Add("Rotation", typeof (float)); foreach (System.Data.DataRow row in ds.Tables[0].Rows) row["Rotation"] = -angle; //Set up provider var xlsProvider = new SharpMap.Data.Providers.DataTablePoint(ds.Tables[0], "OID", "X", "Y"); var xlsLayer = new SharpMap.Layers.VectorLayer("XLS", xlsProvider) {Style = {Symbol = SharpMap.Styles.VectorStyle.DefaultSymbol}}; //Add layer to map map.Layers.Add(xlsLayer); var xlsLabelLayer = new SharpMap.Layers.LabelLayer("XLSLabel") { DataSource = xlsProvider, LabelColumn = "Name", PriorityColumn = "Population", Style = { CollisionBuffer = new System.Drawing.SizeF(2f, 2f), CollisionDetection = true }, LabelFilter = SharpMap.Rendering.LabelCollisionDetection.ThoroughCollisionDetection }; map.Layers.Add(xlsLabelLayer); map.ZoomToBox(tileLayer.Envelope); return map; }
public static SharpMap.Map InitializeMap(float angle) { //Initialize a new map of size 'imagesize' SharpMap.Map map = new SharpMap.Map(); //Set up the countries layer SharpMap.Layers.VectorLayer layCountries = new SharpMap.Layers.VectorLayer("Countries"); //Set the datasource to a shapefile in the App_data folder layCountries.DataSource = new SharpMap.Data.Providers.SpatiaLite( DataSource, "countries", "geom", "PK_UID"); //Set fill-style to green layCountries.Style.Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Green); //Set the polygons to have a black outline layCountries.Style.Outline = System.Drawing.Pens.Black; layCountries.Style.EnableOutline = true; //Set up a river layer SharpMap.Layers.VectorLayer layRivers = new SharpMap.Layers.VectorLayer("Rivers"); //Set the datasource to a shapefile in the App_data folder layRivers.DataSource = new SharpMap.Data.Providers.SpatiaLite( DataSource, "rivers", "geom", "PK_UID"); //Define a blue 3px wide pen layRivers.Style.Line = new System.Drawing.Pen(System.Drawing.Color.LightBlue, 2); layRivers.Style.Line.CompoundArray = new[] { 0.2f, 0.8f }; layRivers.Style.Outline = new System.Drawing.Pen(System.Drawing.Color.DarkBlue, 3); layRivers.Style.EnableOutline = true; //Set up a cities layer SharpMap.Layers.VectorLayer layCities = new SharpMap.Layers.VectorLayer("Cities"); //Set the datasource to the spatialite table layCities.DataSource = new SharpMap.Data.Providers.SpatiaLite( DataSource, "cities", "geom", "PK_UID"); layCities.Style.SymbolScale = 0.8f; layCities.MaxVisible = 40; //Set up a country label layer SharpMap.Layers.LabelLayer layLabel = new SharpMap.Layers.LabelLayer("Country labels") { DataSource = layCountries.DataSource, LabelColumn = "NAME", MultipartGeometryBehaviour = SharpMap.Layers.LabelLayer.MultipartGeometryBehaviourEnum.Largest, LabelFilter = SharpMap.Rendering.LabelCollisionDetection.ThoroughCollisionDetection, PriorityColumn = "POPDENS", Style = new SharpMap.Styles.LabelStyle { ForeColor = System.Drawing.Color.White, Font = new System.Drawing.Font(System.Drawing.FontFamily.GenericSerif, 12), BackColor = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(128, 255, 0, 0)), HorizontalAlignment = SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Center, MaxVisible = 90, MinVisible = 30, CollisionDetection = true } }; //Set up a city label layer SharpMap.Layers.LabelLayer layCityLabel = new SharpMap.Layers.LabelLayer("City labels") { DataSource = layCities.DataSource, LabelColumn = "name", PriorityColumn = "population", PriorityDelegate = delegate(SharpMap.Data.FeatureDataRow fdr) { System.Int32 retVal = 10000000 * ( (System.String)fdr["capital"] == "Y" ? 1 : 0 ); return retVal + System.Convert.ToInt32(fdr["population"]); }, TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias, SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias, LabelFilter = SharpMap.Rendering.LabelCollisionDetection.ThoroughCollisionDetection, Style = new SharpMap.Styles.LabelStyle { ForeColor = System.Drawing.Color.Black, Font = new System.Drawing.Font(System.Drawing.FontFamily.GenericSerif, 11), MaxVisible = layLabel.MinVisible, HorizontalAlignment = SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Left, VerticalAlignment = SharpMap.Styles.LabelStyle.VerticalAlignmentEnum.Bottom, Offset = new System.Drawing.PointF(3, 3), Halo = new System.Drawing.Pen(System.Drawing.Color.Yellow, 2), CollisionDetection = true } }; var layRiverLabels = new SharpMap.Layers.LabelLayer("RiverLabels"); layRiverLabels.DataSource = layRivers.DataSource; layRiverLabels.LabelColumn = "Name"; layRiverLabels.PriorityDelegate = GetRiverLength; layRiverLabels.Style = new SharpMap.Styles.LabelStyle { Font = new System.Drawing.Font("Arial", 10, System.Drawing.FontStyle.Bold), Halo = new System.Drawing.Pen(System.Drawing.Color.Azure, 2), ForeColor = System.Drawing.Color.DarkCyan, IgnoreLength = true, Enabled = true, CollisionDetection = true, }; layRiverLabels.LabelFilter = SharpMap.Rendering.LabelCollisionDetection.ThoroughCollisionDetection; //Add the layers to the map object. //The order we add them in are the order they are drawn, so we add the rivers last to put them on top map.Layers.Add(layCountries); map.Layers.Add(layRivers); map.Layers.Add(layCities); map.Layers.Add(layRiverLabels); map.Layers.Add(layLabel); map.Layers.Add(layCityLabel); //limit the zoom to 360 degrees width map.MaximumZoom = 360; map.BackColor = System.Drawing.Color.LightBlue; map.ZoomToExtents(); // = 360; //map.Center = new SharpMap.Geometries.Point(0, 0); var mat = new System.Drawing.Drawing2D.Matrix(); mat.RotateAt(angle, map.WorldToImage(map.Center)); map.MapTransform = mat; return map; }
public static SharpMap.Map InitializeMap(float angle) { //Initialize a new map of size 'imagesize' SharpMap.Map map = new SharpMap.Map(); //Set up the countries layer SharpMap.Layers.VectorLayer layCountries = new SharpMap.Layers.VectorLayer("Countries"); //Set the datasource to a shapefile in the App_data folder layCountries.DataSource = new SharpMap.Data.Providers.PostGIS(Properties.Settings.Default.PostGisConnectionString, "countries", "ogc_fid"); //Set fill-style to green layCountries.Style.Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Green); //Set the polygons to have a black outline layCountries.Style.Outline = System.Drawing.Pens.Black; layCountries.Style.EnableOutline = true; //Set up a river layer SharpMap.Layers.VectorLayer layRivers = new SharpMap.Layers.VectorLayer("Rivers"); //Set the datasource to a shapefile in the App_data folder layRivers.DataSource = new SharpMap.Data.Providers.PostGIS(Properties.Settings.Default.PostGisConnectionString, "rivers", "ogc_fid"); //Define a blue 1px wide pen layRivers.Style.Line = new System.Drawing.Pen(System.Drawing.Color.Blue, 1); //Set up a river layer SharpMap.Layers.VectorLayer layCities = new SharpMap.Layers.VectorLayer("Cities"); //Set the datasource to a shapefile in the App_data folder layCities.DataSource = new SharpMap.Data.Providers.PostGIS(Properties.Settings.Default.PostGisConnectionString, "cities", "ogc_fid"); layCities.Style.SymbolScale = 0.8f; layCities.MaxVisible = 40; //Set up a country label layer SharpMap.Layers.LabelLayer layLabel = new SharpMap.Layers.LabelLayer("Country labels") { DataSource = layCountries.DataSource, Enabled = true, LabelColumn = "Name", MultipartGeometryBehaviour = SharpMap.Layers.LabelLayer.MultipartGeometryBehaviourEnum.Largest, LabelFilter = SharpMap.Rendering.LabelCollisionDetection.ThoroughCollisionDetection, PriorityColumn = "popdens", Style = new SharpMap.Styles.LabelStyle() { ForeColor = System.Drawing.Color.White, Font = new System.Drawing.Font(System.Drawing.FontFamily.GenericSerif, 12), BackColor = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(128, 255, 0, 0)), HorizontalAlignment = SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Center, CollisionDetection = true, MaxVisible = 90, MinVisible = 30 } }; //Set up a city label layer SharpMap.Layers.LabelLayer layCityLabel = new SharpMap.Layers.LabelLayer("City labels") { DataSource = layCities.DataSource, Enabled = true, LabelColumn = "name", PriorityColumn = "population", PriorityDelegate = delegate(SharpMap.Data.FeatureDataRow fdr) { Int32 retVal = 10000000 * (Int32)( (String)fdr["capital"] == "Y" ? 1 : 0 ); return retVal + Convert.ToInt32(fdr["population"]); }, TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias, SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias, LabelFilter = SharpMap.Rendering.LabelCollisionDetection.ThoroughCollisionDetection, Style = new SharpMap.Styles.LabelStyle() { ForeColor = System.Drawing.Color.White, Font = new System.Drawing.Font(System.Drawing.FontFamily.GenericSerif, 11), MaxVisible = layLabel.MinVisible, HorizontalAlignment = SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Left, VerticalAlignment = SharpMap.Styles.LabelStyle.VerticalAlignmentEnum.Bottom, Offset = new System.Drawing.PointF(3, 3), Halo = new System.Drawing.Pen(System.Drawing.Color.Black, 2), CollisionDetection = true } }; //Add the layers to the map object. //The order we add them in are the order they are drawn, so we add the rivers last to put them on top map.Layers.Add(layCountries); map.Layers.Add(layRivers); map.Layers.Add(layCities); map.Layers.Add(layLabel); map.Layers.Add(layCityLabel); //limit the zoom to 360 degrees width map.MaximumZoom = 360; map.BackColor = System.Drawing.Color.LightBlue; map.ZoomToExtents(); // = 360; map.Center = new GeoAPI.Geometries.Coordinate(0, 0); Matrix mat = new Matrix(); mat.RotateAt(angle, map.WorldToImage(map.Center)); map.MapTransform = mat; return map; }
private void LoadParcels(List<PointD> pt, Color color, string labelname) { SharpMap.Map map = new SharpMap.Map(); List<GeoAPI.Geometries.Coordinate> vertices = new List<GeoAPI.Geometries.Coordinate>(); foreach (PointD i in pt) { GeoAPI.Geometries.Coordinate p = new GeoAPI.Geometries.Coordinate(); p.X = i.X; p.Y = i.Y; vertices.Add(p); } GeoAPI.Geometries.Coordinate l = new GeoAPI.Geometries.Coordinate(); l.X = pt[0].X; l.Y = pt[0].Y; vertices.Add(l); //Collection<GeoAPI.Geometries.IGeometry> geom = new Collection<GeoAPI.Geometries.IGeometry>(); GeometryFactory gf = new NetTopologySuite.Geometries.GeometryFactory(); GeoAPI.Geometries.ILinearRing shell = gf.CreateLinearRing(vertices.ToArray()); GeoAPI.Geometries.IPolygon polygon = gf.CreatePolygon(shell, null); SharpMap.Data.Providers.GeometryProvider geomProvider= new SharpMap.Data.Providers.GeometryProvider(polygon); SharpMap.Layers.VectorLayer layerParcels = new SharpMap.Layers.VectorLayer("Parcels"); SharpMap.Styles.VectorStyle style = new SharpMap.Styles.VectorStyle(); style.Fill = new SolidBrush(Color.FromArgb(200,color)); style.Outline = new Pen(new SolidBrush(color)); layerParcels.Style = style; layerParcels.Style.EnableOutline = true; layerParcels.DataSource = geomProvider; layerParcels.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; mapBox1.ActiveTool = SharpMap.Forms.MapBox.Tools.Pan; var fdt = new SharpMap.Data.FeatureDataTable(); fdt.Columns.Add(new System.Data.DataColumn("id", typeof(uint))); fdt.Columns.Add(new System.Data.DataColumn("label", typeof(string))); var fdr = (SharpMap.Data.FeatureDataRow)fdt.NewRow(); fdr.ItemArray = new object[] { 1, labelname }; fdr.Geometry = polygon; fdt.AddRow(fdr); var dataprovider = new SharpMap.Data.Providers.GeometryFeatureProvider(fdt); var ll = new SharpMap.Layers.LabelLayer("llayer"); ll.DataSource = dataprovider; ll.LabelColumn = "label"; ll.Style.Font = new Font("Eurostile Extended", 16,FontStyle.Bold); mapBox1.Map.Layers.Add(layerParcels); mapBox1.Map.Layers.Add(ll); mapBox1.Map.ZoomToExtents(); mapBox1.Refresh(); }
private void LoadLayers() { SharpMap.Layers.VectorLayer layer; LoadDatabaseLayers(); #region Vector Layers // Vector Layers layer = new SharpMap.Layers.VectorLayer("caminos"); layer.DataSource = new SharpMap.Data.Providers.ShapeFile(AppDomain.CurrentDomain.BaseDirectory + "\\data\\mapas\\caminos.shp", true); layer.Style.Line = System.Drawing.Pens.Black; layer.Theme = new SharpMap.Rendering.Thematics.CustomTheme(CaminosStyle); layer.LayerRendered += layer_LayerRendered; //layer.CoordinateTransformation = Transformation; Layers_["caminos"] = layer; layer = new SharpMap.Layers.VectorLayer("canales"); layer.DataSource = new SharpMap.Data.Providers.ShapeFile(AppDomain.CurrentDomain.BaseDirectory + "\\data\\mapas\\canales.shp", true); layer.Style.Line = System.Drawing.Pens.Blue; layer.LayerRendered += layer_LayerRendered; //layer.CoordinateTransformation = Transformation; Layers_["canales"] = layer; layer = new SharpMap.Layers.VectorLayer("drenajes"); layer.DataSource = new SharpMap.Data.Providers.ShapeFile(AppDomain.CurrentDomain.BaseDirectory + "\\data\\mapas\\drenajes.shp", true); layer.Style.Line = System.Drawing.Pens.BlueViolet; layer.LayerRendered += layer_LayerRendered; //layer.CoordinateTransformation = Transformation; Layers_["drenajes"] = layer; layer = new SharpMap.Layers.VectorLayer("jujuy"); layer.DataSource = new SharpMap.Data.Providers.ShapeFile(AppDomain.CurrentDomain.BaseDirectory + "\\data\\mapas\\jujuy.shp", true); layer.Style.Fill = System.Drawing.Brushes.LightYellow; layer.LayerRendered += layer_LayerRendered; //layer.CoordinateTransformation = Transformation; Layers_["jujuy"] = layer; layer = new SharpMap.Layers.VectorLayer("rios"); layer.DataSource = new SharpMap.Data.Providers.ShapeFile(AppDomain.CurrentDomain.BaseDirectory + "\\data\\mapas\\rios.shp", true); layer.Style.Line.Color = System.Drawing.Color.Turquoise; layer.LayerRendered += layer_LayerRendered; //layer.CoordinateTransformation = Transformation; Layers_["rios"] = layer; layer = new SharpMap.Layers.VectorLayer("salta"); layer.DataSource = new SharpMap.Data.Providers.ShapeFile(AppDomain.CurrentDomain.BaseDirectory + "\\data\\mapas\\salta.shp", true); layer.Style.Fill = System.Drawing.Brushes.LightYellow; layer.LayerRendered += layer_LayerRendered; //layer.CoordinateTransformation = Transformation; Layers_["salta"] = layer; layer = new SharpMap.Layers.VectorLayer("Referencias"); layer.DataSource = new SharpMap.Data.Providers.ShapeFile(AppDomain.CurrentDomain.BaseDirectory + "\\data\\mapas\\Referencias.shp", true); layer.Style.Fill = System.Drawing.Brushes.LightYellow; layer.Theme = new SharpMap.Rendering.Thematics.CustomTheme(ReferenciasStyle); layer.LayerRendered += layer_LayerRendered; //layer.CoordinateTransformation = Transformation; Layers_["Referencias"] = layer; #endregion #region Label Layers // Vector Layers SharpMap.Layers.LabelLayer label = new SharpMap.Layers.LabelLayer("LabelCaminos"); label.DataSource = (Layers_["caminos"] as SharpMap.Layers.VectorLayer).DataSource; label.LayerRendered += layer_LayerRendered; label.LabelStringDelegate = GetLabelMethodCaminos; label.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; label.Style.Font = new System.Drawing.Font("Arial", 8); label.Style.ForeColor = System.Drawing.Color.DarkBlue; //layer.CoordinateTransformation = Transformation; Layers_["LabelCaminos"] = label; label = new SharpMap.Layers.LabelLayer("LabelReferencias"); //label = new SharpMap.Layers.LabelLayer("LabelReferencias"); label.DataSource = (Layers_["Referencias"] as SharpMap.Layers.VectorLayer).DataSource; label.LayerRendered += layer_LayerRendered; label.LabelStringDelegate = GetLabelMethodReferencias; label.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; label.Style.Font = new System.Drawing.Font("Arial", 8); label.Style.ForeColor = System.Drawing.Color.Crimson; //label.LabelColumn = "TYPE"; Layers_["LabelReferencias"] = label; #endregion //LoadRasterLayers(); }
private void CreateLayer(System.Data.DataRow row, out SharpMap.Layers.VectorLayer layer, out SharpMap.Layers.LabelLayer labelLayer) { layer = new SharpMap.Layers.VectorLayer(row["CAT_DESCRIPCION"].ToString().Trim()); //labelLayer = new SharpMap.Layers.HtmlLabelLayer("label"+row["CAT_DESCRIPCION"].ToString().Trim()); labelLayer = new SharpMap.Layers.LabelLayer("label" + row["CAT_DESCRIPCION"].ToString().Trim()); string symbolName = GetSymbolName(layer.LayerName); switch (layer.LayerName) { case "Transporte Caña": case "Cañeros": { SharpMap.Data.Providers.MemoryDataProvider<IntelliTrack.Data.TransporteDataPoint> dsource; dsource = new SharpMap.Data.Providers.MemoryDataProvider<IntelliTrack.Data.TransporteDataPoint>(); dsource.LayerName = layer.LayerName; layer.DataSource = dsource; IntelliTrack.Data.TransporteDataPoint.OnEntradaAlFrente += new IntelliTrack.Data.TransporteDataPoint.EntradaAFrente(TransporteDataPoint_OnEntradaAlFrente); IntelliTrack.Data.TransporteDataPoint.OnSalidaAlFrente += new IntelliTrack.Data.TransporteDataPoint.SalidaDeFrente(TransporteDataPoint_OnSalidaAlFrente); //layer.CoordinateTransformation = Transformation; dsource.LoadFromDB(); if (System.Configuration.ConfigurationManager.AppSettings[GetSymbolName("Cañeros")] == "NSEO") layer.Theme = new SharpMap.Rendering.Thematics.CustomTheme(TransporteCañaStyle); else layer.Style = LoadStyle(GetFileNameFromConfig(GetSymbolName("Cañeros"))); if (udpHandler != null) udpHandler.AddDataProvider(layer.LayerName, dsource); SetLabelStyle(labelLayer); labelLayer.LabelStringDelegate = GetLabelMethodTransporteCaña; labelLayer.DataSource = dsource; break; } case "Regadores": { SharpMap.Data.Providers.MemoryDataProvider<IntelliTrack.Data.RegadorDataPoint> dsource; dsource = new SharpMap.Data.Providers.MemoryDataProvider<IntelliTrack.Data.RegadorDataPoint>(); dsource.LayerName = layer.LayerName; layer.DataSource = dsource; //layer.CoordinateTransformation = Transformation; dsource.LoadFromDB(); if (System.Configuration.ConfigurationManager.AppSettings[symbolName] == "NSEO") layer.Theme = new SharpMap.Rendering.Thematics.CustomTheme(RegadoresStyle); else layer.Style = LoadStyle(GetFileNameFromConfig(symbolName)); if (udpHandler != null) udpHandler.AddDataProvider(layer.LayerName, dsource); SetLabelStyle(labelLayer); labelLayer.LabelStringDelegate = GetLabelMethodRegadores; labelLayer.DataSource = dsource; break; } case "Frentes": { SharpMap.Data.Providers.MemoryDataProvider<IntelliTrack.Data.FrenteDataPoint> dsource; dsource = new SharpMap.Data.Providers.MemoryDataProvider<IntelliTrack.Data.FrenteDataPoint>(); dsource.LayerName = layer.LayerName; layer.DataSource = dsource; //layer.CoordinateTransformation = Transformation; if (System.Configuration.ConfigurationManager.AppSettings[symbolName] == "NSEO") layer.Theme = new SharpMap.Rendering.Thematics.CustomTheme(FrentesStyle); else layer.Style = LoadStyle(GetFileNameFromConfig(symbolName)); layer.Style.Line.Color = System.Drawing.Color.DeepSkyBlue; layer.Style.Fill = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(30, System.Drawing.Color.ForestGreen)); dsource.LoadFromDB(); dsource.LoadCoordinatesFromDB(); if (udpHandler != null) udpHandler.AddDataProvider(layer.LayerName, dsource); SetLabelStyle(labelLayer); labelLayer.LabelStringDelegate = GetLabelMethodFrentes; labelLayer.DataSource = dsource; break; } case "Tractores": { SharpMap.Data.Providers.MemoryDataProvider<IntelliTrack.Data.TractoresDataPoint> dsource; dsource = new SharpMap.Data.Providers.MemoryDataProvider<IntelliTrack.Data.TractoresDataPoint>(); dsource.LayerName = layer.LayerName; layer.DataSource = dsource; //layer.CoordinateTransformation = Transformation; dsource.LoadFromDB(); if (System.Configuration.ConfigurationManager.AppSettings[symbolName] == "NSEO") layer.Theme = new SharpMap.Rendering.Thematics.CustomTheme(TractoresStyle); else layer.Style = LoadStyle(GetFileNameFromConfig(symbolName)); if (udpHandler != null) udpHandler.AddDataProvider(layer.LayerName, dsource); SetLabelStyle(labelLayer); labelLayer.LabelStringDelegate = GetLabelMethodTractores; labelLayer.DataSource = dsource; break; } case "Cosechadoras": { SharpMap.Data.Providers.MemoryDataProvider<IntelliTrack.Data.CosechadorasDataPoint> dsource; dsource = new SharpMap.Data.Providers.MemoryDataProvider<IntelliTrack.Data.CosechadorasDataPoint>(); dsource.LayerName = layer.LayerName; layer.DataSource = dsource; //layer.CoordinateTransformation = Transformation; dsource.LoadFromDB(); if (System.Configuration.ConfigurationManager.AppSettings[symbolName] == "NSEO") layer.Theme = new SharpMap.Rendering.Thematics.CustomTheme(CosechadorasStyle); else layer.Style = LoadStyle(GetFileNameFromConfig(symbolName)); if (udpHandler != null) udpHandler.AddDataProvider(layer.LayerName, dsource); SetLabelStyle(labelLayer); labelLayer.LabelStringDelegate = GetLabelMethodCosechadoras; labelLayer.DataSource = dsource; break; } default: { SharpMap.Data.Providers.MemoryDataProvider<IntelliTrack.Data.GenericDataPoint> dsource; dsource = new SharpMap.Data.Providers.MemoryDataProvider<IntelliTrack.Data.GenericDataPoint>(); dsource.LayerName = layer.LayerName; layer.DataSource = dsource; //layer.CoordinateTransformation = Transformation; dsource.LoadFromDB(); if (System.Configuration.ConfigurationManager.AppSettings[symbolName] == "NSEO") layer.Theme = new SharpMap.Rendering.Thematics.CustomTheme(GenericoStyle); else layer.Style = LoadStyle(GetFileNameFromConfig(symbolName)); if (udpHandler != null) udpHandler.AddDataProvider(layer.LayerName, dsource); SetLabelStyle(labelLayer); labelLayer.LabelStringDelegate = GetLabelMethodGenerico; labelLayer.DataSource = dsource; break; } } }
public static SharpMap.Map InitializeMap() { //Initialize a new map of size 'imagesize' SharpMap.Map map = new SharpMap.Map(); //Set up the countries layer SharpMap.Layers.VectorLayer layCountries = new SharpMap.Layers.VectorLayer("Countries"); //Set the datasource to a shapefile in the App_data folder layCountries.DataSource = new SharpMap.Data.Providers.ShapeFile("GeoData/World/countries.shp", true); //Set fill-style to green layCountries.Style.Fill = new SolidBrush(Color.Green); //Set the polygons to have a black outline layCountries.Style.Outline = System.Drawing.Pens.Black; layCountries.Style.EnableOutline = true; layCountries.SRID = 4326; //Set up a river layer SharpMap.Layers.VectorLayer layRivers = new SharpMap.Layers.VectorLayer("Rivers"); //Set the datasource to a shapefile in the App_data folder layRivers.DataSource = new SharpMap.Data.Providers.ShapeFile("GeoData/World/rivers.shp", true); //Define a blue 1px wide pen layRivers.Style.Line = new Pen(Color.Blue, 1); layRivers.SRID = 4326; //Set up a cities layer SharpMap.Layers.VectorLayer layCities = new SharpMap.Layers.VectorLayer("Cities"); //Set the datasource to a shapefile in the App_data folder layCities.DataSource = new SharpMap.Data.Providers.ShapeFile("GeoData/World/cities.shp", true); layCities.Style.SymbolScale = 0.8f; layCities.MaxVisible = 40; layCities.SRID = 4326; //Set up a country label layer SharpMap.Layers.LabelLayer layLabel = new SharpMap.Layers.LabelLayer("Country labels"); layLabel.DataSource = layCountries.DataSource; layLabel.Enabled = true; layLabel.LabelColumn = "Name"; layLabel.Style = new SharpMap.Styles.LabelStyle(); layLabel.Style.ForeColor = Color.White; layLabel.Style.Font = new Font(FontFamily.GenericSerif, 12); layLabel.Style.BackColor = new System.Drawing.SolidBrush(Color.FromArgb(128, 255, 0, 0)); layLabel.MaxVisible = 90; layLabel.MinVisible = 30; layLabel.Style.HorizontalAlignment = SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Center; layLabel.SRID = 4326; layLabel.MultipartGeometryBehaviour = SharpMap.Layers.LabelLayer.MultipartGeometryBehaviourEnum.Largest; //Set up a city label layer SharpMap.Layers.LabelLayer layCityLabel = new SharpMap.Layers.LabelLayer("City labels"); layCityLabel.DataSource = layCities.DataSource; layCityLabel.Enabled = true; layCityLabel.LabelColumn = "Name"; layCityLabel.Style = new SharpMap.Styles.LabelStyle(); layCityLabel.Style.ForeColor = Color.Black; layCityLabel.Style.Font = new Font(FontFamily.GenericSerif, 11); layCityLabel.MaxVisible = layLabel.MinVisible; layCityLabel.Style.HorizontalAlignment = SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Left; layCityLabel.Style.VerticalAlignment = SharpMap.Styles.LabelStyle.VerticalAlignmentEnum.Bottom; layCityLabel.Style.Offset = new PointF(3, 3); layCityLabel.Style.Halo = new Pen(Color.Yellow, 2); layCityLabel.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; layCityLabel.SmoothingMode = SmoothingMode.AntiAlias; layCityLabel.SRID = 4326; layCityLabel.LabelFilter = SharpMap.Rendering.LabelCollisionDetection.ThoroughCollisionDetection; layCityLabel.Style.CollisionDetection = true; //Add the layers to the map object. //The order we add them in are the order they are drawn, so we add the rivers last to put them on top map.Layers.Add(layCountries); map.Layers.Add(layRivers); map.Layers.Add(layCities); map.Layers.Add(layLabel); map.Layers.Add(layCityLabel); //limit the zoom to 360 degrees width map.MaximumZoom = 360; map.BackColor = Color.LightBlue; map.Zoom = 360; map.Center = new SharpMap.Geometries.Point(0, 0); return map; }
public static SharpMap.Map InitializeMap() { //Initialize a new map of size 'imagesize' SharpMap.Map map = new Map(); //Set up the countries layer SharpMap.Layers.VectorLayer layCountries = new SharpMap.Layers.VectorLayer("Countries"); //Set the datasource to a shapefile in the App_data folder try { layCountries.DataSource = new SharpMap.Data.Providers.Ogr("GeoData/MapInfo/countriesMapInfo.tab"); } catch (Exception ex) { if (ex.GetType() == typeof(TypeInitializationException)) throw new Exception(String.Format("The application threw a PINVOKE exception. You probably need to copy the unmanaged dll's to your bin directory. They are a part of fwtools {0}. You can download it from: http://home.gdal.org/fwtools/", SharpMap.Data.Providers.Ogr.FWToolsVersion)); } //Set fill-style to green layCountries.Style.Fill = new SolidBrush(Color.Green); //Set the polygons to have a black outline layCountries.Style.Outline = System.Drawing.Pens.Black; layCountries.Style.EnableOutline = true; layCountries.SRID = 4326; //Set up a river layer SharpMap.Layers.VectorLayer layRivers = new SharpMap.Layers.VectorLayer("Rivers"); //Set the datasource to a shapefile in the App_data folder layRivers.DataSource = new SharpMap.Data.Providers.Ogr("GeoData/MapInfo/riversMapInfo.tab"); //Define a blue 1px wide pen layRivers.Style.Line = new Pen(Color.Blue, 1); layRivers.SRID = 4326; //Set up a river layer SharpMap.Layers.VectorLayer layCities = new SharpMap.Layers.VectorLayer("Cities"); //Set the datasource to a shapefile in the App_data folder layCities.DataSource = new SharpMap.Data.Providers.Ogr("GeoData/MapInfo/citiesMapInfo.tab"); layCities.Style.SymbolScale = 0.8f; layCities.MaxVisible = 40; layCities.SRID = 4326; //Set up a country label layer SharpMap.Layers.LabelLayer layLabel = new SharpMap.Layers.LabelLayer("Country labels"); layLabel.DataSource = layCountries.DataSource; layLabel.Enabled = true; layLabel.LabelColumn = "Name"; layLabel.Style = new SharpMap.Styles.LabelStyle(); layLabel.Style.ForeColor = Color.White; layLabel.Style.Font = new Font(FontFamily.GenericSerif, 12); layLabel.Style.BackColor = new System.Drawing.SolidBrush(Color.FromArgb(128, 255, 0, 0)); layLabel.MaxVisible = 90; layLabel.MinVisible = 30; layLabel.Style.HorizontalAlignment = SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Center; layLabel.SRID = 4326; layLabel.MultipartGeometryBehaviour = SharpMap.Layers.LabelLayer.MultipartGeometryBehaviourEnum.Largest; //Set up a city label layer SharpMap.Layers.LabelLayer layCityLabel = new SharpMap.Layers.LabelLayer("City labels"); layCityLabel.DataSource = layCities.DataSource; layCityLabel.Enabled = true; layCityLabel.LabelColumn = "Name"; layCityLabel.Style = new SharpMap.Styles.LabelStyle(); layCityLabel.Style.ForeColor = Color.Black; layCityLabel.Style.Font = new Font(FontFamily.GenericSerif, 11); layCityLabel.MaxVisible = layLabel.MinVisible; layCityLabel.Style.HorizontalAlignment = SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Left; layCityLabel.Style.VerticalAlignment = SharpMap.Styles.LabelStyle.VerticalAlignmentEnum.Bottom; layCityLabel.Style.Offset = new PointF(3, 3); layCityLabel.Style.Halo = new Pen(Color.Yellow, 2); layCityLabel.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; layCityLabel.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; layCityLabel.SRID = 4326; layCityLabel.LabelFilter = SharpMap.Rendering.LabelCollisionDetection.ThoroughCollisionDetection; layCityLabel.Style.CollisionDetection = true; //Add the layers to the map object. //The order we add them in are the order they are drawn, so we add the rivers last to put them on top map.Layers.Add(layCountries); map.Layers.Add(layRivers); map.Layers.Add(layCities); map.Layers.Add(layLabel); map.Layers.Add(layCityLabel); //limit the zoom to 360 degrees width map.MaximumZoom = 360; map.BackColor = Color.LightBlue; map.ZoomToExtents(); // = 360; map.Center = new SharpMap.Geometries.Point(0, 0); return map; }
public static SharpMap.Map InitializeMap(float angle) { //Initialize a new map of size 'imagesize' SharpMap.Map map = new SharpMap.Map(); //Set up the countries layer var layCountries = new VectorLayer("Countries"); //Set the datasource to a shapefile in the App_data folder layCountries.DataSource = new SharpMap.Data.Providers.SpatiaLite( DataSource, "countries", "geom", "PK_UID"); //Set fill-style to green layCountries.Style.Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Green); //Set the polygons to have a black outline layCountries.Style.Outline = System.Drawing.Pens.Black; layCountries.Style.EnableOutline = true; //Set up a river layer var layRivers = new SharpMap.Layers.VectorLayer("Rivers"); //Set the datasource to a shapefile in the App_data folder layRivers.DataSource = new SharpMap.Data.Providers.SpatiaLite( DataSource, "rivers", "geom", "PK_UID"); //Define a blue 3px wide pen layRivers.Style.Line = new System.Drawing.Pen(System.Drawing.Color.LightBlue, 2); layRivers.Style.Line.CompoundArray = new[] { 0.2f, 0.8f }; layRivers.Style.Outline = new System.Drawing.Pen(System.Drawing.Color.DarkBlue, 3); layRivers.Style.EnableOutline = true; //Set up a cities layer var layCities = new SharpMap.Layers.VectorLayer("Cities"); //Set the datasource to the spatialite table layCities.DataSource = new SharpMap.Data.Providers.SpatiaLite( DataSource, "cities", "geom", "PK_UID"); layCities.Style.SymbolScale = 0.8f; layCities.MaxVisible = 40; //Set up a country label layer SharpMap.Layers.LabelLayer layLabel = new SharpMap.Layers.LabelLayer("Country labels") { DataSource = layCountries.DataSource, LabelColumn = "NAME", MultipartGeometryBehaviour = SharpMap.Layers.LabelLayer.MultipartGeometryBehaviourEnum.Largest, LabelFilter = SharpMap.Rendering.LabelCollisionDetection.ThoroughCollisionDetection, PriorityColumn = "POPDENS", Style = new SharpMap.Styles.LabelStyle { ForeColor = System.Drawing.Color.White, Font = new System.Drawing.Font(System.Drawing.FontFamily.GenericSerif, 12), BackColor = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(128, 255, 0, 0)), HorizontalAlignment = SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Center, MaxVisible = 90, MinVisible = 30, CollisionDetection = true } }; //Set up a city label layer SharpMap.Layers.LabelLayer layCityLabel = new SharpMap.Layers.LabelLayer("City labels") { DataSource = layCities.DataSource, LabelColumn = "name", PriorityColumn = "population", PriorityDelegate = delegate(SharpMap.Data.FeatureDataRow fdr) { System.Int32 retVal = 10000000 * ((System.String)fdr["capital"] == "Y" ? 1 : 0); return(retVal + System.Convert.ToInt32(fdr["population"])); }, TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias, SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias, LabelFilter = SharpMap.Rendering.LabelCollisionDetection.ThoroughCollisionDetection, Style = new SharpMap.Styles.LabelStyle { ForeColor = System.Drawing.Color.Black, Font = new System.Drawing.Font(System.Drawing.FontFamily.GenericSerif, 11), MaxVisible = layLabel.MinVisible, HorizontalAlignment = SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Left, VerticalAlignment = SharpMap.Styles.LabelStyle.VerticalAlignmentEnum.Bottom, Offset = new System.Drawing.PointF(3, 3), Halo = new System.Drawing.Pen(System.Drawing.Color.Yellow, 2), CollisionDetection = true } }; var layRiverLabels = new SharpMap.Layers.LabelLayer("RiverLabels"); layRiverLabels.DataSource = layRivers.DataSource; layRiverLabels.LabelColumn = "Name"; layRiverLabels.PriorityDelegate = GetRiverLength; layRiverLabels.Style = new SharpMap.Styles.LabelStyle { Font = new System.Drawing.Font("Arial", 10, System.Drawing.FontStyle.Bold), Halo = new System.Drawing.Pen(System.Drawing.Color.Azure, 2), ForeColor = System.Drawing.Color.DarkCyan, IgnoreLength = false, Enabled = true, CollisionDetection = true, }; layRiverLabels.LabelFilter = SharpMap.Rendering.LabelCollisionDetection.ThoroughCollisionDetection; //Add the layers to the map object. //The order we add them in are the order they are drawn, so we add the rivers last to put them on top map.Layers.Add(layCountries); map.Layers.Add(layRivers); map.Layers.Add(layCities); map.Layers.Add(layRiverLabels); map.Layers.Add(layLabel); map.Layers.Add(layCityLabel); //limit the zoom to 360 degrees width map.MaximumZoom = 360; map.BackColor = System.Drawing.Color.LightBlue; map.ZoomToExtents(); // = 360; var mat = new System.Drawing.Drawing2D.Matrix(); mat.RotateAt(angle, map.WorldToImage(map.Center)); map.MapTransform = mat; return(map); }
public static SharpMap.Map InitializeMap(float angle) { var dataSource = new SharpMap.Data.Providers.ShapeFile( string.Format("{0}/roads.shp", ShapefileSample.PathOsm), true); var fds = new SharpMap.Data.FeatureDataSet(); dataSource.Open(); dataSource.ExecuteIntersectionQuery(dataSource.GetExtents(), fds); dataSource.Close(); var gfp = new SharpMap.Data.Providers.GeometryFeatureProvider(fds.Tables[0]); var vl = new SharpMap.Layers.VectorLayer("roads", gfp) { CoordinateTransformation = LayerTools.Dhdn2ToWgs84 }; var ll = new SharpMap.Layers.LabelLayer("labels") { DataSource = gfp, CoordinateTransformation = LayerTools.Dhdn2ToWgs84, LabelColumn = "name", MultipartGeometryBehaviour = SharpMap.Layers.LabelLayer.MultipartGeometryBehaviourEnum.Largest, }; ll.Style.Halo = new System.Drawing.Pen(System.Drawing.Color.Red); //ll.Style.IgnoreLength = true; var map = new SharpMap.Map(); map.Layers.Add(vl); map.Layers.Add(ll); map.Layers.Add(vl); map.ZoomToExtents(); return map; }