IMapDataAdapter CreateData(object datasource) { BubbleChartDataAdapter adapter = new BubbleChartDataAdapter() { DataSource = datasource, ItemMaxSize = 50, ItemMinSize = 10 }; adapter.Mappings.Latitude = "glat"; adapter.Mappings.Longitude = "glon"; adapter.Mappings.Value = "mag"; return(adapter); }
public MapViewModel() { Locations = new List <MapLocation> { new MapLocation("Magdeburg Cracau", 52.1223, 11.6656, 15000), new MapLocation("Magdeburg Neustadt", 52.1512, 11.6451, 16000), new MapLocation("Magdeburg Sudenburg", 52.1132, 11.5948, 9000), new MapLocation("Magdeburg Westerhüsen", 52.0651, 11.6752, 12000), new MapLocation("Burg (bei Magdeburg)", 52.2710, 11.8544, 14000), new MapLocation("Berlin Mitte", 52.5303, 13.3829, 20000), new MapLocation("Berlin Kreuzberg", 52.4982, 13.3890, 11000), new MapLocation("Berlin Steglitz", 52.4559, 13.3341, 9000), new MapLocation("Berlin Friedrichshain", 52.5153, 13.4549, 10000), new MapLocation("Berlin Charlottenburg", 52.5169, 13.3012, 9000) }; DataSourceAdapter = new BubbleChartDataAdapter() { Mappings = new MapBubbleMappingInfo() { Latitude = nameof(MapLocation.Latitude), Longitude = nameof(MapLocation.Longitude), Value = nameof(MapLocation.Value) }, AttributeMappings = { new MapItemAttributeMapping() { Member = nameof(MapLocation.Name), Name = nameof(MapLocation.Name) }, new MapItemAttributeMapping() { Member = nameof(MapLocation.Value), Name = nameof(MapLocation.Value) } }, Clusterer = new DistanceBasedClusterer(), DataSource = Locations, ItemMinSize = 25, ItemMaxSize = 75 }; }
public SCMap AddLayerVectorData(object dataSource, LayerVectorDataOptions options = null) { options ??= new LayerVectorDataOptions(); DataSourceAdapterBase adapter; if (!string.IsNullOrWhiteSpace(options.BubbleField)) { var bubbleAdapter = new BubbleChartDataAdapter() { BubbleItemDataMember = options.BubbleField }; adapter = bubbleAdapter; //Mappings bubbleAdapter.Mappings.ImageIndex = options.ImageIndexField; bubbleAdapter.Mappings.Latitude = options.LatitudeField; bubbleAdapter.Mappings.Longitude = options.LongitudeField; bubbleAdapter.Mappings.Text = options.TextField; bubbleAdapter.Mappings.Type = options.MapItemTypeField; bubbleAdapter.Mappings.XCoordinate = options.XCoordinateField; bubbleAdapter.Mappings.YCoordinate = options.YCoordinateField; bubbleAdapter.Mappings.Value = options.ValueField; } else if (!string.IsNullOrWhiteSpace(options.PieField)) { var pieAdapter = new PieChartDataAdapter() { PieItemDataMember = options.PieField }; adapter = pieAdapter; //Mappings pieAdapter.Mappings.ImageIndex = options.ImageIndexField; pieAdapter.Mappings.Latitude = options.LatitudeField; pieAdapter.Mappings.Longitude = options.LongitudeField; pieAdapter.Mappings.Text = options.TextField; pieAdapter.Mappings.Type = options.MapItemTypeField; pieAdapter.Mappings.XCoordinate = options.XCoordinateField; pieAdapter.Mappings.YCoordinate = options.YCoordinateField; pieAdapter.Mappings.Value = options.ValueField; } else { var listAdapter = new ListSourceDataAdapter() { DefaultMapItemType = (DevExpress.XtraMap.MapItemType)options.DefaultMapItemType }; adapter = listAdapter; //Mappings listAdapter.Mappings.ImageIndex = options.ImageIndexField; listAdapter.Mappings.Latitude = options.LatitudeField; listAdapter.Mappings.Longitude = options.LongitudeField; listAdapter.Mappings.Text = options.TextField; listAdapter.Mappings.Type = options.MapItemTypeField; listAdapter.Mappings.XCoordinate = options.XCoordinateField; listAdapter.Mappings.YCoordinate = options.YCoordinateField; } //Property mappings var defaultItemColor = Utils.ColorFromString(options.DefaultItemColor); if (defaultItemColor != Color.Empty || !string.IsNullOrWhiteSpace(options.ItemColorField)) { var mapItem = new MapItemFillMapping(); if (defaultItemColor != Color.Empty) { mapItem.DefaultValue = defaultItemColor; } if (!string.IsNullOrWhiteSpace(options.ItemColorField)) { mapItem.Member = options.ItemColorField; } adapter.PropertyMappings.Add(mapItem); } var defaultStrokeColor = Utils.ColorFromString(options.DefaultStrokeColor); if (defaultStrokeColor != Color.Empty || !string.IsNullOrWhiteSpace(options.StrokeColorField)) { var mapItem = new MapItemStrokeMapping(); if (defaultStrokeColor != Color.Empty) { mapItem.DefaultValue = defaultStrokeColor; } if (!string.IsNullOrWhiteSpace(options.StrokeColorField)) { mapItem.Member = options.StrokeColorField; } adapter.PropertyMappings.Add(mapItem); } if (options.DefaultDotShapeKind.HasValue || !string.IsNullOrWhiteSpace(options.DotShapeKindField)) { var mapItem = new MapDotShapeKindMapping(); if (options.DefaultDotShapeKind.HasValue) { mapItem.DefaultValue = (DevExpress.XtraMap.MapDotShapeKind)options.DefaultDotShapeKind.Value; } if (!string.IsNullOrWhiteSpace(options.DotShapeKindField)) { mapItem.Member = options.DotShapeKindField; } adapter.PropertyMappings.Add(mapItem); } if (options.DefaultDotSize.HasValue || !string.IsNullOrWhiteSpace(options.DotSizeField)) { var mapItem = new MapDotSizeMapping(); if (options.DefaultDotSize.HasValue) { mapItem.DefaultValue = options.DefaultDotSize.Value; } if (!string.IsNullOrWhiteSpace(options.DotSizeField)) { mapItem.Member = options.DotSizeField; } adapter.PropertyMappings.Add(mapItem); } if (options.DefaultEllipseHeight.HasValue || !string.IsNullOrWhiteSpace(options.EllipseHeightField)) { var mapItem = new MapEllipseHeightMapping(); if (options.DefaultEllipseHeight.HasValue) { mapItem.DefaultValue = options.DefaultEllipseHeight.Value; } if (!string.IsNullOrWhiteSpace(options.EllipseHeightField)) { mapItem.Member = options.EllipseHeightField; } adapter.PropertyMappings.Add(mapItem); } if (options.DefaultEllipseWidth.HasValue || !string.IsNullOrWhiteSpace(options.EllipseWidthField)) { var mapItem = new MapEllipseWidthMapping(); if (options.DefaultEllipseWidth.HasValue) { mapItem.DefaultValue = options.DefaultEllipseWidth.Value; } if (!string.IsNullOrWhiteSpace(options.EllipseWidthField)) { mapItem.Member = options.EllipseWidthField; } adapter.PropertyMappings.Add(mapItem); } if (options.DefaultRectangleHeight.HasValue || !string.IsNullOrWhiteSpace(options.RectangleHeightField)) { var mapItem = new MapRectangleHeightMapping(); if (options.DefaultRectangleHeight.HasValue) { mapItem.DefaultValue = options.DefaultRectangleHeight.Value; } if (!string.IsNullOrWhiteSpace(options.RectangleHeightField)) { mapItem.Member = options.RectangleHeightField; } adapter.PropertyMappings.Add(mapItem); } if (options.DefaultRectangleWidth.HasValue || !string.IsNullOrWhiteSpace(options.RectangleWidthField)) { var mapItem = new MapRectangleWidthMapping(); if (options.DefaultRectangleWidth.HasValue) { mapItem.DefaultValue = options.DefaultRectangleWidth.Value; } if (!string.IsNullOrWhiteSpace(options.RectangleWidthField)) { mapItem.Member = options.RectangleWidthField; } adapter.PropertyMappings.Add(mapItem); } //Attribute mappings if (options.Attributes != null) { foreach (string attribute in options.Attributes) { adapter.AttributeMappings.Add(new MapItemAttributeMapping() { Member = attribute, Name = attribute }); } } if (dataSource != null) { adapter.DataSource = GetDataSource(dataSource, new DataSourceParameters()); } var map = Map; MapItemStyle itemStyle; if (!options.MiniMap) { var layer = new VectorItemsLayer() { AllowEditItems = false, EnableHighlighting = false, EnableSelection = false }; if (!string.IsNullOrWhiteSpace(options.ShapeTitlesPattern)) { layer.ShapeTitlesPattern = options.ShapeTitlesPattern; layer.ShapeTitlesVisibility = VisibilityMode.Visible; } if (!string.IsNullOrWhiteSpace(options.Name)) { layer.Name = options.Name; } if (options.ItemImageIndex.HasValue) { layer.ItemImageIndex = options.ItemImageIndex.Value; } itemStyle = layer.ItemStyle; layer.Data = adapter; map.Layers.Add(layer); CurrentLayer = layer; } else { var layerMini = new MiniMapVectorItemsLayer(); if (!string.IsNullOrWhiteSpace(options.Name)) { layerMini.Name = options.Name; } if (options.ItemImageIndex.HasValue) { layerMini.ItemImageIndex = options.ItemImageIndex.Value; } itemStyle = layerMini.ItemStyle; layerMini.Data = adapter; if (map.MiniMap == null) { throw new Exception("Mini map is not created."); } map.MiniMap.Layers.Add(layerMini); CurrentLayer = layerMini; } if (itemStyle != null) { var fillColor = Utils.ColorFromString(options.FillColor); if (fillColor != Color.Empty) { itemStyle.Fill = fillColor; } var font = Utils.StringToFont(options.Font, out Color textColor); if (font != null) { itemStyle.Font = font; } if (textColor != Color.Empty) { itemStyle.TextColor = textColor; } var strokeColor = Utils.ColorFromString(options.StrokeColor); if (strokeColor != Color.Empty) { itemStyle.Stroke = strokeColor; } if (options.StrokeWidth.HasValue) { itemStyle.StrokeWidth = options.StrokeWidth.Value; } var textGlowColor = Utils.ColorFromString(options.TextGlowColor); if (textGlowColor != Color.Empty) { itemStyle.TextGlowColor = textGlowColor; } } return(this); }