Beispiel #1
0
        // Create pair from point of place and point of label.
        private KeyValuePair <C1.Win.Map.VectorPlacemark, C1.Win.Map.VectorPlacemark> CreateTarget(City sourceCity)
        {
            // Create target point.
            var place = new C1.Win.Map.VectorPlacemark
            {
                Tag      = sourceCity.Title,
                Geometry = new GeoPoint(sourceCity.longitude, sourceCity.latitude),
                Marker   = { Shape = MarkerShape.Custom }
            };

            var shape = new MarkerImageShape();

            shape.Image              = (Image)_resources.GetObject("Target");
            place.Marker.Size        = new SizeF(20, 20);
            place.Marker.CustomShape = shape;

            // Create target point.
            var label = new C1.Win.Map.VectorPlacemark
            {
                Geometry = new GeoPoint(sourceCity.longitude - 0.1F, sourceCity.latitude + 0.16F),
            };

            label.Marker.Caption       = sourceCity.Title;
            label.Marker.LabelAngle    = -90F;
            label.LabelStyle.ForeColor = Color.Yellow;

            return(new KeyValuePair <C1.Win.Map.VectorPlacemark, C1.Win.Map.VectorPlacemark>(place, label));
        }
Beispiel #2
0
        private void UpdataMapMark()
        {
            _vectorLayer.Items.Clear();
            var regionSalesCollection = new ListCollectionView(DataService.GetService().GetRegionWiseSales());

            if (regionSalesCollection.Count == 0)
            {
                return;
            }
            regionSalesCollection.SortDescriptions.Add(new SortDescription("Sales", ListSortDirection.Descending));
            double maxValue = (regionSalesCollection.GetItemAt(0) as RegionSaleItem).Sales;

            foreach (RegionSaleItem sales in regionSalesCollection)
            {
                C1.Win.Map.VectorPlacemark mark = new C1.Win.Map.VectorPlacemark();
                mark.Geometry             = new GeoPoint(sales.Locat.X, sales.Locat.Y);
                mark.Marker.Size          = CreateMarkBySale(sales.Sales, maxValue);
                mark.Marker.Shape         = MarkerShape.Circle;
                mark.Marker.Caption       = string.Format("{0:C}", sales.Sales);
                mark.Marker.LabelPosition = LabelPosition.Center;
                mark.Style.Stroke.Color   = sales.Profit > 0 ? Color.Orange : Color.RoyalBlue;
                mark.Style.BackColor      = mark.Style.Stroke.Color;
                _vectorLayer.Items.Add(mark);
            }
        }
Beispiel #3
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);
                }
            }
        }
 public void SetStores(IEnumerable <Store> shops)
 {
     _stores = shops.ToList();
     foreach (var shop in shops)
     {
         var mark = new C1.Win.Map.VectorPlacemark
         {
             Geometry = new GeoPoint(shop.Location.X, shop.Location.Y),
             Lod      = new LOD(0, 0, 0, 20),
             Tag      = shop.City,
             Marker   =
             {
                 Size          = new SizeF(12,       12),
                 Shape         = MarkerShape.Circle,
                 Caption       = shop.City,
                 LabelPosition = LabelPosition.Right
             }
         };
         _layer.Items.Add(mark);
     }
 }
Beispiel #5
0
        private void AddMark(double lon, double lat)
        {
            var mark = new C1.Win.Map.VectorPlacemark();

            _layer.Items.Add(mark);
            // Create the random number for mark
            var index = GetRandomNumber();

            mark.Geometry           = new GeoPoint(lon, lat);
            mark.Marker.Size        = new SizeF(20, 27.32f);
            mark.Marker.Shape       = MarkerShape.Custom;
            mark.Tag                = index;
            mark.Marker.CustomShape = new MarkShape(index);
            mark.Style.Stroke.Color = Color.DarkGray;
            mark.Style.Stroke.Width = 1;
            mark.Style.BackColor    = GetRandomColor(128, 192);

            var row = _table.NewRow();

            row["Number"]    = index;
            row["longitude"] = lon;
            row["latitude"]  = lat;
            _table.Rows.Add(row);
        }
