本文整理匯總了C#中SharpMap.Map.ZoomToBox方法的典型用法代碼示例。如果您正苦於以下問題:C# Map.ZoomToBox方法的具體用法?C# Map.ZoomToBox怎麽用?C# Map.ZoomToBox使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SharpMap.Map
的用法示例。
在下文中一共展示了Map.ZoomToBox方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CreateMap
public static Map CreateMap()
{
const string getCapabilitiesURI = "http://www2.dmsolutions.ca/cgi-bin/mswfs_gmap?request=GetCapabilities&service=WFS&VERSION=1.0.0";
Map demoMap = new SharpMap.Map(new Size(600, 600));
demoMap.MinimumZoom = 0.005;
demoMap.BackColor = Color.White;
SharpMap.Layers.VectorLayer layer1 = new SharpMap.Layers.VectorLayer("prov_land");
WFS prov1 = new WFS(getCapabilitiesURI, "", "prov_land", WFS.WFSVersionEnum.WFS1_1_0);
layer1.Style.Fill = new SolidBrush(Color.IndianRed); // States
//// Options
// Defaults: MultiGeometries: true, QuickGeometries: false, GetFeatureGETRequest: false
// Render with validation...
prov1.QuickGeometries = false;
// Important when connecting to an UMN MapServer
//!!!prov1.GetFeatureGETRequest = true;
// Ignore multi-geometries...
prov1.MultiGeometries = false;
layer1.DataSource = prov1;
demoMap.Layers.Add(layer1);
demoMap.ZoomToBox(new SharpMap.Geometries.BoundingBox(-3546709.473205, -869773.355764, 4444893.074820, 3923457.184829));
return demoMap;
}
示例2: InitializeMap
public static Map InitializeMap()
{
const string getCapabilitiesURI = "http://steven:8080/eWaterWfsConnector/wfs";
Map map = new SharpMap.Map(new System.Drawing.Size(600, 600));
map.MinimumZoom = 0.005;
map.BackColor = System.Drawing.Color.White;
SharpMap.Layers.VectorLayer layer1 = new SharpMap.Layers.VectorLayer("test");
WFS prov1 = new WFS(getCapabilitiesURI, "", "Well", WFS.WFSVersionEnum.WFS1_0_0);
prov1.QuickGeometries = false;
// Important when connecting to an UMN MapServer
prov1.GetFeatureGETRequest = true;
// Ignore multi-geometries...
prov1.MultiGeometries = false;
layer1.DataSource = prov1;
map.Layers.Add(layer1);
map.ZoomToBox(new SharpMap.Geometries.BoundingBox(574290, 4275299, 702273, 4386402));
return map;
}
示例3: InitializeGoogleMap
public static SharpMap.Map InitializeGoogleMap(GoogleMapType mt)
{
SharpMap.Map map = new SharpMap.Map();
GoogleRequest req;
ITileSource tileSource;
TileAsyncLayer tileLayer;
if (mt == (GoogleMapType.GoogleSatellite | GoogleMapType.GoogleLabels))
{
req = new GoogleRequest(GoogleMapType.GoogleSatellite);
tileSource = new GoogleTileSource(req);
tileLayer = new TileAsyncLayer(tileSource, "TileLayer - " + GoogleMapType.GoogleSatellite);
map.Layers.Add(tileLayer);
req = new GoogleRequest(GoogleMapType.GoogleLabels);
tileSource = new GoogleTileSource(req);
mt = GoogleMapType.GoogleLabels;
}
else
{
req = new GoogleRequest(mt);
tileSource = new GoogleTileSource(req);
}
tileLayer = new TileAsyncLayer(tileSource, "TileLayer - " + mt);
map.BackgroundLayer.Add(tileLayer);
map.ZoomToBox(tileLayer.Envelope);
return map;
}
示例4: CreateMap
public static Map CreateMap()
{
const string getCapabilitiesURI = "http://192.168.25.120:8080/deegree-wfs/services";
Map map = new SharpMap.Map(new Size(600, 600));
map.MinimumZoom = 0.005;
map.BackColor = Color.White;
SharpMap.Layers.VectorLayer layer1 = new SharpMap.Layers.VectorLayer("Springs");
WFS prov1 = new WFS(getCapabilitiesURI, "app1", "Springs", WFS.WFSVersionEnum.WFS1_1_0);
prov1.QuickGeometries = false;
// Important when connecting to an UMN MapServer
prov1.GetFeatureGETRequest = true;
// Ignore multi-geometries...
prov1.MultiGeometries = false;
layer1.DataSource = prov1;
map.Layers.Add(layer1);
map.ZoomToBox(new SharpMap.Geometries.BoundingBox(574290, 4275299, 702273, 4386402));
return map;
}
示例5: InitializeMapOsm
private static Map InitializeMapOsm()
{
Map map = new Map();
TileLayer tileLayer = new TileLayer(new OsmTileSource(), "TileLayer - OSM");
map.Layers.Add(tileLayer);
map.ZoomToBox(tileLayer.Envelope);
return map;
}
示例6: InitializeMap
public static Map InitializeMap()
{
Map map = new Map();
string url = "http://labs.metacarta.com/wms-c/tilecache.py?version=1.1.1&request=GetCapabilities&service=wms-c";
TiledWmsLayer tiledWmsLayer = new TiledWmsLayer("Metacarta", url);
tiledWmsLayer.TileSetsActive.Add(tiledWmsLayer.TileSets["basic"].Name);
map.Layers.Add(tiledWmsLayer);
map.ZoomToBox(new SharpMap.Geometries.BoundingBox(-180.0, -90.0, 180.0, 90.0));
return map;
}
示例7: TestMap2
public void TestMap2()
{
var m = new Map(_mapSize);
m.BackgroundLayer.Add(new TileLayer(new OsmTileSource(new OsmRequest(KnownOsmTileServers.MapQuest)), "MapQuest"));
var codeBase = Path.GetDirectoryName(GetType().Assembly.CodeBase);
var cn = string.Format("Data Source={0};",
Path.Combine(new Uri(codeBase).LocalPath, "TestData", "osm_aurich.sqlite"));
var ct = Wgs84ToWebMercator;
//Env[7,45731445821406 : 7,53454260528903, 53,4342695512313 : 53,478793942147]
var box = new Envelope(7.45731445821406, 7.53454260528903, 53.4342695512313, 53.478793942147);
var box3857 = GeometryTransform.TransformBox(box, ct.MathTransform);
m.ZoomToBox(box3857);
foreach (var msp in ManagedSpatiaLite.GetSpatialTables(cn))
{
var l = new VectorLayer(msp.Table, msp);
switch (msp.Table.Substring(0, 2).ToLower())
{
case "pt":
l.Style = VectorStyle.CreateRandomPuntalStyle();
break;
case "ln":
l.Style = VectorStyle.CreateRandomLinealStyle();
break;
case "pg":
l.Style = VectorStyle.CreateRandomPolygonalStyle();
break;
default:
l.Style = VectorStyle.CreateRandomStyle();
break;
}
l.CoordinateTransformation = ct;
m.Layers.Add(l);
}
var f = GetFormatter();
BruTile.Utility.AddBruTileSurrogates(GetFormatter());
Map mD = null;
Assert.DoesNotThrow(() => mD = SandD(m, f));
TestMaps("Test2", m, mD);
}
示例8: TestRender
public void TestRender()
{
var style = new SharpMap.Styles.GroupStyle();
var vStyle = new SharpMap.Styles.VectorStyle()
{
Enabled = true,
PointColor = Brushes.Red,
PointSize = 6
};
style.AddStyle(vStyle);
vStyle = new SharpMap.Styles.VectorStyle()
{
Enabled = true,
PointColor = Brushes.White,
PointSize = 2
};
style.AddStyle(vStyle);
Assert.AreEqual(2, style.Count);
Assert.AreEqual(Color.Red, (style[0].PointColor as SolidBrush).Color);
VectorLayer vLay = new VectorLayer("test");
vLay.Style = style;
vLay.DataSource = new SharpMap.Data.Providers.GeometryProvider("POINT(0 0)");
Map m = new Map(new Size(11, 11));
m.BackColor = Color.White;
m.ZoomToBox(new GeoAPI.Geometries.Envelope(-5, 5, -5, 5));
m.Layers.Add(vLay);
var img = m.GetMap();
//img.Save(@"c:\\temp\ren.png");
Bitmap bmp = img as Bitmap;
Color c1 = bmp.GetPixel(5, 5);
Assert.AreEqual(Color.White.ToArgb(), c1.ToArgb());
c1 = bmp.GetPixel(3, 5);
Assert.AreEqual(Color.Red.ToArgb(), c1.ToArgb());
c1 = bmp.GetPixel(7, 5);
Assert.AreEqual(Color.Red.ToArgb(), c1.ToArgb());
c1 = bmp.GetPixel(5, 3);
Assert.AreEqual(Color.Red.ToArgb(), c1.ToArgb());
c1 = bmp.GetPixel(5, 7);
Assert.AreEqual(Color.Red.ToArgb(), c1.ToArgb());
}
示例9: InitializeMapOsmWithXls
private static Map InitializeMapOsmWithXls(float angle)
{
Map map = new Map();
TileLayer tileLayer = new TileLayer(new OsmTileSource(), "TileLayer - OSM with XLS");
map.Layers.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 epsg3785 = 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\",\"3785\"]]");
var ct = ctf.CreateFromCoordinateSystems(epsg4326, epsg3785);
foreach (System.Data.DataRow row in ds.Tables[0].Rows)
{
if (row["X"] == DBNull.Value || row["Y"] == DBNull.Value) continue;
double[] coords = new double[] { 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 epsg3785 = new DotSpatial.Projections.ProjectionInfo();
epsg3785.ReadEsriString("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\",\"3785\"]]");
foreach (System.Data.DataRow row in ds.Tables[0].Rows)
{
if (row["X"] == DBNull.Value || row["Y"] == DBNull.Value) continue;
double[] coords = new double[] { Convert.ToDouble(row["X"]), Convert.ToDouble(row["Y"])};
DotSpatial.Projections.Reproject.ReprojectPoints(coords, null, epsg4326, epsg3785, 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);
xlsLayer.Style.Symbol = SharpMap.Styles.VectorStyle.DefaultSymbol;
//Add layer to map
map.Layers.Add(xlsLayer);
var xlsLabelLayer = new SharpMap.Layers.LabelLayer("XLSLabel");
xlsLabelLayer.DataSource = xlsProvider;
xlsLabelLayer.LabelColumn = "Name";
xlsLabelLayer.PriorityColumn = "Population";
xlsLabelLayer.Style.CollisionBuffer = new System.Drawing.SizeF(2f, 2f);
xlsLabelLayer.Style.CollisionDetection = true;
xlsLabelLayer.LabelFilter = SharpMap.Rendering.LabelCollisionDetection.ThoroughCollisionDetection;
map.Layers.Add(xlsLabelLayer);
map.ZoomToBox(tileLayer.Envelope);
return map;
}
示例10: InitializeMapGoogle
private static Map InitializeMapGoogle(GoogleMapType mt)
{
Map map = new Map();
GoogleRequest req;
ITileSource tileSource;
TileLayer tileLayer;
if (mt == (GoogleMapType.GoogleSatellite | GoogleMapType.GoogleLabels))
{
req = new GoogleRequest(GoogleMapType.GoogleSatellite);
tileSource = new GoogleTileSource(req);
tileLayer = new TileLayer(tileSource, "TileLayer - " + GoogleMapType.GoogleSatellite);
map.Layers.Add(tileLayer);
req = new GoogleRequest(GoogleMapType.GoogleLabels);
tileSource = new GoogleTileSource(req);
mt = GoogleMapType.GoogleLabels;
}
else
{
req = new GoogleRequest(mt);
tileSource = new GoogleTileSource(req);
}
tileLayer = new TileLayer(tileSource, "TileLayer - " + mt);
map.Layers.Add(tileLayer);
map.ZoomToBox(tileLayer.Envelope);
return map;
}
示例11: InitializeMapBing
private static Map InitializeMapBing(BingMapType mt)
{
Map map = new Map();
TileLayer tileLayer = new TileLayer(new BingTileSource(BingRequest.UrlBingStaging, "", mt) , "TileLayer - Bing " + mt);
map.Layers.Add(tileLayer);
map.ZoomToBox(tileLayer.Envelope);
return map;
}
示例12: InitializeMapOsmWithVariableLayerCollection
private static Map InitializeMapOsmWithVariableLayerCollection(float angle)
{
Map map = new Map();
TileLayer tileLayer = new TileLayer(new OsmTileSource(), "TileLayer - OSM with VLC");
map.Layers.Add(tileLayer);
VectorLayer vl = null;
vl = new VectorLayer("Vilnius Transport Data - Bus",
new VilniusTransportData(VilniusTransportData.TransportType.Bus));
PublicTransportTheme pttBus = new PublicTransportTheme(Brushes.DarkGreen);
vl.Theme = new CustomTheme(pttBus.GetStyle);
vl.CoordinateTransformation = GetCoordinateTransformation();
map.VariableLayers.Add(vl);
vl = new VectorLayer("Vilnius Transport Data - Trolley",
new VilniusTransportData(VilniusTransportData.TransportType.TrolleyBus));
PublicTransportTheme pttTrolley = new PublicTransportTheme(Brushes.Red);
vl.Theme = new CustomTheme(pttTrolley.GetStyle);
vl.CoordinateTransformation = GetCoordinateTransformation();
map.VariableLayers.Add(vl);
VariableLayerCollection.Interval = 5000;
map.ZoomToBox(vl.Envelope);
return map;
}
示例13: ZoomToBox_WithAspectCorrection
public void ZoomToBox_WithAspectCorrection()
{
Map map = new Map(new Size(400, 200));
map.ZoomToBox(new BoundingBox(20, 10, 100, 180));
Assert.AreEqual(new Point(60, 95), map.Center);
Assert.AreEqual(340, map.Zoom);
}
示例14: ZoomToBoxWithEnforcedMaximumExtents
public void ZoomToBoxWithEnforcedMaximumExtents()
{
Map map = new Map();
//map.MaximumZoom = 100;
map.MaximumExtents = new Envelope(-180, 180, -90, 90);
map.EnforceMaximumExtents = true;
map.ZoomToBox(new Envelope(-200, 200, -100, 100));
Assert.IsTrue(map.MaximumExtents.Contains(map.Envelope));
Assert.AreEqual(new BoundingBox(-120, 120, -90, 90), map.Envelope);
}
示例15: TestZoomToBoxRaisesMapViewOnChange
public void TestZoomToBoxRaisesMapViewOnChange()
{
var raised = false;
var map = new Map(new Size(400, 200));
map.MapViewOnChange += () => raised = true;
// ZoomToBox
map.ZoomToBox(new BoundingBox(20, 100, 10, 180));
Assert.IsTrue(raised, "MapViewOnChange not fired when calling Map.ZoomToBox(...).");
raised = false;
map.ZoomToBox(new BoundingBox(20, 100, 10, 180));
Assert.IsFalse(raised, "MapViewOnChange fired when calling Map.ZoomToBox(map.Envelope).");
// ZoomToExtents
// Note: Not needed as Map.ZoomToExtents() calls Map.ZoomToBox(Map.GetExtents())
//raised = false;
//map.ZoomToExtents();
//Assert.IsTrue(raised, "MapViewOnChange not fired when calling Map.ZoomToExtents()");
//raised = false;
//map.ZoomToExtents();
//Assert.IsFalse(raised, "MapViewOnChange fired when calling Map.ZoomToExtents() twice");
// Set Zoom
map.Zoom = map.Zoom * 0.9;
Assert.IsTrue(raised, "MapViewOnChange not fired when setting Map.Zoom.");
raised = false;
map.Zoom = map.Zoom;
Assert.IsFalse(raised, "MapViewOnChange not fired when setting Map.Zoom = Map.Zoom");
// Set Center
map.Center = new Coordinate(map.Center.X + 1, map.Center.Y);
Assert.IsTrue(raised, "MapViewOnChange not fired when setting Map.Center.");
raised = false;
map.Center = map.Center;
Assert.IsFalse(raised, "MapViewOnChange fired when setting Map.Center = Map.Center.");
}