private void InitializeMap() { // Create a Map control. MapControl map = new MapControl() { Dock = DockStyle.Fill, CoordinateSystem = new CartesianMapCoordinateSystem(), CenterPoint = new CartesianPoint(-100, -50), MaxZoomLevel = 3, MinZoomLevel = 1 }; this.Controls.Add(map); #region #CreateLayer // Create a vector layer and add it to the map. VectorItemsLayer hotelLayer = new VectorItemsLayer() { Data = CreateData(), Colorizer = CreateColorizer() }; map.Layers.Add(hotelLayer); #endregion #CreateLayer #region #AddLegend // Add a legend to the map. map.Legends.Add(new ColorListLegend() { Header = "Room Type", Layer = hotelLayer }); #endregion #AddLegend }
void InitializeMap() { // Create a map control and add it to the form. MapControl map = new MapControl() { Dock = DockStyle.Fill }; this.Controls.Add(map); // Create a layer to display vector data. VectorItemsLayer itemsLayer = new VectorItemsLayer(); map.Layers.Add(itemsLayer); // Generate a data storage for the layer. itemsLayer.Data = CreateData(); // Create a colorizer for the layer. itemsLayer.Colorizer = CreateColorizer(); // Create a legend for the layer. map.Legends.Add(CreateLegend(itemsLayer)); // Specify tooltips for the map. map.ToolTipController = new ToolTipController() { AllowHtmlText = true }; }
public SCMap AddLayerVectorFile(string vectorFile, LayerVectorFileOptions options = null) { options ??= new LayerVectorFileOptions(); var map = Map; var layer = new VectorItemsLayer() { AllowEditItems = false, EnableHighlighting = false, EnableSelection = false }; if (!string.IsNullOrWhiteSpace(options.Name)) { layer.Name = options.Name; } vectorFile = Project.Current.MapPath(vectorFile); if (string.IsNullOrWhiteSpace(vectorFile) || !File.Exists(vectorFile)) { throw new Exception($"Cannot find file: {vectorFile}"); } var fileType = options.FileType ?? VectorFileType.Auto; if (fileType == VectorFileType.Auto) { var ext = Path.GetExtension(vectorFile); fileType = ext?.ToLower() switch { ".kml" => VectorFileType.KML, ".shp" => VectorFileType.SHP, ".svg" => VectorFileType.SVG, _ => throw new Exception("Cannot determine file type. Set property FileType to KML, SHP or SVG.") }; } var data = fileType switch { VectorFileType.KML => (FileDataAdapterBase) new KmlFileDataAdapter(), VectorFileType.SHP => (FileDataAdapterBase) new ShapefileDataAdapter(), VectorFileType.SVG => (FileDataAdapterBase) new SvgFileDataAdapter(), _ => throw new Exception("Cannot determine file type. Set property FileType to KML, SHP or SVG."), }; data.FileUri = new Uri($"file://{vectorFile}"); if (map.CoordinateSystem != null && map.CoordinateSystem is CartesianMapCoordinateSystem) { data.SourceCoordinateSystem = new CartesianSourceCoordinateSystem(); } layer.Data = data; map.Layers.Add(layer); CurrentLayer = layer; return(this); } }
private void Form1_Load(object sender, EventArgs e) { // Create a map control with initial settings and add it to the form. MapControl map = new MapControl() { Dock = DockStyle.Fill, ZoomLevel = 4, CenterPoint = new GeoPoint(43, 15) }; this.Controls.Add(map); // Create a layer to load image tiles from OpenStreetMap. ImageLayer tileLayer = new ImageLayer(); tileLayer.DataProvider = new BingMapDataProvider(); map.Layers.Add(tileLayer); // Create a layer to display vector items. VectorItemsLayer itemsLayer = new VectorItemsLayer(); map.Layers.Add(itemsLayer); // Create a storage for map items and generate them. MapItemStorage storage = new MapItemStorage(); MapItem[] capitals = GetCapitals(); storage.Items.AddRange(capitals); itemsLayer.Data = storage; }
private void InitializeMap() { // Create a map and add it to the form. MapControl map = new MapControl() { Dock = DockStyle.Fill }; this.Controls.Add(map); // Create an adapter to load data from shapefile. Uri baseUri = new Uri(System.Reflection.Assembly.GetEntryAssembly().Location); ShapefileDataAdapter adapter = new ShapefileDataAdapter() { FileUri = new Uri(baseUri, filename) }; // Create a vector items layer and it to the map. VectorItemsLayer vectorLayer = new VectorItemsLayer() { Data = adapter }; map.Layers.Add(vectorLayer); }
private void Form1_Load(object sender, EventArgs e) { // Create a map control, set its dock style and add it to the form. MapControl map = new MapControl(); map.Dock = DockStyle.Fill; this.Controls.Add(map); // Create a vector items layer and add it to the map. VectorItemsLayer itemsLayer = new VectorItemsLayer(); map.Layers.Add(itemsLayer); MapItemStorage storage = new MapItemStorage(); itemsLayer.Data = storage; // Generate map polygons. GenerateVectorItems(storage.Items); // Specify the tooltip content. itemsLayer.ToolTipPattern = "{" + powerAttrName + "}"; // Create a custom colorizer. itemsLayer.Colorizer = new CustomColorizer(); }
private void InitializeMap() { // Create a map control with initial settings and add it to the form. MapControl map = new MapControl() { Dock = DockStyle.Fill }; this.Controls.Add(map); // Create a vector items layer. VectorItemsLayer itemsLayer = new VectorItemsLayer() { Colorizer = CreateColorizer(), Data = CreateData() }; map.Layers.Add(itemsLayer); // Create a legend. map.Legends.Add(new ColorListLegend() { Layer = itemsLayer }); }
private void Form1_Load(object sender, EventArgs e) { // Create a map control with initial settings and add it to the form. MapControl map = new MapControl() { Dock = DockStyle.Fill }; this.Controls.Add(map); // Create a layer to load image tiles from OpenStreetMap. ImageTilesLayer tileLayer = new ImageTilesLayer(); tileLayer.DataProvider = new OpenStreetMapDataProvider(); map.Layers.Add(tileLayer); // Create a vector items layer. VectorItemsLayer itemsLayer = new VectorItemsLayer() { Data = CreateData(), Colorizer = CreateColorizer() }; map.Layers.Add(itemsLayer); // Create a legend. map.Legends.Add(new ColorListLegend() { Layer = itemsLayer }); }
protected override void UpdateMap() { if (WKT == null || WKT.Length <= 0) { return; } var map = MapContext.Map; var layer = new VectorItemsLayer() { AllowEditItems = false, EnableHighlighting = false, EnableSelection = false }; if (!string.IsNullOrWhiteSpace(Name)) { layer.Name = Name; } var storage = new SqlGeometryItemStorage(); int counter = 1; foreach (var wkt in WKT) { storage.Items.Add(SqlGeometryItem.FromWkt(wkt, counter++)); } layer.Data = storage; map.Layers.Add(layer); MapContext.CurrentLayer = layer; }
LayerBase CreateVectorLayer(object data) { ListSourceDataAdapter adapter = new ListSourceDataAdapter() { DataSource = data, DefaultMapItemType = MapItemType.Custom }; adapter.Mappings.Latitude = "Latitude"; adapter.Mappings.Longitude = "Longitude"; adapter.AttributeMappings.Add(new MapItemAttributeMapping() { Name = "Name", Member = "Name" }); adapter.AttributeMappings.Add(new MapItemAttributeMapping() { Name = "Year", Member = "Year" }); adapter.AttributeMappings.Add(new MapItemAttributeMapping() { Name = "Description", Member = "Description" }); VectorItemsLayer layer = new VectorItemsLayer() { Data = adapter, ItemImageIndex = 0, EnableSelection = false, EnableHighlighting = false, ToolTipPattern = "<b>{Name} ({Year})</b>\n{Description}" }; return(layer); }
private void InitMap() { VectorItemsLayer vlayer = (VectorItemsLayer)this.mapControl1.Layers["ShapefileLayer"]; ShapefileDataAdapter data = new ShapefileDataAdapter(); data.FileUri = new Uri(string.Format("file:///{0}/Countries.shp", Environment.CurrentDirectory)); vlayer.Data = data; }
private void AddPushpin(GeoPoint geoPoint) { MapPushpin pin = new MapPushpin(); pin.Location = geoPoint; VectorItemsLayer layer = (VectorItemsLayer)this.map.Layers[2]; ((MapItemStorage)layer.Data).Items.Add(pin); }
void LoadMapShape(string shapeFile, VectorItemsLayer vectorLayer, List <MapItem> mapItems, ShapefileDataAdapter shapeAdapter) { string shapeDfb = Path.Combine(Path.GetDirectoryName(shapeFile), Path.GetFileNameWithoutExtension(shapeFile) + ".dbf"); using (FileStream fsShp = new FileStream(shapeFile, FileMode.Open, FileAccess.Read)) { using (FileStream fsDb = new FileStream(shapeDfb, FileMode.Open, FileAccess.Read)) { shapeAdapter.LoadFromStream(fsShp, fsDb); } } }
private void InitMapControl() { VectorItemsLayer itemsLayer = new VectorItemsLayer(); MapItemStorage storage = new MapItemStorage(); List <MapItem> stations = Getstations(); storage.Items.AddRange(stations); itemsLayer.Data = storage; map.Layers.Add(itemsLayer); }
private LayerBase CreateLayer(int distanceRadius, int minZoom, int maxZoom) { VectorItemsLayer layer = new VectorItemsLayer(); layer.Name = "Layer" + distanceRadius; layer.MinZoomLevel = minZoom; layer.MaxZoomLevel = maxZoom; layer.Data = CreateMapItemStorage(distanceRadius); layer.ViewportChanged += layer_ViewportChanged; return(layer); }
public SCMap AddLayerSql(string connectionName, string query, LayerSqlOptions options = null) { options ??= new LayerSqlOptions(); var map = this.Map; var layer = new VectorItemsLayer() { AllowEditItems = false, EnableHighlighting = false, EnableSelection = false }; if (!string.IsNullOrWhiteSpace(options.Name)) { layer.Name = options.Name; } if (!string.IsNullOrWhiteSpace(options.ShapeTitlesPattern)) { layer.ShapeTitlesPattern = options.ShapeTitlesPattern; layer.ShapeTitlesVisibility = VisibilityMode.Visible; } else { layer.ShapeTitlesVisibility = VisibilityMode.Hidden; } var connections = DBConnections.LoadConnections(); var connection = connections.FindConnection(connectionName); if (connection == null) { throw new Exception($"Cannot find connection '{connectionName}'."); } if (!ConnectionFactory.IsMSSQLServer(connection.Provider)) { throw new Exception("DBMS must be Microsoft SQL Server."); } var adapter = new SqlGeometryDataAdapter { ConnectionString = connection.ConnectionString, SqlText = query, SpatialDataMember = options.SpatialColumn }; layer.Data = adapter; map.Layers.Add(layer); CurrentLayer = layer; return(this); }
private void Form1_Load(object sender, EventArgs e) { cbData.DataSource = mapData; VectorItemsLayer layer = new VectorItemsLayer() { Data = adapter }; layer.ItemStyle.Fill = Color.FromArgb(40, 255, 128, 0); layer.DataLoaded += layer_DataLoaded; mapControl1.Layers.Add(layer); }
void CreatePushPin(Point hitPoint) { VectorItemsLayer layer = (VectorItemsLayer)map.Layers[1]; GeoPoint pos = layer.ScreenToGeoPoint(hitPoint); int number = layer.Items.Count + 1; string txt = number.ToString(); string positionStr = string.Format("#{0} ({1:n2}, {2:n2})", number, pos.Latitude, pos.Longitude); layer.Items.Add(new MapPushpin() { Text = txt, Location = pos, ToolTipPattern = positionStr }); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); mapControl.CenterPoint = new GeoPoint(37.54164, 126.84035); mapControl.ZoomLevel = 13; VectorItemsLayer itemsLayer = new VectorItemsLayer(); mapControl.Layers.Add(itemsLayer); MapItemStorage storage = new MapItemStorage(); List <MapItem> capitals = GetCapitals(); storage.Items.AddRange(capitals); itemsLayer.Data = storage; }
protected override void UpdateMap() { var map = MapContext.Map; var layer = new VectorItemsLayer() { AllowEditItems = false, EnableHighlighting = false, EnableSelection = false }; if (!string.IsNullOrWhiteSpace(Name)) { layer.Name = Name; } if (!string.IsNullOrWhiteSpace(ShapeTitlesPattern)) { layer.ShapeTitlesPattern = ShapeTitlesPattern; layer.ShapeTitlesVisibility = VisibilityMode.Visible; } else { layer.ShapeTitlesVisibility = VisibilityMode.Hidden; } var connections = DBConnections.LoadConnections(); var connection = connections.FindConnection(ConnectionName); if (connection == null) { throw new Exception($"Cannot find connection '{ConnectionName}'."); } if (!ConnectionFactory.IsMSSQLServer(connection.Provider)) { throw new Exception("DBMS must be Microsoft SQL Server."); } var adapter = new SqlGeometryDataAdapter { ConnectionString = connection.ConnectionString, SqlText = Query, SpatialDataMember = SpatialColumn }; layer.Data = adapter; map.Layers.Add(layer); MapContext.CurrentLayer = layer; }
private void Form1_Load(object sender, EventArgs e) { Uri baseUri = new Uri(System.Reflection.Assembly.GetEntryAssembly().Location); #region #AutomaticallyLoaded data.Add(new MapData() { Name = "Automatically loaded coordinate system", FileUri = new Uri(baseUri, "../../Shapefiles/Albers/switzerland.shp") }); #endregion #AutomaticallyLoaded #region #LoadPrjFile data.Add(new MapData() { Name = "LoadPrjFile( ) calling loaded coordinate system", FileUri = new Uri(baseUri, "../../Shapefiles/Lambert/Belize.shp"), CoordinateSystem = ShapefileDataAdapter.LoadPrjFile(new Uri( baseUri, "../../Shapefiles/Lambert/Projection.prj")) }); #endregion #LoadPrjFile #region #ManuallyCreated data.Add(new MapData() { Name = "Manually created coordinate system", FileUri = new Uri(baseUri, "../../Shapefiles/TransverseMercator/israel.shp"), CoordinateSystem = new CartesianSourceCoordinateSystem() { CoordinateConverter = new UTMCartesianToGeoConverter() { Hemisphere = Hemisphere.Northern, UtmZone = 36 } } }); #endregion #ManuallyCreated cbCoordinateSystem.DataSource = data; cbCoordinateSystem.DisplayMember = "Name"; VectorItemsLayer layer = new VectorItemsLayer() { Data = adapter }; layer.ItemStyle.Fill = Color.FromArgb(60, 255, 128, 0); layer.DataLoaded += layer_DataLoaded; mapControl1.Layers.Add(layer); }
private void Form1_Load(object sender, EventArgs e) { // Create a layer to show vector items. VectorItemsLayer itemsLayer = new VectorItemsLayer() { Data = CreateData(), Colorizer = CreateColorizer() }; mapControl1.Layers.Add(itemsLayer); // Show a color legend. mapControl1.Legends.Add(new ColorListLegend() { Layer = itemsLayer }); }
private void Form1_Load(object sender, EventArgs e) { SqlGeometryItemStorage storage = new SqlGeometryItemStorage(); storage.Items.Add(SqlGeometryItem.FromWkt("POINT(-0.1275 51.507222 0 10)", 0)); storage.Items.Add(SqlGeometryItem.FromWkt("POINT(12.5 41.9 0 10)", 1)); storage.Items.Add(SqlGeometryItem.FromWkt("POINT(2.3508 48.8567 0 10)", 2)); storage.Items.Add(SqlGeometryItem.FromWkt("POINT(13.38 52.52 0 10)", 3)); storage.Items.Add(SqlGeometryItem.FromWkt("POINT(-3.68 40.4 0 10)", 4)); VectorItemsLayer layer = new VectorItemsLayer() { Data = storage }; layer.DataLoaded += layer_DataLoaded; mapControl1.Layers.Add(layer); }
private void Form1_Load(object sender, System.EventArgs e) { SqlGeometryDataAdapter adapter = new SqlGeometryDataAdapter() { ConnectionString = connectionString, SqlText = "SELECT TOP 1000 [id], [GeomCol1],[TextCol] FROM [dbo].[DemoTable]", SpatialDataMember = "GeomCol1" }; VectorItemsLayer layer = new VectorItemsLayer() { Data = adapter, ShapeTitlesPattern = "{TextCol}" }; layer.DataLoaded += layer_DataLoaded; mapControl1.Layers.Add(layer); mapControl1.MapEditor.ShowEditorPanel = true; mapControl1.MapEditor.MapItemEdited += MapEditor_MapItemEdited; }
public ucChoroplethMapItem() { InitializeComponent(); VectorItemsLayer baseLayer = new VectorItemsLayer(); var dataAdapter = CreateShapefileDataAdapter(); baseLayer.Data = dataAdapter; baseLayer.EnableHighlighting = false; baseLayer.SelectedItemStyle.StrokeWidth = 0; mapControl1.Layers.Add(baseLayer); VectorItemsLayer fileLayer = new VectorItemsLayer(); dataAdapter = CreateShapefileDataAdapter(); dataAdapter.ItemsLoaded += OnFileLoaded; fileLayer.Data = dataAdapter; fileLayer.Colorizer = CreateGDPColorizer(); fileLayer.ToolTipPattern = "{NAME}"; mapControl1.Layers.Add(fileLayer); }
private void PrepareMap() { // Create a map control. map = new MapControl(); // Specify the map position on the form. map.Dock = DockStyle.Fill; // Add the map control to the window. this.Controls.Add(map); // Bring the map to the front. map.BringToFront(); // Create an image tiles layer and add it to the map. ImageLayer tilesLayer = new ImageLayer(); map.Layers.Add(tilesLayer); // Create an information layer and add it to the map. InformationLayer infoLayer = new InformationLayer(); map.Layers.Add(infoLayer); VectorItemsLayer items = new VectorItemsLayer(); items.Data = new MapItemStorage(); map.Layers.Add(items); // Create a Bing data provider and specify the Bing key. BingMapDataProvider bingProvider = new BingMapDataProvider(); tilesLayer.DataProvider = bingProvider; bingProvider.BingKey = yourBingKey; // Create a Bing search data provider and specify the Bing key. searchProvider = new BingSearchDataProvider(); infoLayer.DataProvider = searchProvider; searchProvider.GenerateLayerItems = false; searchProvider.BingKey = yourBingKey; map.ShowSearchPanel = false; }
void layer_ViewportChanged(object sender, ViewportChangedEventArgs e) { if (e.IsAnimated) { return; } VectorItemsLayer layer = (VectorItemsLayer)sender; double minX = Math.Min(e.TopLeft.GetX(), e.BottomRight.GetX()); double maxX = Math.Max(e.TopLeft.GetX(), e.BottomRight.GetX()); double minY = Math.Min(e.TopLeft.GetY(), e.BottomRight.GetY()); double maxY = Math.Max(e.TopLeft.GetY(), e.BottomRight.GetY()); foreach (PhotoMapItem item in ((MapItemStorage)layer.Data).Items) { double lattitude = item.Location.GetY(); double longitude = item.Location.GetX(); bool isVisible = lattitude > minY && lattitude <maxY && longitude> minX && longitude < maxX; item.Files.ForEach((file) => { file.VisibleOnMap = isVisible; }); } this.galleryView.RefreshData(); }
private void InitializeMap() { // Create a Map control and add it to the form. MapControl map = new MapControl() { Dock = DockStyle.Fill, CenterPoint = new GeoPoint(47, 2), ZoomLevel = 4, ToolTipController = new ToolTipController() }; this.Controls.Add(map); // Create a layer to load image tiles. ImageLayer tilesLayer = new ImageLayer() { DataProvider = new OpenStreetMapDataProvider() }; map.Layers.Add(tilesLayer); // Create a layer to display shapes. VectorItemsLayer itemsLayer = new VectorItemsLayer() { // Provide data to generate shape items. Data = LoadDataFromXML(dataPath), // Enable shape titles. ShapeTitlesVisibility = VisibilityMode.Visible, // Each shape has a CityName attribute, which stores the capital name. // To display this value as a shape title, let's specify the attribute name in braces. ShapeTitlesPattern = "{CityName}", // To display a Population attribute as a tooltip, // let's specify the ToolTipPattern property as follows. ToolTipPattern = "Population: {Population}" }; map.Layers.Add(itemsLayer); }
private void simpleButton1_Click(object sender, EventArgs e) { SaveFileDialog dialog = new SaveFileDialog(); dialog.DefaultExt = ".shp"; // Default file extension dialog.Filter = "Shape file (.shp)|*.shp"; // Filter files by extension if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { VectorItemsLayer vl = this.mapControl1.Layers[0] as VectorItemsLayer; if (vl != null) { vl.ExportToShp(dialog.FileName, new ShpExportOptions() { ExportToDbf = true, ShapeType = ShapeType.PolygonZ }); MessageBox.Show("Shape File Saved"); return; } MessageBox.Show("An error occured"); } }
public SCMap AddLayerWkt(string[] WKT, LayerWktOptions options = null) { if (WKT == null || WKT.Length <= 0) { return(this); } options ??= new LayerWktOptions(); var map = Map; var layer = new VectorItemsLayer() { AllowEditItems = false, EnableHighlighting = false, EnableSelection = false }; if (!string.IsNullOrWhiteSpace(options.Name)) { layer.Name = options.Name; } var storage = new SqlGeometryItemStorage(); int counter = 1; foreach (var wkt in WKT) { storage.Items.Add(SqlGeometryItem.FromWkt(wkt, counter++)); } layer.Data = storage; map.Layers.Add(layer); CurrentLayer = layer; return(this); }