Beispiel #6
0
        private void CreateGrids()
        {
            var layer = new VectorLayer {
                LabelVisibility = LabelVisibility.Visible, Track = false
            };

            c1Map1.Layers.Add(layer);

            layer.LabelStyle.ForeColor = Color.DarkGray;
            layer.Style.Stroke.Color   = Color.DarkGray;
            layer.Style.Stroke.Style   = DashStyle.Dash;
            layer.Style.Stroke.Width   = 1;

            for (int lon = -180; lon <= 180; lon += 30)
            {
                var points = new List <GeoPoint>();
                for (int lat = -85; lat <= 85; lat++)
                {
                    points.Add(new GeoPoint(lon, lat));
                }
                var pl = new VectorPolyline
                {
                    Geometry = new GeoLineString(points)
                };
                layer.Items.Add(pl);

                var lbl = Math.Abs(lon) + "°";
                if (lon > 0)
                {
                    lbl += "E";
                }
                else if (lon < 0)
                {
                    lbl += "W";
                }

                var pm = new VectorPlacemark
                {
                    Geometry = new GeoPoint(lon, 0),
                    Marker   = { Caption = lbl, LabelPosition = LabelPosition.Top }
                };
                layer.Items.Add(pm);
            }

            for (int lat = -80; lat <= 80; lat += 20)
            {
                var points = new List <GeoPoint>();
                for (int lon = -180; lon <= 180; lon++)
                {
                    points.Add(new GeoPoint(lon, lat));
                }
                var pl = new VectorPolyline
                {
                    Geometry = new GeoLineString(points)
                };
                layer.Items.Add(pl);

                var lbl = Math.Abs(lat) + "°";
                if (lat > 0)
                {
                    lbl += "N";
                }
                else if (lat < 0)
                {
                    lbl += "S";
                }

                var pm = new VectorPlacemark
                {
                    Geometry = new GeoPoint(0, lat),
                    Marker   = { Caption = lbl, LabelPosition = LabelPosition.Right }
                };
                layer.Items.Add(pm);
            }
        }
Beispiel #7
0
        protected override void InitMap()
        {
            base.InitMap();
            c1Map1.Viewport.Zoom = 1;
            var layer = new VectorLayer {
                LabelVisibility = LabelVisibility.Visible, Track = false
            };

            c1Map1.Layers.Add(layer);

            layer.LabelStyle.ForeColor = Color.DarkGray;
            layer.Style.Stroke.Color   = Color.DarkGray;
            layer.Style.Stroke.Style   = DashStyle.Dash;
            layer.Style.Stroke.Width   = 1;

            for (int lon = -180; lon <= 180; lon += 30)
            {
                var pl = new VectorPolyline
                {
                    Geometry = new GeoLineString(new[] { new GeoPoint(lon, -85), new GeoPoint(lon, 85) })
                };
                layer.Items.Add(pl);

                var lbl = Math.Abs(lon) + "°";
                if (lon > 0)
                {
                    lbl += "E";
                }
                else if (lon < 0)
                {
                    lbl += "W";
                }

                var pm = new VectorPlacemark
                {
                    Geometry = new GeoPoint(lon, 0),
                    Marker   = { Caption = lbl, LabelPosition = LabelPosition.Top }
                };
                layer.Items.Add(pm);
            }

            for (int lat = -80; lat <= 80; lat += 20)
            {
                var pl = new VectorPolyline
                {
                    Geometry = new GeoLineString(new[] { new GeoPoint(-180, lat), new GeoPoint(180, lat) })
                };
                layer.Items.Add(pl);

                var lbl = Math.Abs(lat) + "°";
                if (lat > 0)
                {
                    lbl += "N";
                }
                else if (lat < 0)
                {
                    lbl += "S";
                }

                var pm = new VectorPlacemark
                {
                    Geometry = new GeoPoint(0, lat),
                    Marker   = { Caption = lbl, LabelPosition = LabelPosition.Right }
                };
                layer.Items.Add(pm);
            }
        }
Beispiel #8
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);
        }