private void Form2_Load(object sender, EventArgs e) { //TileAsyncLayer osmLayer= new TileAsyncLayer(new OsmTileSource(), "TileLayer - OSM"); TileAsyncLayer bingLayer = new TileAsyncLayer(new BingTileSource(BingRequest.UrlBing, "", BingMapType.Roads), "TileLayer - Bing"); this.mapBox1.Map.BackgroundLayer.Add(bingLayer); #if DotSpatialProjections var mathTransform = LayerTools.Wgs84toGoogleMercator; SharpMap.Geometries.BoundingBox geom = GeometryTransform.TransformBox( new SharpMap.Geometries.BoundingBox(-9.205626, 38.690993, -9.123736, 38.740837), mathTransform.Source, mathTransform.Target); #else var mathTransform = LayerTools.Wgs84toGoogleMercator.MathTransform; SharpMap.Geometries.BoundingBox geom = GeometryTransform.TransformBox( new SharpMap.Geometries.BoundingBox(-9.205626, 38.690993, -9.123736, 38.740837), mathTransform); #endif //Adds a pushpin layer VectorLayer pushPinLayer = new VectorLayer("PushPins"); List <SharpMap.Geometries.Geometry> geos = new List <SharpMap.Geometries.Geometry>(); geos.Add(geom.GetCentroid()); SharpMap.Data.Providers.GeometryProvider geoProvider = new SharpMap.Data.Providers.GeometryProvider(geos); pushPinLayer.DataSource = geoProvider; //this.mapBox1.Map.Layers.Add(pushPinLayer); this.mapBox1.Map.ZoomToBox(geom); this.mapBox1.Map.Zoom = 8500; this.mapBox1.Refresh(); }
private void LoadMap() { Map map = new Map(); ITileSource tileSource = KnownTileSources.Create(KnownTileSource.OpenStreetMap); TileAsyncLayer tileLayer = new TileAsyncLayer(tileSource, "Basemap"); map.BackgroundLayer.Add(tileLayer); VectorLayer shpLayer = new VectorLayer("Points"); shpLayer.DataSource = new ShapeFile("Data/indian_points.shp", true); shpLayer.Style.SymbolScale = 0.8f; shpLayer.CoordinateTransformation = Wgs84toGoogleMercator; //Here it re-projects our degree decimal data to Google mercator shpLayer.ReverseCoordinateTransformation = GoogleMercatorToWgs84; shpLayer.SRID = 4326; map.Layers.Add(shpLayer); mapBox1.Map = map; mapBox1.Map.ZoomToExtents(); mapBox1.Refresh(); }
private void InitBackground(Map map) { var lyr = new TileAsyncLayer(KnownTileSources.Create(KnownTileSource.BingRoads), "Async TileLayer [Bing]"); lyr.SRID = 3857; map.BackgroundLayer.Add(lyr); }
private void Form2_Load(object sender, EventArgs e) { //TileAsyncLayer osmLayer= new TileAsyncLayer(new OsmTileSource(), "TileLayer - OSM"); TileAsyncLayer bingLayer = new TileAsyncLayer(new BingTileSource(BingRequest.UrlBing, "", BingMapType.Roads), "TileLayer - Bing"); this.mapBox1.Map.BackgroundLayer.Add(bingLayer); GeometryFactory gf = new GeometryFactory(new PrecisionModel(), 3857); #if DotSpatialProjections var mathTransform = LayerTools.Wgs84toGoogleMercator; var geom = GeometryTransform.TransformBox( new Envelope(-9.205626, -9.123736, 38.690993, 38.740837), mathTransform.Source, mathTransform.Target); #else IMathTransform mathTransform = LayerTools.Wgs84toGoogleMercator.MathTransform; Envelope geom = GeometryTransform.TransformBox( new Envelope(-9.205626, -9.123736, 38.690993, 38.740837), mathTransform); #endif //Adds a pushpin layer VectorLayer pushPinLayer = new VectorLayer("PushPins"); List <IGeometry> geos = new List <IGeometry>(); geos.Add(gf.CreatePoint(geom.Centre)); var geoProvider = new FeatureProvider(geos); pushPinLayer.DataSource = geoProvider; //this.mapBox1.Map.Layers.Add(pushPinLayer); this.mapBox1.Map.ZoomToBox(geom); this.mapBox1.Map.Zoom = 8500; this.mapBox1.Refresh(); }
void _Click(object sender, EventArgs e) { foreach (ToolStripMenuItem menu in DropDownItems) { menu.Checked = false; } while (mapbox.Map.BackgroundLayer.Count > 0) { mapbox.Map.BackgroundLayer.RemoveAt(0); } MapToolStripMenuItem selectedOption = (MapToolStripMenuItem)sender; mapbox.Map.BackgroundLayer.Add(new TileAsyncLayer(mnuOpenStreetMap.TileSource, mnuOpenStreetMap.Name)); TileAsyncLayer mapLayer = new TileAsyncLayer(selectedOption.TileSource, selectedOption.Name) { OnlyRedrawWhenComplete = true, }; mapbox.Map.BackgroundLayer.Add(mapLayer); selectedOption.Checked = true; opacitySlider.Visible = !selectedOption.Name.Equals(mnuOpenStreetMap.Name); UpdateLinkLabel(selectedOption.LinkLabelType); Application.UserAppDataRegistry.SetValue("Default Map Background", selectedOption.Name); mapbox.Refresh(); }
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://resource.sgu.se/service/wms/130/brunnar?SERVICE=WMS&VERSION=1.3&REQUEST=getcapabilities&TILED=true"; //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); }
private void Form2_Load(object sender, EventArgs e) { var tileLayer = new TileAsyncLayer(KnownTileSources.Create(KnownTileSource.BingRoadsStaging), "TileLayer"); this.mapBox1.Map.BackgroundLayer.Add(tileLayer); GeometryFactory gf = new GeometryFactory(new PrecisionModel(), 3857); IMathTransform mathTransform = LayerTools.Wgs84toGoogleMercator.MathTransform; Envelope geom = GeometryTransform.TransformBox( new Envelope(-9.205626, -9.123736, 38.690993, 38.740837), mathTransform); //Adds a pushpin layer VectorLayer pushPinLayer = new VectorLayer("PushPins"); List <IGeometry> geos = new List <IGeometry>(); geos.Add(gf.CreatePoint(geom.Centre)); GeometryProvider geoProvider = new GeometryProvider(geos); pushPinLayer.DataSource = geoProvider; //this.mapBox1.Map.Layers.Add(pushPinLayer); this.mapBox1.Map.ZoomToBox(geom); this.mapBox1.Map.Zoom = 8500; this.mapBox1.Refresh(); }
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); }
private void SetOpacity() { float opacity = tbOpacity.Value / 100.0f; TileAsyncLayer layer = (TileAsyncLayer)mapBox1.Map.BackgroundLayer[1]; layer.SetOpacity(opacity); }
private void FormDemoDrawGeometries_Load(object sender, EventArgs e) { //this.mapBox1.Map = ShapefileSample.InitializeMap(0); //Google Background TileAsyncLayer bingLayer = new TileAsyncLayer(new BingTileSource(BingRequest.UrlBing, "", BingMapType.Roads), "TileLayer - Bing"); this.mapBox1.Map.BackgroundLayer.Add(bingLayer); SharpMap.Layers.VectorLayer vl = new VectorLayer("My Geometries"); geoProvider = new SharpMap.Data.Providers.GeometryProvider(new List <IGeometry>()); vl.DataSource = geoProvider; this.mapBox1.Map.Layers.Add(vl); #if DotSpatialProjections var mathTransform = LayerTools.Wgs84toGoogleMercator; var geom = GeometryTransform.TransformBox( new Envelope(-9.205626, -9.123736, 38.690993, 38.740837), mathTransform.Source, mathTransform.Target); #else var mathTransform = LayerTools.Wgs84toGoogleMercator.MathTransform; var geom = GeometryTransform.TransformBox( new Envelope(-9.205626, -9.123736, 38.690993, 38.740837), mathTransform); #endif this.mapBox1.Map.ZoomToExtents(); //(geom); this.mapBox1.Refresh(); this.mapBox1.GeometryDefined += new SharpMap.Forms.MapBox.GeometryDefinedHandler(mapBox1_GeometryDefined); this.mapBox1.ActiveToolChanged += new SharpMap.Forms.MapBox.ActiveToolChangedHandler(mapBox1_ActiveToolChanged); this.mapBox1.MouseMove += new SharpMap.Forms.MapBox.MouseEventHandler(mapBox1_MouseMove); }
/// <summary> /// 在线显示,图标显示轨迹 /// </summary> /// <param name="angle"></param> /// <returns></returns> private static Map InitializeMapOsmWithXls2(float angle) { var map = new Map(); var tileLayer = new TileAsyncLayer( KnownTileSources.Create(KnownTileSource.OpenStreetMap), "TileLayer - OSM with XLS"); tileLayer.SRID = 4326; map.BackgroundLayer.Add(tileLayer); //Get data from excel var xlsPath = string.Format(XlsConnectionString, System.IO.Directory.GetCurrentDirectory(), "GeoData\\Henan.xls", Properties.Settings.Default.OleDbProvider); var ds = GetDataFromExcel(xlsPath, "Cities"); var ct = GetCoordinateTransformation(); TransCoordinate(ds, ct); string columeName = "Rotation"; //Add Rotation Column AddColumeToDataSet(ds, columeName, -angle); var xlsLayer = GetLayerFromDataSet2(ds, Color.GreenYellow); //Set up provider map.Layers.Add(xlsLayer); //Add layer to map var xlsLabelLayer = GetLabelLayerByVectorLayer(xlsLayer, "XLSLabel"); xlsLabelLayer.Theme = new FontSizeTheme(xlsLabelLayer, map) { FontSizeScale = 1000f }; map.Layers.Add(xlsLabelLayer); map.ZoomToBox(xlsLayer.Envelope); return(map); }
private static Map InitializeMapOsmWithVariableLayerCollection(float angle) { Map map = new Map(); TileAsyncLayer tileLayer = new TileAsyncLayer(new OsmTileSource(), "TileLayer - OSM with VLC"); map.BackgroundLayer.Add(tileLayer); VectorLayer 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); }
public static SharpMap.Map InitializeMap(float angle) { SharpMap.Map map = new SharpMap.Map { SRID = 3857 }; // Add bru-tile map background var cacheFolder = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "BruTileCache"); var lyrBruTile = new TileAsyncLayer( BruTile.Predefined.KnownTileSources.Create(BruTile.Predefined.KnownTileSource.OpenStreetMap), "Tiles", Color.Transparent, true, cacheFolder) { SRID = 3857 }; map.BackgroundLayer.Add(lyrBruTile); map.BackColor = System.Drawing.Color.LightBlue; // SE Asia map.ZoomToBox(new Envelope(6943700, 19849100, -1472900, 6198900)); Matrix mat = new Matrix(); mat.RotateAt(angle, map.WorldToImage(map.Center)); map.MapTransform = mat; return(map); }
private void button1_Click(object sender, EventArgs e) { TileLayer googleLayer = new TileAsyncLayer(new BingTileSource(new BingRequest(BingRequest.UrlBingStaging, string.Empty, BingMapType.Hybrid)), "TileLayer - Bing"); this.mapBox1.Map.BackgroundLayer.Clear(); this.mapBox1.Map.BackgroundLayer.Add(googleLayer); this.mapBox1.Refresh(); }
private void button1_Click(object sender, EventArgs e) { TileLayer googleLayer = new TileAsyncLayer(new GoogleTileSource(new BruTile.Web.GoogleRequest(GoogleMapType.GoogleMap), new BruTile.Cache.MemoryCache <byte[]>(100, 1000)), "TileLayer - Google"); this.mapBox1.Map.BackgroundLayer.Clear(); this.mapBox1.Map.BackgroundLayer.Add(googleLayer); this.mapBox1.Refresh(); }
private void button5_Click(object sender, EventArgs e) { TileAsyncLayer bingLayer = new TileAsyncLayer(new BingTileSource(BingRequest.UrlBing, "", BingMapType.Roads), "TileLayer - Bing"); this.mapBox1.Map.BackgroundLayer.Clear(); this.mapBox1.Map.BackgroundLayer.Add(bingLayer); this.mapBox1.Refresh(); }
private void button6_Click(object sender, EventArgs e) { TileAsyncLayer osmLayer = new TileAsyncLayer(new OsmTileSource(), "TileLayer - OSM"); this.mapBox1.Map.BackgroundLayer.Clear(); this.mapBox1.Map.BackgroundLayer.Add(osmLayer); this.mapBox1.Refresh(); }
private void button5_Click(object sender, EventArgs e) { TileAsyncLayer bingLayer = new TileAsyncLayer(KnownTileSources.Create(KnownTileSource.BingRoadsStaging), "TileLayer - Bing"); this.mapBox1.Map.BackgroundLayer.Clear(); this.mapBox1.Map.BackgroundLayer.Add(bingLayer); this.mapBox1.Refresh(); }
private void button1_Click(object sender, EventArgs e) { var googleLayer = new TileAsyncLayer(KnownTileSources.Create(KnownTileSource.BingHybridStaging), "TileLayer - Bing"); this.mapBox1.Map.BackgroundLayer.Clear(); this.mapBox1.Map.BackgroundLayer.Add(googleLayer); this.mapBox1.Refresh(); }
private void button6_Click(object sender, EventArgs e) { TileAsyncLayer osmLayer = new TileAsyncLayer(KnownTileSources.Create(KnownTileSource.OpenStreetMap), "TileLayer - OSM"); this.mapBox1.Map.BackgroundLayer.Clear(); this.mapBox1.Map.BackgroundLayer.Add(osmLayer); this.mapBox1.Refresh(); }
void SetOpacity() { if (mapBox1 != null && mapBox1.Map != null && mapBox1.Map.BackgroundLayer.Count > 1) { float opacity = tbOpacity.Value / 100.0f; TileAsyncLayer layer = (TileAsyncLayer)mapBox1.Map.BackgroundLayer[1]; layer.SetOpacity(opacity); } }
private static Map InitializeMapOsm() { Map map = new Map(); TileAsyncLayer tileLayer = new TileAsyncLayer(new OsmTileSource(), "TileLayer - OSM"); map.BackgroundLayer.Add(tileLayer); map.ZoomToBox(tileLayer.Envelope); return(map); }
private void button7_Click(object sender, EventArgs e) { ITileSchema schema = new GlobalSphericalMercator(); ILayer[] layers = CreateLayers(); SharpMapTileSource source = new SharpMapTileSource(schema, layers); TileAsyncLayer osmLayer = new TileAsyncLayer(source, "TileLayer - SharpMap"); this.mapBox1.Map.BackgroundLayer.Clear(); this.mapBox1.Map.BackgroundLayer.Add(osmLayer); this.mapBox1.Refresh(); }
private void FormMovingObjectOverTileLayer_Load(object sender, EventArgs e) { //Lisbon... var mathTransform = LayerTools.Wgs84toGoogleMercator.MathTransform; GeoAPI.Geometries.Envelope geom = GeometryTransform.TransformBox( new Envelope(-9.205626, -9.123736, 38.690993, 38.740837), mathTransform); var map = new SharpMap.Map(); //Google Background TileAsyncLayer layer2 = new TileAsyncLayer(KnownTileSources.Create(KnownTileSource.BingRoads), "TileLayer - Bing"); map.BackgroundLayer.Add(layer2); var gf = new GeometryFactory(new PrecisionModel(), 3857); //Adds a static layer var staticLayer = new VectorLayer("Fixed Marker"); //position = geom.GetCentroid(); var aux = new List <IGeometry>(); aux.Add(gf.CreatePoint(geom.Centre)); staticLayer.Style.Symbol = Resources.PumpSmall; var geoProviderFixed = new SharpMap.Data.Providers.GeometryProvider(aux); staticLayer.DataSource = geoProviderFixed; map.Layers.Add(staticLayer); //Adds a moving variable layer VectorLayer pushPinLayer = new VectorLayer("PushPins"); position = geom.Centre; geos.Add(gf.CreatePoint(position)); pushPinLayer.Style.Symbol = Resources.OutfallSmall; var geoProvider = new SharpMap.Data.Providers.GeometryProvider(geos); pushPinLayer.DataSource = geoProvider; map.VariableLayers.Add(pushPinLayer); map.ZoomToBox(geom); this.mapBox1.Map = map; this.mapBox1.Refresh(); }
private void Form2_Load(object sender, EventArgs e) { var tileLayer = new TileAsyncLayer(KnownTileSources.Create(KnownTileSource.BingRoadsStaging, userAgent: TileLayerSample.DefaultUserAgent), "TileLayer"); this.mapBox1.Map.BackgroundLayer.Add(tileLayer); GeometryFactory gf = new GeometryFactory(new PrecisionModel(), 3857); IMathTransform mathTransform = LayerTools.Wgs84toGoogleMercator.MathTransform; Envelope geom = GeometryTransform.TransformBox( new Envelope(-9.205626, -9.123736, 38.690993, 38.740837), mathTransform); //Adds a pushpin layer VectorLayer pushPinLayer = new VectorLayer("PushPins"); List <IGeometry> geos = new List <IGeometry>(); geos.Add(gf.CreatePoint(geom.Centre)); GeometryProvider geoProvider = new GeometryProvider(geos); pushPinLayer.DataSource = geoProvider; //this.mapBox1.Map.Layers.Add(pushPinLayer); // ScaleBar this.mapBox1.Map.SRID = 3857; this.mapBox1.Map.Decorations.Add( new ScaleBar { Anchor = MapDecorationAnchor.RightCenter, Enabled = chkScaleBar.Checked }); // Graticule this.mapBox1.Map.Decorations.Add(new Graticule() { Enabled = chkGraticule.Checked, PcsGraticuleMode = PcsGraticuleMode.WebMercatorScaleLines, PcsGraticuleStyle = { NumSubdivisions = 2 } }); this.mapBox1.Map.ZoomToBox(geom); this.mapBox1.Map.Zoom = 8500; this.mapBox1.Refresh(); }
private void FormMovingObjectOverTileLayer_Load(object sender, EventArgs e) { //Lisbon... #if DotSpatialProjections var mathTransform = LayerTools.Wgs84toGoogleMercator; SharpMap.Geometries.BoundingBox geom = GeometryTransform.TransformBox( new SharpMap.Geometries.BoundingBox(-9.205626, 38.690993, -9.123736, 38.740837), mathTransform.Source, mathTransform.Target); #else var mathTransform = LayerTools.Wgs84toGoogleMercator.MathTransform; SharpMap.Geometries.BoundingBox geom = GeometryTransform.TransformBox( new SharpMap.Geometries.BoundingBox(-9.205626, 38.690993, -9.123736, 38.740837), mathTransform); #endif //Google Background TileAsyncLayer layer2 = new TileAsyncLayer(new OsmTileSource(), "TileLayer - OSM"); this.mapBox1.Map.BackgroundLayer.Add(layer2); //Adds a static layer VectorLayer staticLayer = new VectorLayer("Fixed Marker"); //position = geom.GetCentroid(); List <SharpMap.Geometries.Geometry> aux = new List <SharpMap.Geometries.Geometry>(); aux.Add(geom.GetCentroid()); staticLayer.Style.Symbol = Resources.PumpSmall; SharpMap.Data.Providers.GeometryProvider geoProviderFixed = new SharpMap.Data.Providers.GeometryProvider(aux); staticLayer.DataSource = geoProviderFixed; this.mapBox1.Map.Layers.Add(staticLayer); //Adds a moving variable layer VectorLayer pushPinLayer = new VectorLayer("PushPins"); position = geom.GetCentroid(); geos.Add(position); pushPinLayer.Style.Symbol = Resources.OutfallSmall; SharpMap.Data.Providers.GeometryProvider geoProvider = new SharpMap.Data.Providers.GeometryProvider(geos); pushPinLayer.DataSource = geoProvider; this.mapBox1.Map.VariableLayers.Add(pushPinLayer); this.mapBox1.Map.ZoomToBox(geom); this.mapBox1.Refresh(); }
private static Map InitializeMapOsmWithXls(float angle) { Map map = new Map(); TileAsyncLayer tileLayer = new TileAsyncLayer(new OsmTileSource(), "TileLayer - OSM with XLS"); map.BackgroundLayer.Add(tileLayer); //Get data from excel string xlsPath = string.Format(XlsConnectionString, Directory.GetCurrentDirectory(), "GeoData\\Cities.xls"); DataSet ds = new DataSet("XLS"); using (OleDbConnection cn = new OleDbConnection(xlsPath)) { cn.Open(); using (OleDbDataAdapter da = new OleDbDataAdapter(new 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 CoordinateTransformationFactory ctf = new CoordinateTransformationFactory(); CoordinateSystemFactory cf = new CoordinateSystemFactory(); ICoordinateSystem 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\"]]"); ICoordinateSystem 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\"]]"); ICoordinateTransformation ct = ctf.CreateFromCoordinateSystems(epsg4326, epsg3857); foreach (DataRow row in ds.Tables[0].Rows) { if (row["X"] == DBNull.Value || row["Y"] == DBNull.Value) { continue; } double[] 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 (DataRow row in ds.Tables[0].Rows) { row["Rotation"] = -angle; } //Set up provider DataTablePoint xlsProvider = new DataTablePoint(ds.Tables[0], "OID", "X", "Y"); VectorLayer xlsLayer = new VectorLayer("XLS", xlsProvider) { Style = { Symbol = VectorStyle.DefaultSymbol } }; //Add layer to map map.Layers.Add(xlsLayer); LabelLayer xlsLabelLayer = new LabelLayer("XLSLabel") { DataSource = xlsProvider, LabelColumn = "Name", PriorityColumn = "Population", Style = { CollisionBuffer = new SizeF(2f, 2f), CollisionDetection = true }, LabelFilter = LabelCollisionDetection.ThoroughCollisionDetection }; map.Layers.Add(xlsLabelLayer); map.ZoomToBox(tileLayer.Envelope); return(map); }
private void _InitialLayers() { m_layers = new Dictionary <string, TileLayer>(); TileAsyncLayer bingLayer = new TileAsyncLayer(new BingTileSource(BingRequest.UrlBing, "", BingMapType.Aerial), "TileLayer - Bing"); //TileAsyncLayer googleLayer = new TileAsyncLayer(new BingTileSource(BingRequest.UrlBing, "", BingMapType.Roads), "TileLayer - Bing"); TileAsyncLayer googleLayer = new TileAsyncLayer(new GoogleTileSource(new GoogleRequest(GoogleMapType.GoogleMap), new BruTile.Cache.MemoryCache <byte[]>(100, 1000)), "TileLayer-Google"); //TileAsyncLayer bingLayer = new TileAsyncLayer(new GoogleTileSource(new GoogleRequest(GoogleMapType.GoogleSatellite), new BruTile.Cache.MemoryCache<byte[]>(100, 1000)), "Satellite-Google"); TileAsyncLayer hybrid = new TileAsyncLayer(new BingTileSource(BingRequest.UrlBing, "", BingMapType.Hybrid), "TileLayer - Bing Hybrid"); m_layers.Add("Bing", bingLayer); m_layers.Add("Google", googleLayer); m_layers.Add("Hybrid", hybrid); //Marker layer markerLayer = new VectorLayer("Fixed Marker"); markerLayer.Style.Symbol = GISAppDemo.Properties.Resources.OutfallSmall; markerLayer.DataSource = markerProvider; Color tRed = Color.FromArgb(50, Color.Red); markerLayer.Style.Fill = new SolidBrush(tRed); //output layer outputLayer = new VectorLayer("Output"); outputLayer.Style.Symbol = GISAppDemo.Properties.Resources.g_arrow; outputLayer.Style.Line.Color = Color.FromArgb(255, Color.Crimson); outputLayer.Style.Line.Width = 3.0F; Color tRed2 = Color.FromArgb(128, Color.Red); outputLayer.Style.Fill = new SolidBrush(tRed2); outputLayer.DataSource = outputProvider; //standard output layer stdOutputLayer = new VectorLayer("StdOutput"); stdOutputLayer.Style.Symbol = GISAppDemo.Properties.Resources.r_arrow; stdOutputLayer.Style.Line.Color = Color.FromArgb(85, Color.Red); stdOutputLayer.Style.Line.Width = 3.0F; stdOutputLayer.DataSource = stdOutputProvider; // green point layer greenPointLayer = new VectorLayer("GreenPoint"); greenPointLayer.Style.PointColor = new SolidBrush(Color.FromArgb(200, Color.Green)); greenPointLayer.Style.PointSize = 6; greenPointLayer.DataSource = greenPointProvider; // red point layer redPointLayer = new VectorLayer("RedPoint"); redPointLayer.Style.PointColor = new SolidBrush(Color.FromArgb(200, Color.Red)); redPointLayer.Style.PointSize = 10; redPointLayer.DataSource = redPointProvider; //Shape Layer shapeLayer = new SharpMap.Layers.VectorLayer("Shape"); shapeLayer.DataSource = new SharpMap.Data.Providers.ShapeFile(shpFileName, true); //Set fill-style to green shapeLayer.Style.Fill = new SolidBrush(Color.Green); //Set the polygons to have a black outline shapeLayer.Style.Outline = Pens.Black; //shapeLayer.Style.Line.Color = Color.Navy; //shapeLayer.Style.Line.Color = Color.FromArgb(200, Color.Gray); shapeLayer.Style.Line.Color = Color.FromArgb(200, Color.Navy); shapeLayer.Style.Line.Width = 1; shapeLayer.Style.PointSize = 2; shapeLayer.Style.PointColor = new SolidBrush(Color.Blue); shapeLayer.SRID = 4326; shapeLayer.CoordinateTransformation = LayerTools.Wgs84toGoogleMercator; // Shape Layer 2 shapeLayer2 = new SharpMap.Layers.VectorLayer("Shape_2"); shapeLayer2.DataSource = new SharpMap.Data.Providers.ShapeFile(shpFileName, true); //Set fill-style to green shapeLayer2.Style.Fill = new SolidBrush(Color.Green); //Set the polygons to have a black outline shapeLayer2.Style.Outline = Pens.Black; //shapeLayer.Style.Line.Color = Color.Navy; //shapeLayer.Style.Line.Color = Color.FromArgb(200, Color.Gray); shapeLayer2.Style.Line.Color = Color.FromArgb(200, Color.Navy); shapeLayer2.Style.Line.Width = 2; shapeLayer2.Style.PointSize = 5; shapeLayer2.Style.PointColor = new SolidBrush(Color.FromArgb(200, Color.Green)); shapeLayer2.SRID = 4326; shapeLayer2.CoordinateTransformation = LayerTools.Wgs84toGoogleMercator; // Shape Layer 3 shapeLayer3 = new SharpMap.Layers.VectorLayer("Shape_3"); shapeLayer3.DataSource = new SharpMap.Data.Providers.ShapeFile(shpFileName, true); //Set fill-style to red shapeLayer3.Style.Fill = new SolidBrush(Color.FromArgb(128, Color.Red)); //Set the polygons to have a black outline shapeLayer3.Style.Outline = Pens.Black; shapeLayer3.Style.Line.Color = Color.FromArgb(255, Color.Crimson); shapeLayer3.Style.Line.Width = 3.0F; shapeLayer3.Style.PointSize = 5; shapeLayer3.Style.PointColor = new SolidBrush(Color.Green); shapeLayer3.SRID = 4326; shapeLayer3.CoordinateTransformation = LayerTools.Wgs84toGoogleMercator; //edgeid layer edgeIdLayer = new LabelLayer("EdgeId"); edgeIdLayer.DataSource = shapeLayer.DataSource; edgeIdLayer.LabelColumn = "ID"; edgeIdLayer.Style.ForeColor = Color.Navy; edgeIdLayer.Style.Font = new Font(FontFamily.GenericSerif, 16); edgeIdLayer.CoordinateTransformation = LayerTools.Wgs84toGoogleMercator; }