Esempio n. 1
0
        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);
                }
            }
        }
Esempio n. 2
0
        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);
        }