using System; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Drawing; using System.IO; using System.Web; using ThinkGeo.MapSuite.Core; using ThinkGeo.MapSuite.WmsServerEdition; namespace WmsPlugins { public class ShowUserSpecificMapsWmsLayerPlugin : WmsLayerPlugin { public ShowUserSpecificMapsWmsLayerPlugin() { this.WmsQueryMode = WmsQueryMode.Queryable; } // This method is only called once per style and crs. In it you should create your // layers and add them to the MapConfiguration. If you want to use tile caching you // can also specif that in the MapConfiguration under the TileCache property. // If you have setup multiple styles or projections this method will get called for // each unique combination protected override MapConfiguration GetMapConfigurationCore(string style, string crs) { // Get the paths to the sample data string path = Directory.GetParent(Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).FullName).FullName; string worldLayerFilePath = path + "\\SampleData\\Countries02.shp"; string stateFilePath = path + "\\SampleData\\STATES.SHP"; string citiesFilePath = path + "\\SampleData\\cities_a.shp"; // Setup the various shape file layers ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(worldLayerFilePath); worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1; worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; worldLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.Country1("World"); worldLayer.FeatureSource.CustomColumnFetch += new EventHandler(FeatureSource_CustomColumnFetch); ShapeFileFeatureLayer statesLayer = new ShapeFileFeatureLayer(stateFilePath); statesLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.County1("State"); statesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(255, 243, 239, 228), GeoColor.FromArgb(255, 218, 193, 163), 1); statesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; statesLayer.FeatureSource.CustomColumnFetch += new EventHandler(FeatureSource_CustomColumnFetch); ShapeFileFeatureLayer citiesLayer = new ShapeFileFeatureLayer(citiesFilePath); citiesLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.City3; citiesLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = new TextStyle("Cities", new GeoFont("Verdana", 9), new GeoSolidBrush(GeoColor.StandardColors.Black)); citiesLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.HaloPen = new GeoPen(GeoColor.StandardColors.White, 2); citiesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; citiesLayer.DrawingMarginPercentage = 50; citiesLayer.FeatureSource.CustomColumnFetch += new EventHandler(FeatureSource_CustomColumnFetch); // Create a MapConfiguration and add the layer to it MapConfiguration mapConfiguration = new MapConfiguration(); mapConfiguration.Layers.Add("WorldLayer", worldLayer); mapConfiguration.Layers.Add("StatesLayer", statesLayer); mapConfiguration.Layers.Add("CitiesLayer", citiesLayer); return mapConfiguration; } void FeatureSource_CustomColumnFetch(object sender, CustomColumnFetchEventArgs e) { string columnName = e.ColumnName; e.ColumnValue = columnName + ": " + e.Id; } // In this method you need to return the name of the Layer that WMS will expose. // You will use this name on the client to specify the layer you want to consume protected override string GetNameCore() { return "Show User Specific Maps"; } // In this method you need to return the projections that are supported by your data. // It is your responsability to project the data in the MapConfiguration for each projection // type you specify here. protected override Collection GetProjectionsCore() { return new Collection { "EPSG:4326" }; } // In this method you need to return the bounding box of the layer. protected override RectangleShape GetBoundingBoxCore(string crs) { return new RectangleShape(-126.826171875, 57.104766845702, -70.83984375, 18.960235595702); } } }