本文整理汇总了C#中SharpMap.Map类的典型用法代码示例。如果您正苦于以下问题:C# Map类的具体用法?C# Map怎么用?C# Map使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Map类属于SharpMap命名空间,在下文中一共展示了Map类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MapSridEqualsFactorySrid
public void MapSridEqualsFactorySrid()
{
var m = new Map();
Assert.AreEqual(m.SRID, m.Factory.SRID);
m.SRID = 10;
Assert.AreEqual(m.SRID, m.Factory.SRID);
}
示例2: Default
internal static Map Default()
{
string currdir = Directory.GetCurrentDirectory();
Trace.WriteLine(String.Format("Current directory: {0}", currdir));
Map map = new Map(new Size(1, 1));
IDictionary<string, LayerData> dict = Nyc;
foreach (string layer in dict.Keys)
{
string format = String.Format(@"WMS\Server\data\{0}", layer);
string path = Path.Combine(currdir, format);
if (!File.Exists(path))
throw new FileNotFoundException("file not found", path);
string name = Path.GetFileNameWithoutExtension(layer);
LayerData data = dict[layer];
ShapeFile source = new ShapeFile(path, true);
VectorLayer item = new VectorLayer(name, source)
{
SRID = 4326,
Style = (VectorStyle)data.Style,
SmoothingMode = Smoothing.AntiAlias
};
map.Layers.Add(item);
}
return map;
}
示例3: 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;
}
示例4: InitializeMap
public static Map InitializeMap(float angle)
{
string wmsUrl = "http://dev:8080/geoserver/ows?service=wms&version=1.1.1&request=GetCapabilities";
Map map = new Map();
WmsLayer layWms = new WmsLayer("Demis Map", wmsUrl);
layWms.AddLayer("sf:roads");
//layWms.AddLayer("Topography");
//layWms.AddLayer("Hillshading");
layWms.SetImageFormat(layWms.OutputFormats[0]);
layWms.ContinueOnError = true;
//Skip rendering the WMS Map if the server couldn't be requested (if set to false such an event would crash the app)
layWms.TimeOut = 5000; //Set timeout to 5 seconds
layWms.SRID = 4326;
map.Layers.Add(layWms);
//limit the zoom to 360 degrees width
map.MaximumZoom = 360;
map.BackColor = Color.LightBlue;
map.Zoom = 360;
map.Center = new Point(0, 0);
Matrix mat = new Matrix();
mat.RotateAt(angle, map.WorldToImage(map.Center));
map.MapTransform = mat;
map.ZoomToExtents();
return map;
}
示例5: setup
public void setup()
{
Desc = Helper.Description();
Assert.That(Desc, Is.Not.Null);
Map = Helper.Default();
Assert.That(Map, Is.Not.Null);
}
示例6: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
//Set up the map. We use the method in the App_Code folder for initializing the map
myMap = MapHelper.InitializeMap(new System.Drawing.Size((int)imgMap.Width.Value,(int)imgMap.Height.Value));
//Set a gradient theme on the countries layer, based on Population density
SharpMap.Rendering.Thematics.CustomTheme iTheme = new SharpMap.Rendering.Thematics.CustomTheme(GetCountryStyle);
SharpMap.Styles.VectorStyle defaultstyle = new SharpMap.Styles.VectorStyle();
defaultstyle.Fill = Brushes.Gray;
iTheme.DefaultStyle = defaultstyle;
(myMap.Layers[0] as SharpMap.Layers.VectorLayer).Theme = iTheme;
//Turn off the river layer and label-layers
myMap.Layers[1].Enabled = false;
myMap.Layers[3].Enabled = false;
myMap.Layers[4].Enabled = false;
if (Page.IsPostBack)
{
//Page is post back. Restore center and zoom-values from viewstate
myMap.Center = (ICoordinate)ViewState["mapCenter"];
myMap.Zoom = (double)ViewState["mapZoom"];
}
else
{
//This is the initial view of the map. Zoom to the extents of the map:
//myMap.ZoomToExtents();
myMap.Center = GeometryFactory.CreateCoordinate(0, 0);
myMap.Zoom = 360;
//Create the map
GenerateMap();
}
}
示例7: InitializeMap
public static Map InitializeMap()
{
string wmsUrl = "http://www2.demis.nl/mapserver/request.asp";
SharpMap.Map map = new SharpMap.Map();
SharpMap.Layers.WmsLayer layWms = new SharpMap.Layers.WmsLayer("Demis Map", wmsUrl);
layWms.SpatialReferenceSystem = "EPSG:4326";
layWms.AddLayer("Bathymetry");
layWms.AddLayer("Topography");
layWms.AddLayer("Hillshading");
layWms.SetImageFormat(layWms.OutputFormats[0]);
layWms.ContinueOnError = true; //Skip rendering the WMS Map if the server couldn't be requested (if set to false such an event would crash the app)
layWms.TimeOut = 5000; //Set timeout to 5 seconds
layWms.SRID = 4326;
map.Layers.Add(layWms);
//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;
}
示例8: 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";
string url = "http://dev:8080/geoserver/gwc/service/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=getcapabilities&TILED=true";
//string url = "http://dev:8080/geoserver/ows?service=wms&version=1.3.0&request=GetCapabilities&tiled=true";
//TiledWmsLayer tiledWmsLayer = new TiledWmsLayer("Metacarta", url);
//tiledWmsLayer.TileSetsActive.Add(tiledWmsLayer.TileSets["avalon"].Name);
//map.Layers.Add(tiledWmsLayer);
//map.ZoomToBox(new BoundingBox(-180.0, -90.0, 180.0, 90.0));
//WmscRequest req;
//ITileSource tileSource;
TileAsyncLayer tileLayer;
//BruTile.Web.TmsTileSource source2 = new TmsTileSource(url);
var source = new List<ITileSource>(WmscTileSource.CreateFromWmscCapabilties(new System.Uri(url)));
// foreach (ITileSource src in source)
// {
tileLayer = new TileAsyncLayer(source[16], "tileLayer" + source[16]);
tileLayer.MapNewTileAvaliable += map.MapNewTileAvaliableHandler;
map.BackgroundLayer.Add(tileLayer);
// }
map.ZoomToExtents();
return map;
}
示例9: 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;
}
示例10: OnRenderInternal
protected override void OnRenderInternal(Map map, IPolygon polygon, IGraphics g)
{
IPoint pt = polygon.Centroid;
Point renderingOrigin = Point.Truncate(Transform.WorldtoMap(pt.Coordinate, map));
g.RenderingOrigin = new PointStruct(renderingOrigin.X, renderingOrigin.Y);
base.OnRenderInternal(map, polygon, g);
}
示例11: MagnifierTool
/// <summary>
/// Creates an instance of this class
/// </summary>
public MagnifierTool(MapBox parentMapBox)
: base("Magnifier", "A tool to magnify the portion of the map below the cursor")
{
_parentMapBox = parentMapBox;
_parentMapBox.MapChanged += HandleMapChanged;
Map = _parentMapBox.Map;
MagnificationFactor = 1.10;
Offset = new Size(5,5);
_magnified = new PictureBox();
_magnified.Size = new Size(75, 75);
_magnified.BorderStyle = BorderStyle.FixedSingle;
_magnified.Visible = false;
_parentMapBox.Controls.Add(_magnified);
Map = _parentMapBox.Map;
_map = Map.Clone();
_map.Size = _magnified.Size;
_map.Zoom = _map.Size.Width*(Map.Envelope.Width/Map.Size.Width) / _magnification;
_map.Center = _map.Center;
_magnified.Image = _map.GetMap();
Enabled = true;
var ms = Assembly.GetExecutingAssembly().GetManifestResourceStream("WinFormSamples.Magnifier.cur");
if (ms != null)
Cursor = new Cursor(ms);
}
示例12: 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;
}
示例13: InitializeDXF
private static Map InitializeDXF(float angle)
{
Map map = new Map();
//Set the datasource to a shapefile in the App_data folder
Ogr provider;
try
{
provider = new Ogr("GeoData/SampleDXF.dxf",0);
}
catch (TypeInitializationException ex)
{
if (ex.Message == "The type initializer for 'OSGeo.OGR.Ogr' threw an exception.")
{
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/",
GdalRasterLayer.FWToolsVersion));
}
throw;
}
VectorLayer lay = new VectorLayer("SampleDXF", provider);
map.Layers.Add(lay);
map.ZoomToExtents();
Matrix mat = new Matrix();
mat.RotateAt(angle, map.WorldToImage(map.Center));
map.MapTransform = mat;
_ogrSampleDataset = "SampleDXF";
return map;
}
示例14: 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;
}
示例15: TestMaps
private static void TestMaps(string name, Map m, Map mD)
{
Assert.NotNull(mD);
Assert.AreEqual(m.Size, mD.Size);
Assert.AreEqual(m.Layers.Count, mD.Layers.Count);
var c = new LayerTest.VectorLayerEqualityComparer();
for (var i = 0; i < m.Layers.Count; i++)
{
Assert.IsTrue(c.Equals((VectorLayer)m.Layers[i],
(VectorLayer)mD.Layers[i]),
"Layer {0}, '{1}' Differs at {2}",
i, m.Layers[i].LayerName, string.Join(", ", c.DifferAt));
}
Assert.AreEqual(m.PixelAspectRatio, mD.PixelAspectRatio);
Assert.AreEqual(m.PixelHeight, mD.PixelHeight);
Assert.AreEqual(m.PixelWidth, mD.PixelWidth);
Assert.AreEqual(m.PixelSize, mD.PixelSize);
Assert.AreEqual(m.BackColor, mD.BackColor);
Assert.IsTrue(m.Center.Equals(mD.Center));
Assert.IsTrue(m.GetExtents().Equals(mD.GetExtents()));
Assert.IsTrue(m.Envelope.Equals(mD.Envelope));
Assert.AreEqual(m.Decorations.Count, mD.Decorations.Count);
Assert.AreEqual(m.SRID, mD.SRID);
Assert.AreEqual(m.Zoom, mD.Zoom);
Assert.DoesNotThrow(() => m.GetMap().Save(name + "-S.bmp"));
Assert.DoesNotThrow(() => mD.GetMap().Save(name + "-D.bmp"));
}