void InitialMapsByLocaltion(C1Maps maps, Location location) { C1VectorLayer layer = new C1VectorLayer(); Point center = new Point(); double zoom = 0; switch (location) { case Location.USA: Utils.LoadShapeFromResource(layer, "MapsSamples.Resources.states.shp", "MapsSamples.Resources.states.dbf", location, true, ProcessMap); center = new Point(-115, 50); zoom = 2; break; case Location.Japan: Utils.LoadShapeFromResource(layer, "MapsSamples.Resources.jp_toku_kuni_pgn.shp", "MapsSamples.Resources.jp_toku_kuni_pgn.dbf", location, true, ProcessMap); center = new Point(135, 37); zoom = 4; break; } if (maps.Layers != null && maps.Layers.Count != 0) { maps.Layers.Clear(); } maps.Layers.Add(layer); maps.MinZoom = zoom; maps.Zoom = zoom; maps.Center = center; }
public OfflineMaps() { this.InitializeComponent(); this.Loaded += OnMapsLoaded; currentPosition = new Point(-76.9057, 40.2726); vl = new C1VectorLayer(); this.maps.Layers.Add(vl); }
void InitialMaps() { maps.Source = null; vl = new C1VectorLayer(); // read world map from resources Utils.LoadShapeFromResource(vl, "MapsSamples.Resources.states.shp", "MapsSamples.Resources.states.dbf", true, ProcessUSMap); maps.Layers.Add(vl); }
public MapChart() { InitializeComponent(); maps.Source = null; vl = new C1VectorLayer() { LabelVisibility = LabelVisibility.Hidden, Foreground = new SolidColorBrush(Color.FromArgb(255, 0x97, 0x35, 0x35))}; // read text data from resources using (Stream stream = Assembly.GetExecutingAssembly() .GetManifestResourceStream("MapsSamples.Resources.gdp-ppp.txt")) { using (StreamReader sr = new StreamReader(stream)) { for (; !sr.EndOfStream; ) { string s = sr.ReadLine(); string[] ss = s.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries); countries.Add(new Country() { Name = ss[1].Trim(), Value = double.Parse(ss[2], CultureInfo.InvariantCulture) }); } } } // create palette ColorValues cvals = new ColorValues(); cvals.Add(new ColorValue() { Color = Color.FromArgb(255,241,244,255), Value = 0 }); cvals.Add(new ColorValue() { Color = Color.FromArgb(255, 241, 244, 255), Value = 5000 }); cvals.Add(new ColorValue() { Color = Color.FromArgb(255, 224, 224, 246), Value = 10000 }); cvals.Add(new ColorValue() { Color = Color.FromArgb(255, 203, 205, 255), Value = 20000 }); cvals.Add(new ColorValue() { Color = Color.FromArgb(255, 179, 182, 230), Value = 50000 }); cvals.Add(new ColorValue() { Color = Color.FromArgb(255, 156, 160, 240), Value = 100000 }); cvals.Add(new ColorValue() { Color = Color.FromArgb(255, 127, 132, 243), Value = 200000 }); cvals.Add(new ColorValue() { Color = Color.FromArgb(255, 89, 97, 230), Value = 500000 }); cvals.Add(new ColorValue() { Color = Color.FromArgb(255, 56, 64, 217), Value = 1000000 }); cvals.Add(new ColorValue() { Color = Color.FromArgb(255,19,26,148), Value = 2000000 }); cvals.Add(new ColorValue() { Color = Color.FromArgb(255,0,3,74), Value = 1.001 * countries.GetMax() }); countries.Converter = cvals; // read world map from resources Utils.LoadKMZFromResources(vl, "MapsSamples.Resources.WorldMap.kmz", true, ProcessWorldMap); maps.Layers.Add(vl); maps.TargetZoomChanged += new EventHandler<C1.WPF.PropertyChangedEventArgs<double>>(maps_TargetZoomChanged); InitLegend(); }
public static void LoadKMZFromResources(C1VectorLayer vl, string resname, bool clear, ProcessVectorItem pv) { using (Stream zipStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resname)) { if (zipStream != null) { if( clear) vl.Children.Clear(); vl.LoadKMZ(zipStream, true, pv); } } }
void Marks_Loaded(object sender, RoutedEventArgs e) { vl = new C1VectorLayer(); c1Maps1.Layers.Add(vl); c1Maps1.RightTapped += maps_RightTapped; c1Maps1.TargetCenter = new Point(0, 20); c1Maps1.Zoom = 2; for (int i = 0; i < 10; i++) { // create random coordinates Point pt = new Point(-80 + rnd.Next(160), -80 + rnd.Next(160)); AddMark(pt); } }
public static void LoadKMZFromResources(C1VectorLayer vl, string resname, bool clear, ProcessVectorItem pv) { using (Stream zipStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resname)) { if (zipStream != null) { if (clear) { vl.Children.Clear(); } vl.LoadKMZ(zipStream, true, pv); } } }
public static void LoadKMLFromResources(C1VectorLayer vl, string resname, bool clear, ProcessVectorItem pv) { using (Stream stream = typeof(Utils).GetTypeInfo().Assembly.GetManifestResourceStream(resname)) { if (stream != null) { if (clear) { vl.Children.Clear(); } vl.LoadKML(stream, false, pv); } } }
public Marks() { InitializeComponent(); vl = new C1VectorLayer(); maps.Layers.Add(vl); maps.MouseLeftButtonUp += new MouseButtonEventHandler(maps_MouseLeftButtonUp); for (int i = 0; i < 10; i++) { // create random coordinates Point pt = new Point(-80 + rnd.Next(160), -80 + rnd.Next(160)); AddMark(pt); } }
private void OnLoaded(object sender, RoutedEventArgs e) { vectorLayer = new C1VectorLayer(); Map.Source = new VirtualEarthRoadSource(); Map.Layers.Add(vectorLayer); var engine = OlapPanel.OlapEngine; engine.DataSource = DataService.GetService().ProductWiseSaleCollection; OlapGrid.DataSource = OlapPanel; engine.RowFields.Add("Category"); engine.RowFields.Add("Product"); engine.Fields["Product"].Width = 200; engine.ColumnFields.Add("Region"); engine.ValueFields.Add("Sale"); engine.ValueField.Format = "C"; }
public static void LoadShapeFromResource(C1VectorLayer vl, string resname, string dbfname, bool clear, ProcessShapeItem pv) { using (Stream shapeStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resname)) { using (Stream dbfStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(dbfname)) { if (shapeStream != null) { if (clear) vl.Children.Clear(); vl.LoadShape(shapeStream, dbfStream, true, pv); } } } }
public static void LoadShape(this C1VectorLayer vl, Stream stream, Stream dbfStream, Location location, bool centerAndZoom, ProcessShapeItem processShape) { Dictionary <C1VectorItemBase, C1ShapeAttributes> vects = ShapeReader.Read(stream, dbfStream); vl.BeginUpdate(); foreach (C1VectorItemBase vect in vects.Keys) { if (processShape != null) { processShape(vect, vects[vect], location); } vl.Children.Add(vect); } vl.EndUpdate(); }
void EarthQuakes_Loaded(object sender, RoutedEventArgs e) { if (this.maps.Layers.Count == 0) { var layer = new C1VectorLayer() { ItemStyle = (Style)this.Resources["style"], }; Utils.LoadKMLFromResources(layer, "MapsSamples.Resources.2.5_day_depth.kml", true, null); this.maps.Layers.Add(layer); } else { var layer = maps.Layers[0] as C1VectorLayer; Utils.LoadKMLFromResources(layer, "MapsSamples.Resources.2.5_day_depth.kml", true, null); } }
private void OnLoaded(object sender, RoutedEventArgs e) { vectorLayer = new C1VectorLayer(); Map.Source = new VirtualEarthRoadSource(); Map.Layers.Add(vectorLayer); if (!MainPage.IsWindowsPhoneDevice()) { scaleLayer = new C1VectorLayer(); ScaleMap.Source = new VirtualEarthRoadSource(); ScaleMap.Layers.Add(scaleLayer); } collectionView = DataService.GetService().ProductWiseSaleCollection; ProductList.ItemsSource = DataService.GetService().ProductList; RegionList.ItemsSource = DataService.GetService().RegionList; ProductList.SelectAll(); RegionList.SelectAll(); }
public static void LoadShapeFromResource(C1VectorLayer vl, string resname, string dbfname, Location location, bool clear, ProcessShapeItem pv) { using (Stream shapeStream = typeof(Utils).GetTypeInfo().Assembly.GetManifestResourceStream(resname)) { using (Stream dbfStream = typeof(Utils).GetTypeInfo().Assembly.GetManifestResourceStream(dbfname)) { if (shapeStream != null) { if (clear) { vl.Children.Clear(); } vl.LoadShape(shapeStream, dbfStream, location, true, pv); } } } }
private void vl_UriSourceLoaded(object sender, EventArgs e) { C1VectorLayer vl = (C1VectorLayer)sender; Rect bnds = vl.Children.GetBounds(); if (!bnds.IsEmpty) { maps.TargetCenter = new Point(bnds.Left + 0.5 * bnds.Width, bnds.Top + 0.5 * bnds.Height); double w = maps.ActualWidth > 0 ? maps.ActualWidth : 500; double h = maps.ActualHeight > 0 ? maps.ActualHeight : 500; double scale = Math.Max(bnds.Width / 360 * w, bnds.Height / 180 * h);; _zoom = Math.Log(512 / Math.Max(scale, 1), 2.0); maps.CenterChanged += (maps_CenterChanged); } }
public MapFilterPresenter() { _map = new C1Maps { Height = 200, Zoom = 2, Center = new Point(-83, 39), ShowTools = false, Source = new VirtualEarthRoadSource(), MinZoom = 2, MaxZoom = 2 }; _map.MouseDoubleClick += _map_MouseDoubleClick; _layer = new C1VectorLayer { LabelVisibility = LabelVisibility.Visible }; _map.Layers.Add(_layer); Items.Add(_map); }
public static void LoadKMZ(this C1VectorLayer vl, Stream stream, bool centerAndZoom, ProcessVectorItem processVector) { using (C1ZipFile zip = new C1ZipFile(stream)) { foreach (C1ZipEntry entry in zip.Entries) { if (entry.FileName.EndsWith(".kml")) { using (Stream docStream = entry.OpenReader()) { if (docStream != null) { LoadKML(vl, docStream, centerAndZoom, processVector); } } } } } }
void Cities_Loaded(object sender, RoutedEventArgs e) { Color fc = Color.FromArgb(0xff, 0xC0, 0x50, 0x4d); //maps.Foreground = new SolidColorBrush(fc); vl = new C1VectorLayer(); Stream stream = typeof(Cities).GetTypeInfo().Assembly.GetManifestResourceStream("MapsSamples.Resources.Cities100K.txt"); if (stream != null) { List<City> cities = City.Read(stream); vl.ItemTemplate = (DataTemplate)Resources["templCity"]; IEnumerable<City> source = from city in cities orderby city.Population descending select city; vl.ItemsSource = source.Take(500); } stream.Dispose(); stream = null; maps.Layers.Add(vl); }
public Cities() { InitializeComponent(); Color fc = Color.FromArgb(0xff, 0xC0, 0x50, 0x4d); maps.Foreground = new SolidColorBrush(fc); vl = new C1VectorLayer(); Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MapsSamples.Resources.Cities100K.txt"); if (stream != null) { List<City> cities = City.Read(stream); vl.ItemTemplate = (DataTemplate)Resources["templCity"]; IEnumerable<City> source = from city in cities orderby city.Population descending select city; vl.ItemsSource = source.Take(500); } maps.Layers.Add(vl); }
public static void LoadKML(this C1VectorLayer vl, Stream stream, bool centerAndZoom, ProcessVectorItem processVector) { using (StreamReader sr = new StreamReader(stream)) { string s = sr.ReadToEnd(); List <C1VectorItemBase> vects = KmlReader.Read(s); vl.BeginUpdate(); foreach (C1VectorItemBase vect in vects) { if (processVector != null) { if (!processVector(vect)) { continue; } } vl.Children.Add(vect); } vl.EndUpdate(); if (centerAndZoom) { Rect bnds = vects.GetBounds(); C1Maps maps = ((IMapLayer)vl).ParentMaps; if (maps != null) { maps.Center = new Point(bnds.Left + 0.5 * bnds.Width, bnds.Top + 0.5 * bnds.Height); double scale = Math.Max(bnds.Width / 360 * maps.ActualWidth, bnds.Height / 180 * maps.ActualHeight);; double zoom = Math.Log(512 / scale, 2.0); maps.TargetZoom = maps.Zoom = zoom > 0 ? zoom : 0; } } sr.Close(); } }
void Cities_Unloaded(object sender, RoutedEventArgs e) { this.maps.Zoom = 2; this.maps.Center = new Point(); //Release memory if (vl != null) { foreach (var child in vl.Children) { var place = child as C1VectorPlacemark; if (place != null) { place.Loaded -= C1VectorPlacemark_Loaded; } } } vl = null; this.maps.Layers.Clear(); }
public static void UpdataMapMark(C1VectorLayer vectorLayer, C1VectorLayer scaleLayer, bool isPhone) #endif { vectorLayer.Children.Clear(); #if WINDOWS_UWP if (!isPhone) { scaleLayer.Children.Clear(); } #endif var regionSalesCollection = new ListCollectionView(DataService.GetService().GetRegionWiseSales()); regionSalesCollection.SortDescriptions.Add(new SortDescription("Sales", ListSortDirection.Descending)); #if WPF double maxValue = (regionSalesCollection.GetItemAt(0) as RegionSaleItem).Sales; #elif WINDOWS_UWP double maxValue = (regionSalesCollection.ElementAt(0) as RegionSaleItem).Sales; #endif foreach (RegionSaleItem sales in regionSalesCollection) { C1VectorPlacemark mark = new C1VectorPlacemark(); mark.Label = string.Format("{0:C}", sales.Sales); mark.LabelPosition = LabelPosition.Center; mark.Geometry = CreateMarkBySale(sales.Sales, maxValue); mark.Fill = sales.Profit > 0 ? new SolidColorBrush(Colors.Orange) : new SolidColorBrush(Colors.RoyalBlue); mark.GeoPoint = sales.Locat; vectorLayer.Children.Add(mark); #if WINDOWS_UWP if (!isPhone) { C1VectorPlacemark clone = new C1VectorPlacemark(); clone.Label = mark.Label; clone.LabelPosition = mark.LabelPosition; clone.Geometry = mark.Geometry; clone.Fill = mark.Fill; clone.GeoPoint = sales.Locat; scaleLayer.Children.Add(clone); } #endif } }
public Cities() { InitializeComponent(); Color fc = Color.FromArgb(0xff, 0xC0, 0x50, 0x4d); maps.Foreground = new SolidColorBrush(fc); vl = new C1VectorLayer(); Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MapsSamples.Resources.Cities100K.txt"); if (stream != null) { List <City> cities = City.Read(stream); vl.ItemTemplate = (DataTemplate)Resources["templCity"]; IEnumerable <City> source = from city in cities orderby city.Population descending select city; vl.ItemsSource = source.Take(500); } maps.Layers.Add(vl); }
void Grid_Loaded(object sender, RoutedEventArgs e) { Color fc = Colors.LightGray;// Color.FromArgb(0xff, 0xC0, 0x50, 0x4d); Color bk = Color.FromArgb(0xff, 0x44, 0x44, 0x44); Color bb = Colors.Black; maps.Foreground = new SolidColorBrush(fc); maps.Background = new SolidColorBrush(bk); maps.BorderBrush = new SolidColorBrush(bb); vl = new C1VectorLayer(); SolidColorBrush stroke = new SolidColorBrush(Colors.LightGray); for (int lon = -180; lon <= 180; lon += 30) { DoubleCollection dc = new DoubleCollection(); dc.Add(1); dc.Add(2); C1VectorPolyline pl = new C1VectorPolyline() { Stroke = stroke }; PointCollection pc = new PointCollection(); pc.Add(new Point(lon, -85)); pc.Add(new Point(lon, +85)); pl.Points = pc; vl.Children.Insert(0, pl); string lbl = Math.Abs(lon).ToString() + Strings.Degree; if (lon > 0) { lbl += Strings.East; } else if (lon < 0) { lbl += Strings.West; } C1VectorPlacemark pm = new C1VectorPlacemark() { GeoPoint = new Point(lon, 0), Label = lbl, LabelPosition = LabelPosition.Top }; vl.Children.Add(pm); } for (int lat = -80; lat <= 80; lat += 20) { DoubleCollection dc = new DoubleCollection(); dc.Add(1); dc.Add(2); C1VectorPolyline pl = new C1VectorPolyline() { Stroke = stroke }; PointCollection pc = new PointCollection(); pc.Add(new Point(-180, lat)); pc.Add(new Point(180, lat)); pl.Points = pc; vl.Children.Insert(0, pl); string lbl = Math.Abs(lat).ToString() + Strings.Degree; if (lat > 0) { lbl += Strings.North; } else if (lat < 0) { lbl += Strings.South; } C1VectorPlacemark pm = new C1VectorPlacemark() { GeoPoint = new Point(0, lat), Label = lbl, LabelPosition = LabelPosition.Right }; vl.Children.Add(pm); } maps.Layers.Add(vl); }
public Grid() { InitializeComponent(); Color fc = Colors.LightGray;// Color.FromArgb(0xff, 0xC0, 0x50, 0x4d); Color bk = Color.FromArgb(0xff, 0x44, 0x44, 0x44); Color bb = Colors.Black; maps.Foreground = new SolidColorBrush(fc); maps.Background = new SolidColorBrush(bk); maps.BorderBrush = new SolidColorBrush(bb); vl = new C1VectorLayer(); SolidColorBrush stroke = new SolidColorBrush(Colors.LightGray); for (int lon = -180; lon <= 180; lon += 30) { DoubleCollection dc = new DoubleCollection(); dc.Add(1); dc.Add(2); C1VectorPolyline pl = new C1VectorPolyline() { Stroke = stroke, StrokeDashArray = dc }; PointCollection pc = new PointCollection(); pc.Add(new Point(lon, -85)); pc.Add(new Point(lon, +85)); pl.Points = pc; vl.Children.Insert(0, pl); string lbl = Math.Abs(lon).ToString() + "°"; if (lon > 0) { lbl += "E"; } else if (lon < 0) { lbl += "W"; } C1VectorPlacemark pm = new C1VectorPlacemark() { GeoPoint = new Point(lon, 0), Label = lbl, LabelPosition = LabelPosition.Top }; vl.Children.Add(pm); } for (int lat = -80; lat <= 80; lat += 20) { DoubleCollection dc = new DoubleCollection(); dc.Add(1); dc.Add(2); C1VectorPolyline pl = new C1VectorPolyline() { Stroke = stroke, StrokeDashArray = dc }; PointCollection pc = new PointCollection(); pc.Add(new Point(-180, lat)); pc.Add(new Point(180, lat)); pl.Points = pc; vl.Children.Insert(0, pl); string lbl = Math.Abs(lat).ToString() + "°"; if (lat > 0) { lbl += "N"; } else if (lat < 0) { lbl += "S"; } C1VectorPlacemark pm = new C1VectorPlacemark() { GeoPoint = new Point(0, lat), Label = lbl, LabelPosition = LabelPosition.Right }; vl.Children.Add(pm); } maps.Layers.Add(vl); }
public Grid() { InitializeComponent(); Color fc = Colors.LightGray;// Color.FromArgb(0xff, 0xC0, 0x50, 0x4d); Color bk = Color.FromArgb(0xff, 0x44, 0x44, 0x44); Color bb = Colors.Black; maps.Foreground = new SolidColorBrush(fc); maps.Background = new SolidColorBrush(bk); maps.BorderBrush = new SolidColorBrush(bb); vl = new C1VectorLayer(); SolidColorBrush stroke = new SolidColorBrush(Colors.LightGray); for (int lon = -180; lon <= 180; lon += 30) { DoubleCollection dc = new DoubleCollection(); dc.Add(1); dc.Add(2); C1VectorPolyline pl = new C1VectorPolyline() { Stroke=stroke, StrokeDashArray=dc}; PointCollection pc = new PointCollection(); pc.Add( new Point(lon, -85)); pc.Add( new Point(lon, +85)); pl.Points = pc; vl.Children.Insert(0,pl); string lbl = Math.Abs(lon).ToString() + "°"; if (lon > 0) lbl += "E"; else if (lon < 0) lbl += "W"; C1VectorPlacemark pm = new C1VectorPlacemark() { GeoPoint = new Point(lon,0), Label = lbl, LabelPosition = LabelPosition.Top }; vl.Children.Add(pm); } for (int lat = -80; lat <= 80; lat += 20) { DoubleCollection dc = new DoubleCollection(); dc.Add(1); dc.Add(2); C1VectorPolyline pl = new C1VectorPolyline() { Stroke = stroke, StrokeDashArray=dc }; PointCollection pc = new PointCollection(); pc.Add(new Point(-180,lat)); pc.Add(new Point(180, lat)); pl.Points = pc; vl.Children.Insert(0,pl); string lbl = Math.Abs(lat).ToString() + "°"; if (lat > 0) lbl += "N"; else if( lat<0) lbl += "S"; C1VectorPlacemark pm = new C1VectorPlacemark() { GeoPoint = new Point(0, lat), Label = lbl, LabelPosition = LabelPosition.Right }; vl.Children.Add(pm); } maps.Layers.Add(vl); }
public MapChart() { InitializeComponent(); maps.Source = null; vl = new C1VectorLayer() { LabelVisibility = LabelVisibility.Hidden, Foreground = new SolidColorBrush(Color.FromArgb(255, 0x97, 0x35, 0x35)) }; // read text data from resources using (Stream stream = Assembly.GetExecutingAssembly() .GetManifestResourceStream("MapsSamples.Resources.gdp-ppp.txt")) { using (StreamReader sr = new StreamReader(stream)) { for (; !sr.EndOfStream;) { string s = sr.ReadLine(); string[] ss = s.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries); countries.Add(new Country() { Name = ss[1].Trim(), Value = double.Parse(ss[2], CultureInfo.InvariantCulture) }); } } } // create palette ColorValues cvals = new ColorValues(); cvals.Add(new ColorValue() { Color = Color.FromArgb(255, 241, 244, 255), Value = 0 }); cvals.Add(new ColorValue() { Color = Color.FromArgb(255, 241, 244, 255), Value = 5000 }); cvals.Add(new ColorValue() { Color = Color.FromArgb(255, 224, 224, 246), Value = 10000 }); cvals.Add(new ColorValue() { Color = Color.FromArgb(255, 203, 205, 255), Value = 20000 }); cvals.Add(new ColorValue() { Color = Color.FromArgb(255, 179, 182, 230), Value = 50000 }); cvals.Add(new ColorValue() { Color = Color.FromArgb(255, 156, 160, 240), Value = 100000 }); cvals.Add(new ColorValue() { Color = Color.FromArgb(255, 127, 132, 243), Value = 200000 }); cvals.Add(new ColorValue() { Color = Color.FromArgb(255, 89, 97, 230), Value = 500000 }); cvals.Add(new ColorValue() { Color = Color.FromArgb(255, 56, 64, 217), Value = 1000000 }); cvals.Add(new ColorValue() { Color = Color.FromArgb(255, 19, 26, 148), Value = 2000000 }); cvals.Add(new ColorValue() { Color = Color.FromArgb(255, 0, 3, 74), Value = 1.001 * countries.GetMax() }); countries.Converter = cvals; // read world map from resources Utils.LoadKMZFromResources(vl, "MapsSamples.Resources.WorldMap.kmz", true, ProcessWorldMap); maps.Layers.Add(vl); maps.TargetZoomChanged += new EventHandler <C1.WPF.PropertyChangedEventArgs <double> >(maps_TargetZoomChanged); InitLegend(); }
public static void UpdataMapMark(C1VectorLayer vectorLayer)