protected override void InitMap() { base.InitMap(); c1Map1.Viewport.Zoom = 1; var layer = MapReader.LoadKmlFile("Resources\\2.5_day_depth.kml", (vector, data) => { var placemark = vector as C1.Win.Map.VectorPlacemark; if (placemark == null) { return; } var name = data["name"] as string; placemark.Tag = name; placemark.Marker.Caption = name; placemark.Marker.Shape = MarkerShape.Custom; placemark.Marker.CustomShape = new EarthquakeShape(); placemark.Marker.LabelPosition = LabelPosition.Right; placemark.Marker.Size = new SizeF(10, 6); placemark.LabelStyle.BackColor = Color.FromArgb(0x70, Color.White); placemark.LabelWidth = 150; }); layer.Style.Stroke.Color = Color.FromArgb(0x90, 0xff, 0x00, 0x00); layer.Style.Stroke.Width = 2; layer.LabelVisibility = LabelVisibility.AutoHide; c1Map1.Layers.Add(layer); }
private void CreateWorldMap() { var layerWorld = MapReader.LoadKmlFile("Resources\\WorldMap.kmz", (vector, data) => { var name = data["name"] as string; vector.Tag = name; vector.Style.BackColor = MapReader.GetKmlStyleColor(data[KmlReader.StyleFillColor] as string); var placemark = vector as VectorPlacemark; if (placemark != null) { placemark.Marker.Caption = name; placemark.Lod = new LOD(0, 0, 2, 20); } }); layerWorld.LabelVisibility = LabelVisibility.AutoHide; layerWorld.LabelStyle.ForeColor = Color.FromArgb(0x97, 0x35, 0x35); c1Map1.Layers.Add(layerWorld); }
protected override void InitMap() { base.InitMap(); c1Map1.Viewport.Zoom = 1; var layer = new C1.Win.Map.VectorLayer { LabelVisibility = LabelVisibility.AutoHide }; layer.LabelStyle.ForeColor = Color.FromArgb(0xC0, 0x50, 0x4d); layer.Style.BackColor = Color.FromArgb(0x80, Color.Gold); layer.Style.Stroke.Color = Color.FromArgb(0x80, Color.White); layer.Style.Stroke.Width = 1; c1Map1.Layers.Add(layer); using (var stream = MapReader.OpenFile("Resources\\Cities100K.txt")) { var cities = City.Read(stream); var top500 = cities.OrderByDescending(city => city.Population).Take(500); foreach (var city in top500) { var mark = new C1.Win.Map.VectorPlacemark { Geometry = new GeoPoint(city.Location.X, city.Location.Y), Lod = GetLod(city), Tag = city.Name + ":\r\n" + city.Population, Marker = { Size = GetSize(city), Shape = MarkerShape.Circle, Caption = city.Name, LabelPosition = LabelPosition.Right } }; layer.Items.Add(mark); } } }
private void cmbCountry_SelectedIndexChanged(object sender, EventArgs e) { c1Map1.Layers.Clear(); switch (cmbCountry.SelectedIndex) { case 0: var layerUsa = MapReader.LoadShpFile("Resources\\states.shp", "Resources\\states.dbf", (vector, data) => { vector.Tag = data["STATE_NAME"]; }); layerUsa.Style.BackColor = Color.Purple; layerUsa.Style.Stroke.Color = Color.LightGray; c1Map1.Layers.Add(layerUsa); c1Map1.Viewport.Center = new C1.Win.Interop.Point(-115, 50); c1Map1.Viewport.MinZoom = 2; c1Map1.Viewport.Zoom = 2; break; case 1: var layerJapan = MapReader.LoadShpFile("Resources\\jp_toku_kuni_pgn.shp", "Resources\\jp_toku_kuni_pgn.dbf", (vector, data) => { vector.Tag = data["NAME_UTF"]; }); layerJapan.Style.BackColor = Color.Brown; layerJapan.Style.Stroke.Color = Color.LightGray; c1Map1.Layers.Add(layerJapan); c1Map1.Viewport.Center = new C1.Win.Interop.Point(135, 37); c1Map1.Viewport.MinZoom = 4; c1Map1.Viewport.Zoom = 4; break; } }
protected override void InitMap() { base.InitMap(); c1Map1.Viewport.Zoom = 1; // read text data from resources foreach (var s in File.ReadAllLines("Resources\\gdp-ppp.txt")) { var ss = s.Split(new[] { '\t' }, StringSplitOptions.RemoveEmptyEntries); _countries.Add(new Country { Name = ss[1].Trim(), Value = double.Parse(ss[2], CultureInfo.InvariantCulture) }); } // create palette var cvals = new ColorValues { new ColorValue { Color = Color.FromArgb(255, 241, 244, 255), Value = 0 }, new ColorValue { Color = Color.FromArgb(255, 241, 244, 255), Value = 5000 }, new ColorValue { Color = Color.FromArgb(255, 224, 224, 246), Value = 10000 }, new ColorValue { Color = Color.FromArgb(255, 203, 205, 255), Value = 20000 }, new ColorValue { Color = Color.FromArgb(255, 179, 182, 230), Value = 50000 }, new ColorValue { Color = Color.FromArgb(255, 156, 160, 240), Value = 100000 }, new ColorValue { Color = Color.FromArgb(255, 127, 132, 243), Value = 200000 }, new ColorValue { Color = Color.FromArgb(255, 89, 97, 230), Value = 500000 }, new ColorValue { Color = Color.FromArgb(255, 56, 64, 217), Value = 1000000 }, new ColorValue { Color = Color.FromArgb(255, 19, 26, 148), Value = 2000000 }, new ColorValue { Color = Color.FromArgb(255, 0, 3, 74), Value = 1.001 * _countries.GetMax() } }; _countries.Converter = cvals; // read world map from resources var layerWorld = MapReader.LoadKmlFile("Resources\\WorldMap.kmz", (vector, data) => { var name = data["name"] as string; vector.Tag = name; var country = _countries[name]; if (country != null) { vector.Style.BackColor = country.Fill; } var placemark = vector as C1.Win.Map.VectorPlacemark; if (placemark != null) { placemark.Marker.Caption = name; placemark.Lod = new LOD(0, 0, 2, 20); } }); layerWorld.LabelVisibility = LabelVisibility.AutoHide; layerWorld.LabelStyle.ForeColor = Color.FromArgb(0x97, 0x35, 0x35); c1Map1.Layers.Add(layerWorld); // reserve space for legend c1Map1.Viewport.Margin = new Padding(0, 0, 100, 0); InitKmlLegend(); }
protected override void InitMap() { base.InitMap(); c1Map1.Viewport.Zoom = 1; using (var stream = MapReader.OpenFile("Resources\\database.xml")) { var serializer = new XmlSerializer(typeof(DataBase)); _factories = (DataBase)serializer.Deserialize(stream); } var layerFactory = new VectorLayer(); var factoryShape = new MarkerImageShape { Image = Image.FromFile("Resources\\factory.png") }; var factoryMarker = new Marker { Size = new SizeF(60, 60), Shape = MarkerShape.Custom, CustomShape = factoryShape }; foreach (var factory in _factories.Factories) { var item = new C1.Win.Map.VectorPlacemark { Geometry = new GeoPoint(factory.Longitude, factory.Latitude), Marker = factoryMarker, Tag = factory.Name }; layerFactory.Items.Add(item); } c1Map1.Layers.Add(layerFactory); var layerOffice = new VectorLayer(); foreach (var office in _factories.Offices) { var item = new C1.Win.Map.VectorPlacemark { Geometry = new GeoPoint(office.Longitude, office.Latitude), Tag = office.Name }; var officeMarker = new Marker { Size = new SizeF(60, 60), Shape = MarkerShape.Custom, CustomShape = new OfficeShape(office) }; item.Marker = officeMarker; item.Style.Font = new Font("Arial", 9f); layerOffice.Items.Add(item); } c1Map1.Layers.Add(layerOffice); var layerStore = new VirtualLayer(); layerStore.Slices.Add(new MapSlice(0, 1, 1)); var storeSlices = (int)Math.Pow(2, LocalStoreSource.MinStoreZoom); layerStore.Slices.Add(new MapSlice(LocalStoreSource.MinStoreZoom, storeSlices, storeSlices)); layerStore.ItemsSource = new LocalStoreSource(_factories); c1Map1.Layers.Add(layerStore); }