private void InitializeMap(GeoPosition position) { _walkedPathLayer = new WalkedPathLayer(VisitedWaypoints, Consts.WalkedPathLayerName); _mapView.AddLayer(_walkedPathLayer); _positionLayer = new PositionLayer(position, new SymbolStyle { Fill = new Brush(Color.FromString("#3366CC")), SymbolScale = 0.25, SymbolType = SymbolType.Ellipse }); _mapView.AddLayer(_positionLayer); _mapView.AddLayer(new PointOfInterestLayer(_route.Waypoints.OfType <PointOfInterest>())); _expectedPositionLayer = new PositionLayer(GetLastWayPoint(), new SymbolStyle { BitmapId = GetBitMap("FamilieWandelPad.Assets.navigationArrow.svg"), SymbolScale = 0.075, RotateWithMap = true }); _mapView.AddLayer(_expectedPositionLayer); UpdateMap(position, GetLastWayPoint(), false); }
public void Render(object target, IReadOnlyViewport viewport, IEnumerable <ILayer> layers, IEnumerable <IWidget> widgets, Color background = null) { var allWidgets = layers.Select(l => l.Attribution).ToList().Where(w => w != null).Concat(widgets).ToList(); RenderTypeSave((Canvas)target, viewport, layers, allWidgets, background); }
public static void Draw(SKCanvas canvas, IViewport viewport, IStyle style, IGeometry geometry) { var lineString = ((LineString) geometry).Vertices; float lineWidth = 1; var lineColor = new Color(); var vectorStyle = style as VectorStyle; if (vectorStyle != null) { lineWidth = (float) vectorStyle.Line.Width; lineColor = vectorStyle.Line.Color; } var line = WorldToScreen(viewport, lineString); var path = ToSkia(line); using (var paint = new SKPaint()) { paint.IsStroke = true; paint.StrokeWidth = lineWidth; paint.Color = lineColor.ToSkia(); paint.StrokeJoin = SKStrokeJoin.Round; canvas.DrawPath(path, paint); } }
public NetworkMap(BackgroundLayerSet backgroundLayerSet) { InitializeComponent(); _backgroundLayerSet = backgroundLayerSet; _defaultColor = Mapsui.Styles.Color.Black; _nodes = new Dictionary <Mapsui.Providers.Feature, Node2>(); _links = new Dictionary <Mapsui.Providers.Feature, Link>(); _nodeStyles = new Dictionary <System.Windows.Media.Color, SymbolStyle>(); _linkStyles = new Dictionary <System.Windows.Media.Color, VectorStyle>(); Clear(); _nodeLegend = new Legend() { VerticalAlignment = System.Windows.VerticalAlignment.Top, HorizontalAlignment = System.Windows.HorizontalAlignment.Left, Margin = new System.Windows.Thickness(5, 5, 0, 0), Visibility = System.Windows.Visibility.Collapsed, }; _linkLegend = new Legend() { VerticalAlignment = System.Windows.VerticalAlignment.Top, HorizontalAlignment = System.Windows.HorizontalAlignment.Left, Margin = new System.Windows.Thickness(5, 5, 0, 0), Visibility = System.Windows.Visibility.Collapsed, }; root.Children.Add(_nodeLegend); root.Children.Add(_linkLegend); }
private void Render(Canvas canvas, IViewport viewport, IEnumerable<ILayer> layers, IEnumerable<IWidget> widgets, Color background = null) { Clear(canvas, background); if (viewport.Initialized) Render(canvas, viewport, layers); Render(canvas, widgets); }
public static Color Copy(this Color color) { if (color == null) { return(null); } return(new Color(color.R, color.G, color.B, color.A)); }
public static WinColor ToXaml(this Color color) { if (color == null) { return(WinColor.FromArgb(0, 255, 255, 255)); } return(WinColor.FromArgb((byte)color.A, (byte)color.R, (byte)color.G, (byte)color.B)); }
public static IStyle CreateLineStringStyle() { return(new VectorStyle { Fill = null, Outline = null, Line = { Color = Color.FromString("Red"), Width = 4 } }); }
private static void Clear(Canvas canvas, Color background) { canvas.Background = ToBackground(background); foreach (var child in canvas.Children) { (child as Canvas)?.Children.Clear(); } canvas.Children.Clear(); }
private void RenderTypeSave(Canvas canvas, IReadOnlyViewport viewport, IEnumerable <ILayer> layers, IEnumerable <IWidget> widgets, Color background = null) { if (!viewport.HasSize) { return; } Clear(canvas, background); Render(canvas, viewport, layers); Render(canvas, viewport, widgets); }
private static MemoryStream RenderToBitmapStreamStatic(IViewport viewport, IEnumerable <ILayer> layers, SymbolCache symbolCache, Color background) { var canvas = new Canvas(); Render(canvas, viewport, layers, background, symbolCache, true); var bitmapStream = BitmapRendering.BitmapConverter.ToBitmapStream(canvas, (int)viewport.Width, (int)viewport.Height); canvas.Children.Clear(); canvas.Dispatcher.InvokeShutdown(); return(bitmapStream); }
private static void Render(Canvas target, IViewport viewport, IEnumerable <ILayer> layers, Color background, bool rasterizing) { #if !NETFX_CORE target.BeginInit(); #endif target.Background = background == null ? null : new XamlMedia.SolidColorBrush { Color = background.ToXaml() }; target.Visibility = Visibility.Collapsed; foreach (var child in target.Children) { (child as Canvas)?.Children.Clear(); } target.Children.Clear(); layers = layers.ToList(); foreach (var layer in layers) { if (!layer.Enabled) { continue; } if (layer.MinVisible > viewport.Resolution) { continue; } if (layer.MaxVisible < viewport.Resolution) { continue; } RenderLayer(target, viewport, layer, rasterizing); } target.Arrange(new Rect(0, 0, viewport.Width, viewport.Height)); target.Visibility = Visibility.Visible; #if !NETFX_CORE if (DeveloperTools.DeveloperMode) { DrawDebugInfo(target, layers); } #endif #if !NETFX_CORE target.EndInit(); #endif }
public static ILayer CreateLineLayer(List <Feature> lines, Mapsui.Styles.Color colour) { return(new Layer("Lines") { CRS = "EPSG:3857", DataSource = new MemoryProvider(lines), IsMapInfoLayer = true, Style = new VectorStyle { Fill = null, Outline = null, Line = { Color = colour, Width = 5 } } }); }
public static ILayer CreatePolygonLayer(List <Feature> polygons, Mapsui.Styles.Color lineColour, Mapsui.Styles.Color fillColour) { return(new Layer("Polygons") { CRS = "EPSG:3857", DataSource = new MemoryProvider(polygons), IsMapInfoLayer = true, Style = new VectorStyle { Fill = new Mapsui.Styles.Brush(fillColour), Outline = new Pen { Color = lineColour, Width = 5, PenStyle = PenStyle.Solid, PenStrokeCap = PenStrokeCap.Round } } }); }
public static ILayer CreateLayer(List <Polygon> polys, Mapsui.Styles.Color fillColor, Mapsui.Styles.Color outlineColor) { return(new Layer("Polygons") { DataSource = new MemoryProvider(polys) { CRS = "EPSG:4326" }, Style = new VectorStyle { Fill = new Brush(fillColor), Outline = new Pen { Color = outlineColor, Width = 4, PenStyle = PenStyle.Solid, PenStrokeCap = PenStrokeCap.Round } } }); }
private static CGColor ToCGColor(Mapsui.Styles.Color color) { return(new CoreGraphics.CGColor(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f)); }
public MemoryStream RenderToBitmapStream(IViewport viewport, IEnumerable <ILayer> layers, Color background = null) { MemoryStream bitmapStream = null; RunMethodOnStaThread(() => bitmapStream = RenderToBitmapStreamStatic(viewport, layers, background)); return(bitmapStream); }
public void Render(object target, IViewport viewport, IEnumerable <ILayer> layers, Color background) { Render((Canvas)target, viewport, layers, background, false); }
public MemoryStream RenderToBitmapStream(IViewport viewport, IEnumerable <ILayer> layers, Color background = null) { #if NETFX_CORE throw new NotImplementedException(); #else MemoryStream bitmapStream = null; RunMethodOnStaThread(() => bitmapStream = RenderToBitmapStreamStatic(viewport, layers, background)); return(bitmapStream); #endif }
public MapControl(BackgroundLayerSet backgroundLayerSet) : this() { _backgroundLayerSet = backgroundLayerSet; _defaultColor = Mapsui.Styles.Color.Black; Clear(); }
private static XamlMedia.SolidColorBrush ToBackground(Color background) { return(background == null ? null : new XamlMedia.SolidColorBrush { Color = background.ToXaml() }); }
public MemoryStream RenderToBitmapStream(IReadOnlyViewport viewport, IEnumerable <ILayer> layers, Color background = null, float pixelDensity = 1) { MemoryStream bitmapStream = null; RunMethodOnStaThread(() => bitmapStream = RenderToBitmapStreamStatic(viewport, layers, _symbolCache)); return(bitmapStream); }
public MemoryStream RenderToBitmapStream(IViewport viewport, IEnumerable<ILayer> layers, Color background = null) { MemoryStream bitmapStream = null; RunMethodOnStaThread(() => bitmapStream = RenderToBitmapStreamStatic(viewport, layers, background)); return bitmapStream; }
public void Render(object target, IViewport viewport, IEnumerable<ILayer> layers, Color background) { Render((Canvas) target, viewport, layers, background, false); }
private static MemoryStream RenderToBitmapStreamStatic(IViewport viewport, IEnumerable<ILayer> layers, Color background) { var canvas = new Canvas(); Render(canvas, viewport, layers, background, true); var bitmapStream = BitmapRendering.BitmapConverter.ToBitmapStream(canvas, (int)viewport.Width, (int)viewport.Height); canvas.Children.Clear(); canvas.Dispatcher.InvokeShutdown(); return bitmapStream; }
public static WinColor ToXaml(this Color color) { return(WinColor.FromArgb((byte)color.A, (byte)color.R, (byte)color.G, (byte)color.B)); }
public static AndroidColor ToAndroid(this Color color) { return(new AndroidColor(color.R, color.G, color.B, color.A)); }
private static void Render(Canvas target, IViewport viewport, IEnumerable<ILayer> layers, Color background, bool rasterizing) { target.BeginInit(); target.Background = background == null ? null : new XamlMedia.SolidColorBrush {Color = background.ToXaml()}; target.Visibility = Visibility.Collapsed; foreach (var child in target.Children) { (child as Canvas)?.Children.Clear(); } target.Children.Clear(); layers = layers.ToList(); foreach (var layer in layers) { if (!layer.Enabled) continue; if (layer.MinVisible > viewport.Resolution) continue; if (layer.MaxVisible < viewport.Resolution) continue; RenderLayer(target, viewport, layer, rasterizing); } target.Arrange(new Rect(0, 0, viewport.Width, viewport.Height)); target.Visibility = Visibility.Visible; if (DeveloperTools.DeveloperMode) { DrawDebugInfo(target, layers); } target.EndInit(); }
protected override async void OnAppearing() { if (Navigator != null) { return; } await Application.Current.MainPage.Navigation.PushModalAsync(new LookingForGpsPage()); Route route = null; try { route = await _routeTask; } catch (Exception e) { var properties = new Dictionary <string, string> { { "Category", "Route parsing" } }; Crashes.TrackError(e, properties); return; } try { MapView.Info += async(sender, args) => { args.Handled = true; if (args.MapInfo.Feature is PointOfInterestFeature poif) { await poif.OnClick(); } }; var routeLayer = new PathLayer( route.GetEnumerable(route.Waypoints.First(), Direction.Forward), Consts.MainPathLayerName ); routeLayer.Style = null; routeLayer.feature.Styles.Add( new VectorStyle() { Line = new Pen(Color.FromArgb(255, 48, 78, 130)) { PenStyle = PenStyle.Solid, Width = 15d } } ); routeLayer.feature.Styles.Add( new VectorStyle() { Line = new Pen(Color.FromArgb(255, 45, 115, 200)) { PenStyle = PenStyle.Solid, Width = 12d } } ); MapView.Map.Layers.Add(routeLayer); } catch (Exception e) { var properties = new Dictionary <string, string> { { "Category", "Map styling" } }; Crashes.TrackError(e, properties); return; } try { NavigationStats = new NavigationStats(route); Navigator = new Navigator(MapView, route, CrossGeolocator.Current, NavigationStats); DistanceLabel.SetBinding(Label.TextProperty, new Binding("Progress", source: NavigationStats)); if (await Navigator.StartNavigation()) { await Application.Current.MainPage.Navigation.PopModalAsync(); } } catch (Exception e) { var properties = new Dictionary <string, string> { { "Category", "Navigation" } }; Crashes.TrackError(e, properties); return; } }