本文整理汇总了C#中SharpMap.Map.ZoomToBox方法的典型用法代码示例。如果您正苦于以下问题:C# SharpMap.Map.ZoomToBox方法的具体用法?C# SharpMap.Map.ZoomToBox怎么用?C# SharpMap.Map.ZoomToBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharpMap.Map
的用法示例。
在下文中一共展示了SharpMap.Map.ZoomToBox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Example2
public static void Example2()
{
var map = new SharpMap.Map(new Size(1280, 1084));
SharpMap.Data.Providers.IProvider provider =
new SharpMap.Data.Providers.ShapeFile(
@"C:\temp\Data\niedersachsen.shp\railways.shp");
var style = new SharpMap.Styles.VectorStyle();
style.Line.Brush = Brushes.White;
style.Line.DashPattern = new float[] { 4f, 4f };
style.Line.Width = 4;
style.EnableOutline = true;
style.Outline.Brush = Brushes.Black;
style.Outline.Width = 6;
var vl = new SharpMap.Layers.VectorLayer("Railways", provider)
{Style = style};
map.Layers.Add(vl);
var env = vl.Envelope;
env.ExpandBy(-0.45f *env.Width, -0.45 * env.Height);
map.ZoomToBox(env);
var mapImage = map.GetMap();
mapImage.Save("Example2.png",
System.Drawing.Imaging.ImageFormat.Png);
}
示例2: InitializeMapOsm
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;
}
示例3: TestRealData
public void TestRealData()
{
var fdt = GetRealFeatureDataTable();
FillRealDataTable(fdt);
var p = new SharpMap.Data.Providers.FeatureProvider(fdt);
var m = new SharpMap.Map(new Size(640, 640));
m.Layers.Add(new TileLayer(
new OsmTileSource(new OsmRequest(KnownTileServers.Mapnik) /*,
new FileCache(@"d:\temp\OSM", "png")*/), "OSM"));
var l = new HeatLayer(p, "Data", 0.001f);
l.LayerName = "HEAT";
m.Layers.Add(l);
#if DotSpatialProjections
l.CoordinateTransformation = new DotSpatial.Projections.CoordinateTransformation
{
Source = ProjectionInfo.FromEpsgCode(4326),
Target = ProjectionInfo.FromEpsgCode(3857)
};
#else
var ctfac = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory();
l.CoordinateTransformation =
ctfac.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84,
ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator);
#endif
l.ZoomMin = 0;// 0.01 * m.GetExtents().Width;
l.ZoomMax = /*0.9 * */m.GetExtents().Width;
l.OpacityMax = 1;
l.OpacityMin = 0.3f;
m.ZoomToBox(l.Envelope);
for (var i = 0; i < 5; i++)
{
using (var img = m.GetMap())
{
img.Save("RealDataHeat" + i + ".png");
}
m.Zoom /= 2;
}
m.ZoomToExtents();
using (var img = m.GetMap())
{
img.Save("RealDataHeat.png");
}
}
示例4: InitializeMap
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();
m.BackgroundLayer.Add(new SharpMap.Layers.TileAsyncLayer(
new BruTile.Web.OsmTileSource(
new BruTile.Web.OsmRequest(KnownTileSource.OpenStreetMap),
new BruTile.Cache.FileCache(@"d:\temp\OSM", "png")), "OSM"));
m.BackgroundLayer[0].LayerName = "TileLayer with HeatLayer";
//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);
#if DotSpatialProjections
l.CoordinateTransformation = new DotSpatial.Projections.CoordinateTransformation
{
Source = DotSpatial.Projections.ProjectionInfo.FromEpsgCode(4326),
Target = DotSpatial.Projections.ProjectionInfo.FromEpsgCode(3857)
};
#else
var ctfac = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory();
l.CoordinateTransformation =
ctfac.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84,
ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator);
#endif
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;
}
示例5: Example1
public static void Example1()
{
var map = new SharpMap.Map(new Size(1280, 1084));
SharpMap.Data.Providers.IProvider provider =
new SharpMap.Data.Providers.ShapeFile(
@"C:\temp\Data\niedersachsen.shp\railways.shp");
var vl = new SharpMap.Layers.VectorLayer("Railways", provider);
map.Layers.Add(vl);
map.ZoomToBox(vl.Envelope);
var mapImage = map.GetMap();
mapImage.Save("Example1.png",
System.Drawing.Imaging.ImageFormat.Png);
}
示例6: TestIncompleteImage
public void TestIncompleteImage()
{
using (var map = new SharpMap.Map(new Size(2500, 2500)))
{
map.BackColor = Color.Magenta;
var br = new BingRequest(BingRequest.UrlBing, "", BingMapType.Hybrid);
var bts = new BingTileSource(br);
var tl = new TileLayer(bts, "TileLayer - " + BingMapType.Hybrid.ToString(), Color.Transparent, true,
System.IO.Path.Combine(_fileCacheRoot, "BingStaging"));
map.Layers.Add(tl);
map.ZoomToBox(new Envelope(829384.331338522, 837200.785470394, 7068020.31417922, 7072526.73926545)
/*new Envelope(-239839.49199841652, 78451.759683380573, -37033.0152981899, 106723.52879865949)*/);
using (var image = map.GetMap())
{
image.Save("TestIncompleteImage.png", ImageFormat.Png);
}
}
}
示例7: HeatLayerTest
public void HeatLayerTest()
{
var m = new SharpMap.Map(new Size(640, 480));
var data = CreatingData.CreatePointFeatureDataTableFromArrays(
CreatingData.GetRandomOrdinates(150, 5, 6),
CreatingData.GetRandomOrdinates(150, 52, 53), null,
CreatingData.GetRandomOrdinates(150, 0, 1));
var p = new SharpMap.Data.Providers.FeatureProvider(data);
var l = new HeatLayer(p, "Data");
m.Layers.Add(l);
m.ZoomToBox(new Envelope(5.4, 5.8, 52.4, 52.6));
//m.ZoomToExtents();
var img = m.GetMap();
img.Save("HeatMap.png", ImageFormat.Png);
img.Dispose();
}
示例8: Example3
public static void Example3()
{
var map = new SharpMap.Map(new Size(1280, 1084));
SharpMap.Data.Providers.IProvider provider =
new SharpMap.Data.Providers.ShapeFile(
@"C:\temp\Data\niedersachsen.shp\railways.shp");
var cls = new SharpMap.Rendering.Symbolizer.CachedLineSymbolizer();
cls.LineSymbolizeHandlers.Add(
new SharpMap.Rendering.Symbolizer.PlainLineSymbolizeHandler
{ Line = new System.Drawing.Pen(System.Drawing.Color.Gold, 2) });
var wls = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander
{
Pattern =
SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer.
GetGreaterSeries(3, 3),
Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1),
Interval = 20
};
cls.LineSymbolizeHandlers.Add(wls);
var vl = new SharpMap.Layers.Symbolizer.LinealVectorLayer(
"Railways", provider);
vl.Symbolizer = cls;
map.Layers.Add(vl);
var env = vl.Envelope;
env.ExpandBy(-0.45f * env.Width, -0.45 * env.Height);
map.ZoomToBox(env);
var mapImage = map.GetMap();
mapImage.Save("Example3.png",
System.Drawing.Imaging.ImageFormat.Png);
}
示例9: InitializeMapOsmWithXls
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;
}
示例10: InitializeMapGoogle
private static SharpMap.Map InitializeMapGoogle(BruTile.Web.GoogleMapType mt)
{
var map = new SharpMap.Map();
BruTile.Web.GoogleRequest req;
BruTile.ITileSource tileSource;
SharpMap.Layers.TileLayer tileLayer;
if (mt == (BruTile.Web.GoogleMapType.GoogleSatellite | BruTile.Web.GoogleMapType.GoogleLabels))
{
req = new BruTile.Web.GoogleRequest(BruTile.Web.GoogleMapType.GoogleSatellite);
tileSource = new BruTile.Web.GoogleTileSource(req);
tileLayer = new SharpMap.Layers.TileLayer(tileSource, "TileLayer - " + BruTile.Web.GoogleMapType.GoogleSatellite);
map.Layers.Add(tileLayer);
req = new BruTile.Web.GoogleRequest(BruTile.Web.GoogleMapType.GoogleLabels);
tileSource = new BruTile.Web.GoogleTileSource(req);
mt = BruTile.Web.GoogleMapType.GoogleLabels;
}
else
{
req = new BruTile.Web.GoogleRequest(mt);
tileSource = new BruTile.Web.GoogleTileSource(req);
}
tileLayer = new SharpMap.Layers.TileLayer(tileSource, "TileLayer - " + mt);
map.Layers.Add(tileLayer);
map.ZoomToBox(tileLayer.Envelope);
return map;
}
示例11: InitializeMapBing
private static SharpMap.Map InitializeMapBing(BruTile.Web.BingMapType mt)
{
var map = new SharpMap.Map();
var tileLayer = new SharpMap.Layers.TileLayer(new BruTile.Web.BingTileSource(BruTile.Web.BingRequest.UrlBingStaging, "", mt), "TileLayer - Bing " + mt);
map.BackgroundLayer.Add(tileLayer);
map.ZoomToBox(tileLayer.Envelope);
return map;
}
示例12: InitializeMapOsmWithVariableLayerCollection
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;
}
示例13: ZoomToBox_WithAspectCorrection
public void ZoomToBox_WithAspectCorrection()
{
SharpMap.Map map = new SharpMap.Map(new System.Drawing.Size(400, 200));
map.ZoomToBox(new SharpMap.Geometries.BoundingBox(20, 10, 100, 180));
Assert.AreEqual(new SharpMap.Geometries.Point(60, 95), map.Center);
Assert.AreEqual(340, map.Zoom);
}
示例14: TestTransformation
public void TestTransformation()
{
var m = new SharpMap.Map(new System.Drawing.Size(640, 320));
var l = new SharpMap.Layers.Symbolizer.PuntalVectorLayer("l",
new SharpMap.Data.Providers.GeometryProvider(m.Factory.CreatePoint(new GeoAPI.Geometries.Coordinate(0, 51.478885))),
SharpMap.Rendering.Symbolizer.PathPointSymbolizer.CreateCircle(System.Drawing.Pens.Aquamarine, System.Drawing.Brushes.BurlyWood, 24));
var ctFact = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory();
l.CoordinateTransformation = ctFact.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84, ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator);
l.ReverseCoordinateTransformation = ctFact.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator, ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84);
m.Layers.Add(new SharpMap.Layers.TileLayer(new BruTile.Web.OsmTileSource(),"b"));
m.Layers.Add(l);
var e = new GeoAPI.Geometries.Envelope(-0.02, 0.02, 51.478885 - 0.01, 51.478885 + 0.01);
e = GeoAPI.CoordinateSystems.Transformations.GeometryTransform.TransformBox(e,
l.CoordinateTransformation.MathTransform);
m.ZoomToBox(e);
m.GetMap().Save("Greenwich.png", System.Drawing.Imaging.ImageFormat.Png);
}
示例15: ZoomToBox_WithAspectCorrection
public void ZoomToBox_WithAspectCorrection()
{
SharpMap.Map map = new SharpMap.Map(new System.Drawing.Size(400, 200));
map.ZoomToBox(GeometryFactory.CreateEnvelope(20, 10, 100, 180));
Assert.AreEqual(GeometryFactory.CreateCoordinate(60, 95), map.Center);
Assert.AreEqual(340, map.Zoom);
}