private static VectorLayer CrearCapaTemaAdscripcion(IUnidadGeoEstadistica uge) { if (uge is PlantaEdificio) { PlantaEdificio pe = (PlantaEdificio)uge; //Montar la consulta de los dptos ordenados por superficie _dsTemas = pe.EstadisticaDepartamentosSIGUA(); _capaTemaAdsc = new SharpMap.Layers.VectorLayer(pe.Codigo); SharpMap.Data.Providers.PostGIS proveedorPostgis = new SharpMap.Data.Providers.PostGIS(SIGUANETDesktop.DB.DBUtils.GetPGSQLCnString(), "sig" + pe.Planta.ToString().ToLower(), "gid"); proveedorPostgis.DefinitionQuery = string.Format("codigo like '{0}%' AND actividad <> 93", pe.Codigo); _capaTemaAdsc.DataSource = proveedorPostgis; //Llama a la función delegada para pintar adscripcion CustomTheme generadorEstilos = new SharpMap.Rendering.Thematics.CustomTheme(CrearEstiloPorAdscripcion); VectorStyle estiloPorDefecto = SIGUANETDesktop.ModeloCartografia.Simbologia.Paleta.obtenerEstiloPorDefecto(_paleta); generadorEstilos.DefaultStyle = estiloPorDefecto; _capaTemaAdsc.Theme = generadorEstilos; NuevaEntradaLeyendaTematica(TipoMapa.TemaAdscripcion, _capaTemaAdsc.LayerName, _capaTemaAdsc, "Temático por Adscripción", EntradaLeyendaTematica.TipoOrdenacion.Descendente); return(_capaTemaAdsc); } else { return(null); } }
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 = (SharpMap.Geometries.Point)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 = new SharpMap.Geometries.Point(0, 0); myMap.Zoom = 360; //Create the map GenerateMap(); } }
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 and alter it afterwards myMap = MapHelper.InitializeMap(new System.Drawing.Size((int)imgMap.Width.Value, (int)imgMap.Height.Value)); //Remove the river layer and label-layers myMap.Layers.RemoveAt(4); myMap.Layers.RemoveAt(3); myMap.Layers.RemoveAt(1); //Create Pie Layer SharpMap.Layers.VectorLayer pieLayer = new SharpMap.Layers.VectorLayer("Pie charts"); pieLayer.DataSource = (myMap.Layers[0] as SharpMap.Layers.VectorLayer).DataSource; SharpMap.Rendering.Thematics.CustomTheme iTheme = new SharpMap.Rendering.Thematics.CustomTheme(GetCountryStyle); pieLayer.Theme = iTheme; myMap.Layers.Add(pieLayer); 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(10, 50); myMap.Zoom = 60; //Create the map GenerateMap(); } }
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(); } }
private HtmlGenericControl LegendDiv(SharpMap.Layers.ILayer myLayer) { HtmlGenericControl legendDiv = new HtmlGenericControl("div"); legendDiv.Style.Add("width", "2em"); legendDiv.Style.Add("overflow", "hidden"); legendDiv.Style.Add("position", "absolute"); legendDiv.Style.Add("margin-left", "0.5em"); legendDiv.Style.Add("margin-bottom", "0px"); if (myLayer.GetType() == typeof(SharpMap.Layers.VectorLayer)) { SharpMap.Layers.VectorLayer myVectorLayer = (myLayer as SharpMap.Layers.VectorLayer); SharpMap.Styles.VectorStyle myStyle = new SharpMap.Styles.VectorStyle(); if (myVectorLayer.Theme != null) { if (myVectorLayer.Theme.GetType() == typeof(SharpMap.Rendering.Thematics.CustomTheme)) { SharpMap.Rendering.Thematics.CustomTheme myTheme = (myVectorLayer.Theme as SharpMap.Rendering.Thematics.CustomTheme); myStyle = (myTheme.DefaultStyle as SharpMap.Styles.VectorStyle); } else if (myVectorLayer.Theme.GetType() == typeof(SharpMap.Rendering.Thematics.GradientTheme)) { SharpMap.Rendering.Thematics.GradientTheme myTheme = (myVectorLayer.Theme as SharpMap.Rendering.Thematics.GradientTheme); myStyle = (myTheme.MinStyle as SharpMap.Styles.VectorStyle); } } else { myStyle = myVectorLayer.Style; } if (myStyle.Outline.Color.Name.ToString() != "Black") { string lineStyle = (myStyle.Outline.DashStyle.ToString() == "Dash") ? "dotted" : "solid"; legendDiv.Style.Add("border", lineStyle + " " + myStyle.Outline.Width.ToString() + "px " + ColorToHex(myStyle.Outline.Color)); legendDiv.Style.Add("height", "1em"); } else { string lineStyle = (myStyle.Line.DashStyle.ToString() == "Dash") ? "dotted" : "solid"; legendDiv.Style.Add("border-bottom", lineStyle + " " + myStyle.Line.Width.ToString() + "px " + ColorToHex(myStyle.Line.Color)); legendDiv.Style.Add("height", "0.8em"); } System.Drawing.SolidBrush fillBrush = (myVectorLayer.Style.Fill as System.Drawing.SolidBrush); if (fillBrush.Color.Name.ToString() != "Black") { HtmlGenericControl fillDiv = new HtmlGenericControl("div"); fillDiv.Style.Add("border-left", "solid 2em " + ColorToHex(fillBrush.Color)); fillDiv.Style.Add("height", "1.2em"); fillDiv.Style.Add("overflow", "hidden"); fillDiv.Style.Add("opacity ", ColorAlpha(fillBrush.Color) + "%"); fillDiv.Style.Add("filter", "ALPHA(opacity=" + ColorAlpha(fillBrush.Color) + ")"); legendDiv.Controls.Add(fillDiv); } } return(legendDiv); }
public object Clone() { CustomTheme customTheme = new CustomTheme(this._getStyleDelegate); if (DefaultStyle != null) { customTheme.DefaultStyle = (IStyle)DefaultStyle.Clone(); } return(customTheme); }
public VectorLayer getPolygonPoints(PointF points, VectorLayer veclayer) { //VectorLayer veclayer = (VectorLayer)m_viewBox.Map.GetLayerByName("province"); SharpMap.Layers.VectorLayer laySelected = new SharpMap.Layers.VectorLayer("Selection"); ; CustomTheme myTheme = new CustomTheme(FeatureColoured); ShapeFile vecshp = (ShapeFile)veclayer.DataSource; ShapeFile shp = vecshp; if (!shp.IsOpen) shp.Open(); FeatureDataSet featDataSet = new FeatureDataSet(); FeatureDataTable featDataTable = null; //将point的大地坐标转为经纬度 Projection pj = new Projection(); points = pj.GetLatLonFromXY(points,cfg.pjPara); // 获取feature数量 uint featCount = (uint)shp.GetFeatureCount(); for (uint index = 0; index < featCount; index++) { FeatureDataRow r = shp.GetFeature(index); GeoAPI.Geometries.Coordinate[] geomes = r.Geometry.Coordinates; double[] geomsX = new double[geomes.Length]; double[] geomsY = new double[geomes.Length]; for (int j = 0; j < geomes.Length; j++) { geomsX[j] = geomes[j].X; geomsY[j] = geomes[j].Y; } if ((points.X < geomsX.Min()) || (points.X > geomsX.Max()) || (points.Y < geomsY.Min()) || (points.Y > geomsY.Max())) { continue; } PointF p1 = new PointF(); p1.X = points.X; p1.Y = points.Y; if (InPolygon(geomes, p1)) { //首先把geomes传出去,供其他使用 ContourGeomes = geomes; //如果在某区域内,选中某个区域,放入新图层 laySelected.DataSource = new SharpMap.Data.Providers.GeometryProvider(shp.GetFeature(index)); polygon = ((NetTopologySuite.Geometries.Polygon)r.Geometry); laySelected.Style.Fill = new System.Drawing.SolidBrush(Color.HotPink); laySelected.CoordinateTransformation = veclayer.CoordinateTransformation; } } return laySelected; }
private static VectorLayer CrearCapaTemaUsos(IUnidadGeoEstadistica uge) { if (uge is PlantaEdificio) { PlantaEdificio pe = (PlantaEdificio)uge; _capaTemaUsos = new SharpMap.Layers.VectorLayer(pe.Codigo); SharpMap.Data.Providers.PostGIS proveedorPostgis = new SharpMap.Data.Providers.PostGIS(SIGUANETDesktop.DB.DBUtils.GetPGSQLCnString(), "sig" + pe.Planta.ToString().ToLower(), "gid"); proveedorPostgis.DefinitionQuery = string.Format("codigo like '{0}%' AND actividad <> 93", pe.Codigo); _capaTemaUsos.DataSource = proveedorPostgis; CustomTheme generadorEstilos = new SharpMap.Rendering.Thematics.CustomTheme(CrearEstiloPorActividad); VectorStyle estiloPorDefecto = SIGUANETDesktop.ModeloCartografia.Simbologia.Paleta.obtenerEstiloPorDefecto(_paleta); generadorEstilos.DefaultStyle = estiloPorDefecto; _capaTemaUsos.Theme = generadorEstilos; NuevaEntradaLeyendaTematica(TipoMapa.TemaUso, _capaTemaUsos.LayerName, _capaTemaUsos, "Temático por Uso", EntradaLeyendaTematica.TipoOrdenacion.Ascendente); return(_capaTemaUsos); } else { return(null); } }
public SelectTool() { orgClickTime = DateTime.Now; FeatureEditors = new List<IFeatureEditor>(); Name = "Select"; trackingLayer.Name = "trackers"; FeatureCollection trackerProvider = new FeatureCollection {Features = trackers}; trackingLayer.DataSource = trackerProvider; CustomTheme iTheme = new CustomTheme(GetTrackerStyle); trackingLayer.Theme = iTheme; }
public static SharpMap.Map InitializeMap(Size size, string colors, string colorsLine) { HttpContext.Current.Trace.Write("Initializing map..."); //Initialize a new map of size 'imagesize' var map = new SharpMap.Map(size); var blackPen = new Pen(Color.FromArgb(255, 0, 0, 0), 1); var blackPen2 = new Pen(Color.FromArgb(255, 0, 0, 0), 2); var greenPen = new Pen(Color.FromArgb(255, 0, 255, 0), 1); var greenPenTransp = new Pen(Color.FromArgb(255, 0, 255, 0), 1); greenPenTransp.Color = Color.FromArgb(100, greenPenTransp.Color.R, greenPenTransp.Color.G, greenPenTransp.Color.B); var redPen = new Pen(Color.FromArgb(255, 255, 0, 0), 1); var bluePen = new Pen(Color.FromArgb(255, 0, 0, 255), 1); var violetPen = new Pen(Color.FromArgb(255, 255, 0, 255), 1); var cyanPen = new Pen(Color.FromArgb(255, 0, 255, 255), 1); var yellowPen = new Pen(Color.FromArgb(255, 255, 255, 0), 1); var darkGrayPen = new Pen(Color.DarkGray, 1); var darkGrayPenTransp = new Pen(Color.DarkGray, 1); darkGrayPenTransp.Color = Color.FromArgb(100, darkGrayPenTransp.Color.R, darkGrayPenTransp.Color.G, darkGrayPenTransp.Color.B); var lightBluePen = new Pen(Color.LightBlue, 1); var lightGreenPen = new Pen(Color.LightGreen, 1); var lightGrayPen = new Pen(Color.FromArgb(255, 234, 234, 234)); var darkGreenPen = new Pen(Color.DarkGreen); var azurePen = new Pen(Color.DarkKhaki); var lightGoldenrodYellowPen = new Pen(Color.LightGoldenrodYellow); Dictionary<string, Color> colorFill = new Dictionary<string, Color>(); if (colors != null) { colors = colors.Replace(",", ""); string[] parts = colors.Split('|'); for (int i = 0; i < parts.Length; i++) { if (parts[i] != "") { string[] pair = parts[i].Split('='); try { colorFill.Add(pair[0], Color.FromName(pair[1])); } catch { } } } } else { colorFill["Lviv"] = Color.FromArgb(255, 234, 234, 234); colorFill["Suburbs2"] = lightGrayPen.Color; colorFill["Parks"] = darkGreenPen.Color; colorFill["Suburbs1"] = lightGrayPen.Color; colorFill["Homes"] = azurePen.Color; colorFill["Proms"] = darkGrayPen.Color; colorFill["FuelStations"] = Color.FromArgb(255, 234, 234, 234); } Dictionary<string, Color> colorLineDict = new Dictionary<string, Color>(); if (colors != null) { colorsLine = colorsLine.Replace(",", ""); string[] parts = colorsLine.Split('|'); for (int i = 0; i < parts.Length; i++) { if (parts[i] != "") { string[] pair = parts[i].Split('='); try { colorLineDict.Add(pair[0], Color.FromName(pair[1])); } catch { } } } } else { colorLineDict["Lviv"] = blackPen.Color; colorLineDict["Suburbs2"] = blackPen.Color; colorLineDict["Parks"] = blackPen.Color; colorLineDict["Suburbs1"] = blackPen.Color; colorLineDict["Homes"] = blackPen.Color; colorLineDict["Proms"] = blackPen.Color; colorLineDict["FuelStations"] = blackPen.Color; } bool town = true; if (town) { var lvivBlockLayer = new VectorLayer("Lviv"); lvivBlockLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath( @"~\App_Data\maps_lviv_new\block.shp"), true); lvivBlockLayer.Style.Outline = new Pen(colorLineDict["Lviv"]); lvivBlockLayer.Style.Fill = new SolidBrush( colorFill["Lviv"] ); lvivBlockLayer.Style.EnableOutline = true; map.Layers.Add(lvivBlockLayer); var suburbsLayer2 = new VectorLayer("Suburbs2"); suburbsLayer2.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath(@"~\App_Data\maps_lviv_new\LLSITY12.shp"), true); suburbsLayer2.Style.Outline = new Pen(colorLineDict["Suburbs2"]); suburbsLayer2.Style.Fill = new SolidBrush(colorFill["Suburbs2"]); suburbsLayer2.Style.EnableOutline = true; map.Layers.Add(suburbsLayer2); var parksLayer = new VectorLayer("Parks"); parksLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath(@"~\App_Data\maps_lviv_new\LLVGREN1.shp"), true); parksLayer.Style.Outline = new Pen(colorLineDict["Parks"]); parksLayer.Style.Fill = new SolidBrush(colorFill["Parks"]); parksLayer.Style.EnableOutline = true; map.Layers.Add(parksLayer); var suburbsLayer1 = new VectorLayer("Suburbs1"); suburbsLayer1.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath(@"~\App_Data\maps_lviv_new\LLVELL12.shp"), true); suburbsLayer1.Style.Outline = new Pen(colorLineDict["Suburbs1"]); suburbsLayer1.Style.Fill = new SolidBrush(colorFill["Suburbs1"]); suburbsLayer1.Style.EnableOutline = true; map.Layers.Add(suburbsLayer1); //homes var homesLayer = new VectorLayer("Homes"); homesLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath(@"~\App_Data\maps_lviv_new\LLVHOM12.shp"), true); homesLayer.Style.Outline = new Pen(colorLineDict["Homes"]); homesLayer.Style.Fill = new SolidBrush(colorFill["Homes"]); homesLayer.Style.EnableOutline = true; map.Layers.Add(homesLayer); //proms var promLayer = new VectorLayer("Proms"); promLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath(@"~\App_Data\maps_lviv_new\LLVPROM.shp"), true); promLayer.Style.Outline = new Pen(colorLineDict["Proms"]); promLayer.Style.Fill = new SolidBrush(colorFill["Proms"]); promLayer.Style.EnableOutline = true; map.Layers.Add(promLayer); VectorLayer fuelStationLayer = new VectorLayer("FuelStations"); fuelStationLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath( @"~\App_Data\FuelStationsLayers\LvivCityCorr\fuel_stations_lviv.shp"), true); fuelStationLayer.Style.Outline = new Pen(colorLineDict["FuelStations"]); fuelStationLayer.Style.Fill = new SolidBrush(colorFill["FuelStations"]); fuelStationLayer.Style.EnableOutline = true; //fuelStationLayer.Style.PointColor = Brushes.AliceBlue; SharpMap.Rendering.Thematics.CustomTheme myTheme = new SharpMap.Rendering.Thematics.CustomTheme(GetFullStationStyle); fuelStationLayer.Theme = myTheme; map.Layers.Add(fuelStationLayer); //var tmp6 = new VectorLayer("Lviv"){DataSource = new ShapeFile(HttpContext.Current.Server.MapPath(@"~\App_Data\maps_lviv_new\LROAD12.shp"), true)}; //tmp6.Style.Outline = waPen6; //tmp6.Style.Fill = new SolidBrush(Color.FromArgb(255, 234, 234, 234)); //tmp6.Style.EnableOutline = true; //map.Layers.Add(tmp6); } else { var lvivRegioonLayer = new VectorLayer("Region"); lvivRegioonLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath( @"~\App_Data\Lviv_Region_Romik\lv_line.shp"), true); lvivRegioonLayer.Style.Outline = blackPen2; lvivRegioonLayer.Style.Fill = new SolidBrush(Color.FromArgb(255, 234, 234, 234)); lvivRegioonLayer.Style.EnableOutline = true; map.Layers.Add(lvivRegioonLayer); var territoryLayer = new VectorLayer("Regions"); territoryLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath( @"~\App_Data\Lviv_Region_Romik\terrytor.shp"), true); territoryLayer.Style.Outline = darkGrayPenTransp; territoryLayer.Style.Fill = new SolidBrush(lightGoldenrodYellowPen.Color); territoryLayer.Style.EnableOutline = true; map.Layers.Add(territoryLayer); var lakesLayer = new VectorLayer("Lakes"); lakesLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath( @"~\App_Data\Lviv_Region_Romik\vodoimy.shp"), true); lakesLayer.Style.Outline = blackPen; lakesLayer.Style.Fill = new SolidBrush(bluePen.Color); lakesLayer.Style.EnableOutline = true; map.Layers.Add(lakesLayer); var punkLayer = new VectorLayer("Punks"); punkLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath( @"~\App_Data\Lviv_Region_Romik\nas_punk.shp"), true); punkLayer.Style.Outline = blackPen; punkLayer.Style.Fill = new SolidBrush(darkGrayPen.Color); punkLayer.Style.EnableOutline = true; map.Layers.Add(punkLayer); var railsLayer = new VectorLayer("Rails"); railsLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath( @"~\App_Data\Lviv_Region_Romik\zal_kol.shp"), true); //map.Layers.Add(railsLayer); var fuelStationLayer = new VectorLayer("FuelStations"); fuelStationLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath( @"~\App_Data\FuelStationsLayers\LvivObl\fuel_stations.shp"), true); fuelStationLayer.Style.PointColor = Brushes.AliceBlue; map.Layers.Add(fuelStationLayer); var roadsLayer = new VectorLayer("Roads"); roadsLayer.Style.Outline = blackPen; roadsLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath( @"~\App_Data\Lviv_Region_Romik\meregi.shp"), true); map.Layers.Add(roadsLayer); } GeoAPI.Geometries.Envelope mapExtents = map.GetExtents(); //SharpMap.Geometries.BoundingBox mapExtents = map.GetExtents(); map.Zoom = mapExtents.Width; map.MaximumZoom = mapExtents.Width; map.MinimumZoom = 2000; map.Center = mapExtents.Centre; map.BackColor = Color.White; map.ZoomToExtents(); HttpContext.Current.Trace.Write("Map initialized"); return map; }
private static themeCustom GetThemeCustom(CustomTheme theme) { string defaultStyle = GetDefaultStyle(theme); return new themeCustom {defaultStyle = defaultStyle}; }
public static SharpMap.Map InitializeMap(Size size, string colors, string colorsLine) { HttpContext.Current.Trace.Write("Initializing map..."); //Initialize a new map of size 'imagesize' var map = new SharpMap.Map(size); var blackPen = new Pen(Color.FromArgb(255, 0, 0, 0), 1); var blackPen2 = new Pen(Color.FromArgb(255, 0, 0, 0), 2); var greenPen = new Pen(Color.FromArgb(255, 0, 255, 0), 1); var greenPenTransp = new Pen(Color.FromArgb(255, 0, 255, 0), 1); greenPenTransp.Color = Color.FromArgb(100, greenPenTransp.Color.R, greenPenTransp.Color.G, greenPenTransp.Color.B); var redPen = new Pen(Color.FromArgb(255, 255, 0, 0), 1); var bluePen = new Pen(Color.FromArgb(255, 0, 0, 255), 1); var violetPen = new Pen(Color.FromArgb(255, 255, 0, 255), 1); var cyanPen = new Pen(Color.FromArgb(255, 0, 255, 255), 1); var yellowPen = new Pen(Color.FromArgb(255, 255, 255, 0), 1); var darkGrayPen = new Pen(Color.DarkGray, 1); var darkGrayPenTransp = new Pen(Color.DarkGray, 1); darkGrayPenTransp.Color = Color.FromArgb(100, darkGrayPenTransp.Color.R, darkGrayPenTransp.Color.G, darkGrayPenTransp.Color.B); var lightBluePen = new Pen(Color.LightBlue, 1); var lightGreenPen = new Pen(Color.LightGreen, 1); var lightGrayPen = new Pen(Color.FromArgb(255, 234, 234, 234)); var darkGreenPen = new Pen(Color.DarkGreen); var azurePen = new Pen(Color.DarkKhaki); var lightGoldenrodYellowPen = new Pen(Color.LightGoldenrodYellow); Dictionary <string, Color> colorFill = new Dictionary <string, Color>(); if (colors != null) { colors = colors.Replace(",", ""); string[] parts = colors.Split('|'); for (int i = 0; i < parts.Length; i++) { if (parts[i] != "") { string[] pair = parts[i].Split('='); try { colorFill.Add(pair[0], Color.FromName(pair[1])); } catch { } } } } else { colorFill["Lviv"] = Color.FromArgb(255, 234, 234, 234); colorFill["Suburbs2"] = lightGrayPen.Color; colorFill["Parks"] = darkGreenPen.Color; colorFill["Suburbs1"] = lightGrayPen.Color; colorFill["Homes"] = azurePen.Color; colorFill["Proms"] = darkGrayPen.Color; colorFill["FuelStations"] = Color.FromArgb(255, 234, 234, 234); } Dictionary <string, Color> colorLineDict = new Dictionary <string, Color>(); if (colors != null) { colorsLine = colorsLine.Replace(",", ""); string[] parts = colorsLine.Split('|'); for (int i = 0; i < parts.Length; i++) { if (parts[i] != "") { string[] pair = parts[i].Split('='); try { colorLineDict.Add(pair[0], Color.FromName(pair[1])); } catch { } } } } else { colorLineDict["Lviv"] = blackPen.Color; colorLineDict["Suburbs2"] = blackPen.Color; colorLineDict["Parks"] = blackPen.Color; colorLineDict["Suburbs1"] = blackPen.Color; colorLineDict["Homes"] = blackPen.Color; colorLineDict["Proms"] = blackPen.Color; colorLineDict["FuelStations"] = blackPen.Color; } bool town = true; if (town) { var lvivBlockLayer = new VectorLayer("Lviv"); lvivBlockLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath( @"~\App_Data\maps_lviv_new\block.shp"), true); lvivBlockLayer.Style.Outline = new Pen(colorLineDict["Lviv"]); lvivBlockLayer.Style.Fill = new SolidBrush(colorFill["Lviv"]); lvivBlockLayer.Style.EnableOutline = true; map.Layers.Add(lvivBlockLayer); var suburbsLayer2 = new VectorLayer("Suburbs2"); suburbsLayer2.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath(@"~\App_Data\maps_lviv_new\LLSITY12.shp"), true); suburbsLayer2.Style.Outline = new Pen(colorLineDict["Suburbs2"]); suburbsLayer2.Style.Fill = new SolidBrush(colorFill["Suburbs2"]); suburbsLayer2.Style.EnableOutline = true; map.Layers.Add(suburbsLayer2); var parksLayer = new VectorLayer("Parks"); parksLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath(@"~\App_Data\maps_lviv_new\LLVGREN1.shp"), true); parksLayer.Style.Outline = new Pen(colorLineDict["Parks"]); parksLayer.Style.Fill = new SolidBrush(colorFill["Parks"]); parksLayer.Style.EnableOutline = true; map.Layers.Add(parksLayer); var suburbsLayer1 = new VectorLayer("Suburbs1"); suburbsLayer1.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath(@"~\App_Data\maps_lviv_new\LLVELL12.shp"), true); suburbsLayer1.Style.Outline = new Pen(colorLineDict["Suburbs1"]); suburbsLayer1.Style.Fill = new SolidBrush(colorFill["Suburbs1"]); suburbsLayer1.Style.EnableOutline = true; map.Layers.Add(suburbsLayer1); //homes var homesLayer = new VectorLayer("Homes"); homesLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath(@"~\App_Data\maps_lviv_new\LLVHOM12.shp"), true); homesLayer.Style.Outline = new Pen(colorLineDict["Homes"]); homesLayer.Style.Fill = new SolidBrush(colorFill["Homes"]); homesLayer.Style.EnableOutline = true; map.Layers.Add(homesLayer); //proms var promLayer = new VectorLayer("Proms"); promLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath(@"~\App_Data\maps_lviv_new\LLVPROM.shp"), true); promLayer.Style.Outline = new Pen(colorLineDict["Proms"]); promLayer.Style.Fill = new SolidBrush(colorFill["Proms"]); promLayer.Style.EnableOutline = true; map.Layers.Add(promLayer); VectorLayer fuelStationLayer = new VectorLayer("FuelStations"); fuelStationLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath( @"~\App_Data\FuelStationsLayers\LvivCityCorr\fuel_stations_lviv.shp"), true); fuelStationLayer.Style.Outline = new Pen(colorLineDict["FuelStations"]); fuelStationLayer.Style.Fill = new SolidBrush(colorFill["FuelStations"]); fuelStationLayer.Style.EnableOutline = true; //fuelStationLayer.Style.PointColor = Brushes.AliceBlue; SharpMap.Rendering.Thematics.CustomTheme myTheme = new SharpMap.Rendering.Thematics.CustomTheme(GetFullStationStyle); fuelStationLayer.Theme = myTheme; map.Layers.Add(fuelStationLayer); //var tmp6 = new VectorLayer("Lviv"){DataSource = new ShapeFile(HttpContext.Current.Server.MapPath(@"~\App_Data\maps_lviv_new\LROAD12.shp"), true)}; //tmp6.Style.Outline = waPen6; //tmp6.Style.Fill = new SolidBrush(Color.FromArgb(255, 234, 234, 234)); //tmp6.Style.EnableOutline = true; //map.Layers.Add(tmp6); } else { var lvivRegioonLayer = new VectorLayer("Region"); lvivRegioonLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath( @"~\App_Data\Lviv_Region_Romik\lv_line.shp"), true); lvivRegioonLayer.Style.Outline = blackPen2; lvivRegioonLayer.Style.Fill = new SolidBrush(Color.FromArgb(255, 234, 234, 234)); lvivRegioonLayer.Style.EnableOutline = true; map.Layers.Add(lvivRegioonLayer); var territoryLayer = new VectorLayer("Regions"); territoryLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath( @"~\App_Data\Lviv_Region_Romik\terrytor.shp"), true); territoryLayer.Style.Outline = darkGrayPenTransp; territoryLayer.Style.Fill = new SolidBrush(lightGoldenrodYellowPen.Color); territoryLayer.Style.EnableOutline = true; map.Layers.Add(territoryLayer); var lakesLayer = new VectorLayer("Lakes"); lakesLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath( @"~\App_Data\Lviv_Region_Romik\vodoimy.shp"), true); lakesLayer.Style.Outline = blackPen; lakesLayer.Style.Fill = new SolidBrush(bluePen.Color); lakesLayer.Style.EnableOutline = true; map.Layers.Add(lakesLayer); var punkLayer = new VectorLayer("Punks"); punkLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath( @"~\App_Data\Lviv_Region_Romik\nas_punk.shp"), true); punkLayer.Style.Outline = blackPen; punkLayer.Style.Fill = new SolidBrush(darkGrayPen.Color); punkLayer.Style.EnableOutline = true; map.Layers.Add(punkLayer); var railsLayer = new VectorLayer("Rails"); railsLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath( @"~\App_Data\Lviv_Region_Romik\zal_kol.shp"), true); //map.Layers.Add(railsLayer); var fuelStationLayer = new VectorLayer("FuelStations"); fuelStationLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath( @"~\App_Data\FuelStationsLayers\LvivObl\fuel_stations.shp"), true); fuelStationLayer.Style.PointColor = Brushes.AliceBlue; map.Layers.Add(fuelStationLayer); var roadsLayer = new VectorLayer("Roads"); roadsLayer.Style.Outline = blackPen; roadsLayer.DataSource = new ShapeFile( HttpContext.Current.Server.MapPath( @"~\App_Data\Lviv_Region_Romik\meregi.shp"), true); map.Layers.Add(roadsLayer); } GeoAPI.Geometries.Envelope mapExtents = map.GetExtents(); //SharpMap.Geometries.BoundingBox mapExtents = map.GetExtents(); map.Zoom = mapExtents.Width; map.MaximumZoom = mapExtents.Width; map.MinimumZoom = 2000; map.Center = mapExtents.Centre; map.BackColor = Color.White; map.ZoomToExtents(); HttpContext.Current.Trace.Write("Map initialized"); return(map); }
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 and alter it afterwards myMap = MapHelper.InitializeMap(new System.Drawing.Size((int)imgMap.Width.Value,(int)imgMap.Height.Value)); //Remove the river layer and label-layers myMap.Layers.RemoveAt(4); myMap.Layers.RemoveAt(3); myMap.Layers.RemoveAt(1); //Create Pie Layer SharpMap.Layers.VectorLayer pieLayer = new SharpMap.Layers.VectorLayer("Pie charts"); pieLayer.DataSource = (myMap.Layers[0] as SharpMap.Layers.VectorLayer).DataSource; SharpMap.Rendering.Thematics.CustomTheme iTheme = new SharpMap.Rendering.Thematics.CustomTheme(GetCountryStyle); pieLayer.Theme = iTheme; myMap.Layers.Add(pieLayer); 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(10,50); myMap.Zoom = 60; //Create the map GenerateMap(); } }