private static SharpMap.Map InitializeMapOsmWithVariableLayerCollection(float angle) { var map = new SharpMap.Map(); var tileLayer = new SharpMap.Layers.TileAsyncLayer(new BruTile.Web.OsmTileSource(), "TileLayer - OSM with VLC"); map.BackgroundLayer.Add(tileLayer); var vl = new SharpMap.Layers.VectorLayer("Vilnius Transport Data - Bus", new VilniusTransportData(VilniusTransportData.TransportType.Bus)); var pttBus = new PublicTransportTheme(System.Drawing.Brushes.DarkGreen); vl.Theme = new SharpMap.Rendering.Thematics.CustomTheme(pttBus.GetStyle); vl.CoordinateTransformation = GetCoordinateTransformation(); map.VariableLayers.Add(vl); vl = new SharpMap.Layers.VectorLayer("Vilnius Transport Data - Trolley", new VilniusTransportData(VilniusTransportData.TransportType.TrolleyBus)); var pttTrolley = new PublicTransportTheme(System.Drawing.Brushes.Red); vl.Theme = new SharpMap.Rendering.Thematics.CustomTheme(pttTrolley.GetStyle); vl.CoordinateTransformation = GetCoordinateTransformation(); map.VariableLayers.Add(vl); SharpMap.Layers.VariableLayerCollection.Interval = 5000; map.ZoomToBox(vl.Envelope); return(map); }
private static SharpMap.Map InitializeMapOsm() { var map = new SharpMap.Map(); var tileLayer = new SharpMap.Layers.TileAsyncLayer(new BruTile.Web.OsmTileSource(), "TileLayer - OSM"); map.BackgroundLayer.Add(tileLayer); map.ZoomToBox(tileLayer.Envelope); return map; }
private static SharpMap.Map InitializeMapOsm() { var map = new SharpMap.Map(); var tileLayer = new SharpMap.Layers.TileAsyncLayer(new BruTile.Web.OsmTileSource(), "TileLayer - OSM"); map.BackgroundLayer.Add(tileLayer); map.ZoomToBox(tileLayer.Envelope); return(map); }
private void button2_Click(object sender, EventArgs e) { mapBox1.Map.BackgroundLayer.Clear(); if (m_ts != null) m_ts.Dispose(); m_ts = new BruTile.GoogleMaps.GoogleV3TileSource((BruTile.GoogleMaps.GoogleV3TileSource.MapTypeId)(m_nextMap++ % 4)); var tl = new SharpMap.Layers.TileAsyncLayer(m_ts, "Google"); mapBox1.Map.BackgroundLayer.Add(tl); mapBox1.Refresh(); }
private static SharpMap.Map InitializeMapOsm() { var map = new SharpMap.Map(); var tileLayer = new SharpMap.Layers.TileAsyncLayer( KnownTileSources.Create(KnownTileSource.OpenStreetMap), "TileLayer - OSM"); map.BackgroundLayer.Add(tileLayer); map.ZoomToBox(tileLayer.Envelope); return(map); }
private void button2_Click(object sender, EventArgs e) { mapBox1.Map.BackgroundLayer.Clear(); if (m_ts != null) { m_ts.Dispose(); } m_ts = new BruTile.GoogleMaps.GoogleV3TileSource((BruTile.GoogleMaps.GoogleV3TileSource.MapTypeId)(m_nextMap++ % 4)); var tl = new SharpMap.Layers.TileAsyncLayer(m_ts, "Google"); mapBox1.Map.BackgroundLayer.Add(tl); mapBox1.Refresh(); }
public Form1() { ts = new BruTile.GoogleMaps.GoogleV3TileSource(BruTile.GoogleMaps.GoogleV3TileSource.MapTypeId.ROADMAP); InitializeComponent(); SharpMap.Layers.TileAsyncLayer tl = new SharpMap.Layers.TileAsyncLayer(ts, "Google"); tl.OnlyRedrawWhenComplete = true; mapBox1.Map.BackgroundLayer.Add(tl); mapBox1.Map.ZoomToBox(new GeoAPI.Geometries.Envelope(-1500000, 4250000, 4500000, 12500000)); mapBox1.EnableShiftButtonDragRectangleZoom = true; mapBox1.PanOnClick = false; mapBox1.SetToolsNoneWhileRedrawing = false; mapBox1.Refresh(); }
public Form1() { ServicePointManager.DefaultConnectionLimit = 20; m_ts = new BruTile.GoogleMaps.GoogleV3TileSource(BruTile.GoogleMaps.GoogleV3TileSource.MapTypeId.ROADMAP); InitializeComponent(); var tl = new SharpMap.Layers.TileAsyncLayer(m_ts, "Google"); tl.OnlyRedrawWhenComplete = true; mapBox1.Map.BackgroundLayer.Add(tl); mapBox1.Map.ZoomToBox(new GeoAPI.Geometries.Envelope(-1500000, 4250000, 4500000, 12500000)); mapBox1.EnableShiftButtonDragRectangleZoom = true; mapBox1.PanOnClick = false; mapBox1.SetToolsNoneWhileRedrawing = false; mapBox1.Refresh(); }
public static SharpMap.Map InitializeMap(float angle) { var fdt = GetRealFeatureDataTable(); FillRealDataTable(fdt); var p = new SharpMap.Data.Providers.GeometryFeatureProvider(fdt); var m = new SharpMap.Map(); var tl = new SharpMap.Layers.TileAsyncLayer(KnownTileSources.Create(KnownTileSource.OpenStreetMap), "TileLayer with HeatLayer", System.Drawing.Color.Transparent, false, new BruTile.Cache.FileCache(@"d:\temp\OSM", "png"), System.Drawing.Imaging.ImageFormat.Png); m.BackgroundLayer.Add(tl); //var l = new SharpMap.Layers.HeatLayer(p, r => 0.02f) { LayerName = "HEAT" }; var l = new SharpMap.Layers.HeatLayer(p, "Data", 0.00025f) { LayerName = "HEAT" }; m.Layers.Add(l); var ctfac = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory(); l.CoordinateTransformation = ctfac.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84, ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator); l.ZoomMin = 0;// 0.01 * m.GetExtents().Width; l.ZoomMax = /*0.9 * */ m.GetExtents().Width; l.OpacityMax = 0.5f; l.OpacityMin = 0.9f; l.HeatColorBlend = SharpMap.Layers.HeatLayer.Classic; var env = l.Envelope; GeoAPI.Geometries.GeoAPIEx.Grow(env, env.Width * 0.05, env.Height * 0.05); //m.EnforceMaximumExtents = true; //m.MaximumExtents = env; m.ZoomToBox(env); return(m); }
private void button2_Click(object sender, EventArgs e) { mapBox1.Map.BackgroundLayer.Clear(); if (ts != null) ts.Dispose(); ts = new BruTile.GoogleMaps.GoogleV3TileSource((BruTile.GoogleMaps.GoogleV3TileSource.MapTypeId)(nextMap++ % 4)); SharpMap.Layers.TileAsyncLayer tl = new SharpMap.Layers.TileAsyncLayer(ts, "Google"); mapBox1.Map.BackgroundLayer.Add(tl); mapBox1.Refresh(); //for (int i = 0; i < 10; i++) { // FrmMapFrm frm = new FrmMapFrm(); // frm.Show(); //while (!frm.Visible) //{ // Thread.Sleep(100); //} //frm.Close(); //frm.Dispose(); } }
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; }
private static SharpMap.Map InitializeMapOsmWithVariableLayerCollection(float angle) { var map = new SharpMap.Map(); var tileLayer = new SharpMap.Layers.TileAsyncLayer(new BruTile.Web.OsmTileSource(), "TileLayer - OSM with VLC"); map.BackgroundLayer.Add(tileLayer); var vl = new SharpMap.Layers.VectorLayer("Vilnius Transport Data - Bus", new VilniusTransportData(VilniusTransportData.TransportType.Bus)); var pttBus = new PublicTransportTheme(System.Drawing.Brushes.DarkGreen); vl.Theme = new SharpMap.Rendering.Thematics.CustomTheme(pttBus.GetStyle); vl.CoordinateTransformation = GetCoordinateTransformation(); map.VariableLayers.Add(vl); vl = new SharpMap.Layers.VectorLayer("Vilnius Transport Data - Trolley", new VilniusTransportData(VilniusTransportData.TransportType.TrolleyBus)); var pttTrolley = new PublicTransportTheme(System.Drawing.Brushes.Red); vl.Theme = new SharpMap.Rendering.Thematics.CustomTheme(pttTrolley.GetStyle); vl.CoordinateTransformation = GetCoordinateTransformation(); map.VariableLayers.Add(vl); SharpMap.Layers.VariableLayerCollection.Interval = 5000; map.ZoomToBox(vl.Envelope); 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); }