/// <summary> /// Shows how to render circles with a geographic radius of 250km /// Note: you'll have to take the latitude into account! /// </summary> /// <param name="layer"></param> public void AddCircles(ShapeLayer layer) { for (int lon = -180; lon <= +180; lon = lon + 10) { for (int lat = -80; lat <= +80; lat = lat + 10) { double radius = 250000; // radius in meters double cosB = Math.Cos(lat / 360.0 * (2 * Math.PI)); // factor depends on latitude double ellipseSize = Math.Abs(1.0 / cosB * radius) * 2; // size mercator units var ellipse = new Ellipse { Width = ellipseSize, Height = ellipseSize, Fill = new SolidColorBrush(Color.FromArgb(128, 0, 0, 255)), Stroke = new SolidColorBrush(Colors.Black), StrokeThickness = 25000 }; ShapeCanvas.SetScaleFactor(ellipse, 1); // scale linear ShapeCanvas.SetLocation(ellipse, new Point(lon, lat)); layer.Shapes.Add(ellipse); // bonus: show how to add a popup that the location (a the ellipse center) ellipse.Tag = new Point(lon, lat); ellipse.MouseEnter += Ellipse_MouseEnter; ellipse.MouseLeave += Ellipse_MouseLeave; } } }
/// <summary> /// Besides the individual customized symbols, which can be any objects of type FrameworkElement, /// additionally labels are added into the shape layer. /// </summary> /// <param name="frameworkElement">New shape element to insert into the shape layer.</param> /// <param name="animation">Optionally an animation can be specified applied to the new shape.</param> private void AddToLayer(FrameworkElement frameworkElement, Timeline animation = null) { #region doc:add to layer // Because of a different positioning of labels for objects of type MapPolylineBase compared // to other object types, two different implementations are available if (frameworkElement is MapPolylineBase) { shapeLayer.Shapes.Add(frameworkElement); // Create a label at the position specified in the Location property of the MapPolyline object. var border = CreateLabel("Hello"); ShapeCanvas.SetLocation(border, ShapeCanvas.GetLocation(frameworkElement)); shapeLayer.Shapes.Add(border); } else { // Arrange symbol and text label in a stack panel var stackPanel = new StackPanel(); stackPanel.Children.Add(frameworkElement); stackPanel.Children.Add(CreateLabel("Hello")); // The following properties of the new object are transferred to the StackPanel for // correct behavior. ShapeCanvas.SetLocation(stackPanel, ShapeCanvas.GetLocation(frameworkElement)); ShapeCanvas.SetAnchor(stackPanel, ShapeCanvas.GetAnchor(frameworkElement)); ShapeCanvas.SetScale(stackPanel, ShapeCanvas.GetScale(frameworkElement)); ShapeCanvas.SetScaleFactor(stackPanel, ShapeCanvas.GetScaleFactor(frameworkElement)); shapeLayer.Shapes.Add(stackPanel); // Add the option animation if (animation == null) { return; } // Set the animation to target the Center property of the stack panel object Storyboard.SetTarget(animation, stackPanel); Storyboard.SetTargetProperty(animation, new PropertyPath(ShapeCanvas.LocationProperty)); // Create a storyboard to apply the animation. var sb = new Storyboard(); sb.Children.Add(animation); sb.Begin(); } #endregion //doc:add to layer }
public void AddSymbols() { var layer = Map.Layers["Symbols"]; if (layer != null) { Map.Layers.Remove(layer); } var symbolLayer = new ShapeLayer("Symbols") { LazyUpdate = useSymLazyUpdate }; Map.Layers.Add(symbolLayer); for (int i = 0; i < coordinates.Count; i++) { const int symbolSize = 25; var color = i % 3 == 0 ? Colors.Blue : i % 3 == 1 ? Colors.Green : Colors.Red; FrameworkElement symbol; if (useSymBitmapCaching) { var bitmap = GetCachedBitmap(color, symbolSize); symbol = new Image { Source = bitmap }; } else { symbol = new Pyramid { Color = color }; symbol.Width = symbol.Height = symbolSize; } // log-scaling parameters ShapeCanvas.SetScale(symbol, 10); ShapeCanvas.SetScaleFactor(symbol, 0.4); ShapeCanvas.SetLocation(symbol, coordinates[i]); symbol.ToolTip = "Hello"; symbolLayer.Shapes.Add(symbol); } }
private static void AddCircle(ShapeLayer layer, Point center, double radius) { // calculate the size in mercator units var cosB = Math.Cos(center.Y * Math.PI / 180.0); // factor depends on latitude var ellipseSize = Math.Abs(1.0 / cosB * radius) * 2; // size mercator units var ellipse = new Ellipse { Width = ellipseSize, Height = ellipseSize, Fill = new SolidColorBrush(Color.FromArgb(128, 0, 0, 255)), Stroke = new SolidColorBrush(Colors.LightBlue), StrokeThickness = 25 }; ShapeCanvas.SetScaleFactor(ellipse, 1); // scale linear ShapeCanvas.SetLocation(ellipse, center); layer.Shapes.Add(ellipse); }
/// <summary> /// Load local image files and add it to the map /// See also http://www.i-programmer.info/programming/wpf-workings/520-bitmapimage-and-local-files-.html /// </summary> /// <param name="layer"></param> public void AddShapes(ShapeLayer layer) { // add ptv logo var ptvLogo = new Image(); var src = new BitmapImage(); src.BeginInit(); src.CacheOption = BitmapCacheOption.OnLoad; src.UriSource = new Uri("Icons\\Logo_PTV_Screen-mini.tif", UriKind.Relative); src.EndInit(); ptvLogo.Source = src; ShapeCanvas.SetLocation(ptvLogo, new Point(8.428253, 49.013432)); ptvLogo.Name = "PTV"; // optional: set explicit size and scale factor ptvLogo.Height = 100; ShapeCanvas.SetScaleFactor(ptvLogo, .1); layer.Shapes.Add(ptvLogo); // add cas logo var casLogo = new Image(); src = new BitmapImage(); src.BeginInit(); src.CacheOption = BitmapCacheOption.OnLoad; src.UriSource = new Uri("Icons\\logoCAS-Software-AG-DE.gif", UriKind.Relative); src.EndInit(); casLogo.Source = src; casLogo.Name = "CAS"; ShapeCanvas.SetLocation(casLogo, new Point(8.439220, 49.021664)); // optional: set explicit size and scale factor casLogo.Height = 100; ShapeCanvas.SetScaleFactor(casLogo, .1); layer.Shapes.Add(casLogo); }
public void AddBalloon(MultiCanvasShapeLayer layer, double lat, double lon, Color color, string text, string tooltip) { // create and initialize balloon var balloon = new Balloon { Color = color, Text = text, ToolTip = tooltip }; // set geo location ShapeCanvas.SetLocation(balloon, new System.Windows.Point(lon, lat)); // optional use adaptive (zoom-dependent scaling) ShapeCanvas.SetScale(balloon, 2.5); ShapeCanvas.SetScaleFactor(balloon, 0.1); // don't need a z_index, use TopShapes instead. // Canvas.SetZIndex(balloon, 1); // add to map layer.TopShapes.Add(balloon); }
/// <summary> /// The arrow demo is uses an adaption of Charles Petzold's WPF arrow class /// http://charlespetzold.com/blog/2007/04/191200.html to be used as custom MapShape /// </summary> /// <param name="layer"></param> public void AddPinWithLabel(ShapeLayer layer) { // text and symbol as two shapes Control pin = new Pin(); pin.Width = pin.Height = 30; ShapeCanvas.SetLocation(pin, new Point(8.4, 49)); ShapeCanvas.SetAnchor(pin, LocationAnchor.RightBottom); layer.Shapes.Add(pin); var textBlock = new TextBlock { Text = "Hello", Background = new SolidColorBrush(Colors.White), Foreground = new SolidColorBrush(Colors.Black) }; ShapeCanvas.SetLocation(textBlock, new Point(8.4, 49)); ShapeCanvas.SetAnchor(textBlock, LocationAnchor.LeftTop); layer.Shapes.Add(textBlock); // text with symbol in a view box var grid = new Grid(); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(50) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(50) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(50) }); var viewBox = new Viewbox { Stretch = Stretch.Uniform }; pin = new Cube(); viewBox.Child = pin; Grid.SetRow(viewBox, 0); grid.Children.Add(viewBox); viewBox = new Viewbox { Stretch = Stretch.Uniform }; textBlock = new TextBlock { Text = "Hello", Background = new SolidColorBrush(Colors.White), Foreground = new SolidColorBrush(Colors.Black) }; viewBox.Child = textBlock; Grid.SetRow(viewBox, 1); grid.Children.Add(viewBox); ShapeCanvas.SetLocation(grid, new Point(8.5, 49)); ShapeCanvas.SetScaleFactor(grid, .1); layer.Shapes.Add(grid); }
/// <summary> Adds elements to the map. </summary> private void AddElements() { #region doc:the location around which the shapes are created // the location in Gauss-Kruger coordinates var location = new Point(3565913, 5935734); #endregion #region doc:create ShapeLayer // create a shape layer shapeLayer = new ShapeLayer("DifferentShapes") { SpatialReferenceId = "EPSG:31467", // set SR to Gaus s-Kruger zone 3 (default is WGS84) LocalOffset = location // the localOffset can be used to reduce jitter at deep zoom levels }; shapeLayer2 = new ShapeLayer("PieCharts") { LocalOffset = new Point(10, 53) // to reduce jitter }; #endregion //doc:create ShapeLayer #region doc:add layer to map // add layers to map wpfMap.Layers.Add(shapeLayer); wpfMap.Layers.InsertBefore(shapeLayer2, "DifferentShapes"); #endregion //doc:add layer to map #region doc:animate shape // create a WPF element var triangleUp = new TriangleUp { Color = Colors.Blue, Stroke = Colors.Red, HorizontalAlignment = HorizontalAlignment.Left, ToolTip = "TriangleUp", Width = 32, Height = 32 }; // set geo location of the element triangleUp.SetValue(ShapeCanvas.LocationProperty, location); // add some click interaction triangleUp.MouseDoubleClick += (o, e) => MessageBox.Show("Hello!"); var myPointAnimation = new PointAnimation { Duration = TimeSpan.FromSeconds(2), AutoReverse = true, RepeatBehavior = RepeatBehavior.Forever, From = location, To = new Point(location.X + 960, location.Y + 960) }; // add to layer AddToLayer(triangleUp, myPointAnimation); #endregion //doc:animate shape #region doc:add MapPolygon var poly = new MapPolygon { Points = new PointCollection(new[] { (Point)(location - new Point(-100, -100)), (Point)(location - new Point(100, -100)), (Point)(location - new Point(100, 100)), (Point)(location - new Point(-100, 100)) }), Fill = new SolidColorBrush(Colors.Red), Opacity = .5, MapStrokeThickness = 5, Stroke = new SolidColorBrush(Colors.Black) }; Panel.SetZIndex(poly, -1); AddToLayer(poly); #endregion //doc:add MapPolygon #region doc:handle MapPolygon events poly.MouseEnter += (o, e) => poly.Fill = new SolidColorBrush(Colors.Green); poly.MouseLeave += (o, e) => poly.Fill = new SolidColorBrush(Colors.Red); #endregion //doc:handle MapPolygon events #region doc:create shapes // Create elements var triangleDown = CreateElement(Symbols.TriangleDown, Colors.Black, Colors.Red) as TriangleDown; var star = CreateElement(Symbols.Star, Colors.Yellow, Colors.Green) as Star; var pentagon = CreateElement(Symbols.Pentagon, Colors.Red, Colors.Blue) as Pentagon; var hexagon = CreateElement(Symbols.Hexagon, Colors.Orange, Colors.Navy) as Hexagon; var diamond = CreateElement(Symbols.Diamond, Colors.DeepPink, Colors.Navy) as Diamond; var pyramid = CreateElement(Symbols.Pyramid, Colors.Yellow, Colors.Black) as Pyramid; var ball = CreateElement(Symbols.Ball, Colors.Yellow, Colors.Green) as Ball; ball.Width = ball.Height = 100; // Varying the default size var pin = CreateElement(Symbols.Pin, Colors.Green, Colors.Black) as Pin; var cube = CreateElement(Symbols.Cube, Colors.Blue, Colors.Red) as Cube; cube.Width = cube.Height = 15; // Varying the default size var truck = CreateElement(Symbols.Truck, Colors.Red, Colors.Black) as Truck; #endregion //doc:create shapes #region doc:set position // set position triangleDown.SetValue(ShapeCanvas.LocationProperty, new Point(location.X + 320, location.Y)); Panel.SetZIndex(triangleDown, -1); star.SetValue(ShapeCanvas.LocationProperty, new Point(location.X + 640, location.Y)); Panel.SetZIndex(star, -1); pentagon.SetValue(ShapeCanvas.LocationProperty, new Point(location.X + 960, location.Y)); Panel.SetZIndex(pentagon, -1); hexagon.SetValue(ShapeCanvas.LocationProperty, new Point(location.X, location.Y + 320)); Panel.SetZIndex(hexagon, -1); diamond.SetValue(ShapeCanvas.LocationProperty, new Point(location.X + 320, location.Y + 320)); Panel.SetZIndex(diamond, -1); pyramid.SetValue(ShapeCanvas.LocationProperty, new Point(location.X + 640, location.Y + 320)); Panel.SetZIndex(pyramid, -1); ball.SetValue(ShapeCanvas.LocationProperty, new Point(location.X + 960, location.Y + 320)); Panel.SetZIndex(ball, -1); pin.SetValue(ShapeCanvas.LocationProperty, new Point(location.X, location.Y + 640)); ShapeCanvas.SetAnchor(pin, LocationAnchor.RightBottom); Panel.SetZIndex(pin, -1); cube.SetValue(ShapeCanvas.LocationProperty, new Point(location.X + 320, location.Y + 640)); Panel.SetZIndex(cube, -1); truck.SetValue(ShapeCanvas.LocationProperty, new Point(location.X + 960, location.Y + 640)); Panel.SetZIndex(truck, -1); #endregion //doc:set position AddToLayer(triangleDown); AddToLayer(star); AddToLayer(pentagon); AddToLayer(hexagon); AddToLayer(diamond); AddToLayer(pyramid); AddToLayer(ball); AddToLayer(pin); AddToLayer(cube); AddToLayer(truck); #region doc:sample anchor var pinRightBottom = CreateElement(Symbols.Pin, Colors.Green, Colors.Black) as Pin; if (pinRightBottom != null) { pinRightBottom.SetValue(ShapeCanvas.LocationProperty, new Point(location.X - 320, location.Y)); pinRightBottom.ToolTip = "Pin with anchor right bottom"; ShapeCanvas.SetAnchor(pinRightBottom, LocationAnchor.RightBottom); Panel.SetZIndex(pinRightBottom, -1); AddToLayer(pinRightBottom); } var ballRightBottom = CreateElement(Symbols.Ball, Colors.Red, Colors.Black) as Ball; if (ballRightBottom != null) { ballRightBottom.Width = 10; ballRightBottom.Height = 10; ballRightBottom.ToolTip = "Ball with same coordinates like pin"; ballRightBottom.SetValue(ShapeCanvas.LocationProperty, new Point(location.X - 320, location.Y)); Panel.SetZIndex(ballRightBottom, -1); AddToLayer(ballRightBottom); } var pinCenter = CreateElement(Symbols.Pin, Colors.Green, Colors.Black) as Pin; if (pinCenter != null) { pinCenter.SetValue(ShapeCanvas.LocationProperty, new Point(location.X - 320, location.Y + 150)); pinCenter.ToolTip = "Pin with default anchor"; Panel.SetZIndex(pinCenter, -1); AddToLayer(pinCenter); } var ballCenter = CreateElement(Symbols.Ball, Colors.Red, Colors.Black) as Ball; if (ballCenter != null) { ballCenter.Width = 10; ballCenter.Height = 10; ballCenter.ToolTip = "Ball with same coordinates like pin"; ballCenter.SetValue(ShapeCanvas.LocationProperty, new Point(location.X - 320, location.Y + 150)); Panel.SetZIndex(ballCenter, -1); AddToLayer(ballCenter); } #endregion // doc:sample anchor #region doc:sample ScaleProperty var starStandard = CreateElement(Symbols.Star, Colors.Green, Colors.Black) as Star; if (starStandard != null) { starStandard.SetValue(ShapeCanvas.LocationProperty, new Point(location.X - 100, location.Y + 960)); starStandard.Width = starStandard.Height = 40; starStandard.ToolTip = "Star with size 40 and scale 1 (standard display)"; starStandard.SetValue(ShapeCanvas.ScaleProperty, 1.0); Panel.SetZIndex(starStandard, -1); AddToLayer(starStandard); } var starBig = CreateElement(Symbols.Star, Colors.Green, Colors.Black) as Star; if (starBig != null) { starBig.SetValue(ShapeCanvas.LocationProperty, new Point(location.X, location.Y + 960)); starBig.Width = starBig.Height = 40; starBig.ToolTip = "Star with size 40 and scale 3 (object bigger and border thicker)"; starBig.SetValue(ShapeCanvas.ScaleProperty, 3.0); Panel.SetZIndex(starBig, -1); AddToLayer(starBig); } #endregion // doc:sample ScaleProperty #region doc:sample ScaleFactor var starConstant = CreateElement(Symbols.Star, Colors.Red, Colors.Black) as Star; if (starConstant != null) { starConstant.SetValue(ShapeCanvas.LocationProperty, new Point(location.X + 320, location.Y + 960)); starConstant.Width = starConstant.Height = 80; starConstant.ToolTip = "Star with size 80 and scale factor 0 (constant object size, standard display)"; ShapeCanvas.SetScaleFactor(starConstant, 0); Panel.SetZIndex(starConstant, -1); AddToLayer(starConstant); } var starHalfEnlarged = CreateElement(Symbols.Star, Colors.Yellow, Colors.Black) as Star; if (starHalfEnlarged != null) { starHalfEnlarged.SetValue(ShapeCanvas.LocationProperty, new Point(location.X + 370, location.Y + 960)); starHalfEnlarged.Width = starHalfEnlarged.Height = 80; starHalfEnlarged.ToolTip = "Star with size 80 and scale factor 0.5 (object is half enlarged if the map zooms)"; ShapeCanvas.SetScaleFactor(starHalfEnlarged, 0.5); Panel.SetZIndex(starHalfEnlarged, -1); AddToLayer(starHalfEnlarged); } var starEnlarged = CreateElement(Symbols.Star, Colors.Green, Colors.Black) as Star; if (starEnlarged != null) { starEnlarged.SetValue(ShapeCanvas.LocationProperty, new Point(location.X + 420, location.Y + 960)); starEnlarged.Width = starEnlarged.Height = 80; starEnlarged.ToolTip = "Star with size 80 and scale factor 1 (object is enlarged if the map zooms)"; ShapeCanvas.SetScaleFactor(starEnlarged, 1); Panel.SetZIndex(starEnlarged, -1); AddToLayer(starEnlarged); } #endregion // doc:sample ScaleFactor // our demo data var stores = new List <Store> { new Store { Name = "HH-South", Latitude = 53.55, Longitude = 10.02, Sales = new List <Sale> { new Sale { Type = "Food", Amount = 30 }, new Sale { Type = "Non Food", Amount = 70 } } }, new Store { Name = "HH-North", Latitude = 53.56, Longitude = 10.02, Sales = new List <Sale> { new Sale { Type = "Food", Amount = 40 }, new Sale { Type = "Non Food", Amount = 50 }, new Sale { Type = "Pet Food", Amount = 10 } } } }; foreach (var store in stores) { // initialize a pie chart for each element var chartView = new Chart(); chartView.BeginInit(); chartView.Width = 300; chartView.Height = 250; chartView.Background = new SolidColorBrush(Color.FromArgb(192, 255, 255, 255)); var pieSeries = new PieSeries(); chartView.Title = store.Name; pieSeries.IndependentValuePath = "Type"; pieSeries.DependentValuePath = "Amount"; pieSeries.ItemsSource = store.Sales; pieSeries.IsSelectionEnabled = true; chartView.Series.Add(pieSeries); chartView.EndInit(); // Add to map ShapeCanvas.SetLocation(chartView, new Point(store.Longitude, store.Latitude)); ShapeCanvas.SetAnchor(chartView, LocationAnchor.Center); ShapeCanvas.SetScaleFactor(chartView, .1); // adopt the element to the scale factor shapeLayer2.Shapes.Add(chartView); } #region doc:center map to location // center map to location wpfMap.SetMapLocation(new Point(location.X + 1000, location.Y + 650), 14.7, "EPSG:31467"); #endregion //doc:center map to location }
// Shows how to add an arbitrary controls to the map // As sample the pie charts series of Wpf toolkit is used // http://wpf.codeplex.com/releases/view/40535 public void AddPieCharts(ShapeLayer layer) { // our demo data var stores = new List <Store> { new Store { Name = "KA-Center", Latitude = 48.96, Longitude = 8.39, Sales = new List <Sale> { new Sale { Type = "Food", Amount = 30 }, new Sale { Type = "Non Food", Amount = 70 } } }, new Store { Name = "KA-North", Latitude = 49.04, Longitude = 8.41, Sales = new List <Sale> { new Sale { Type = "Food", Amount = 40 }, new Sale { Type = "Non Food", Amount = 50 }, new Sale { Type = "Pet Food", Amount = 10 } } } }; foreach (var store in stores) { // initialize a pie chart for each element var chart = new Chart(); chart.BeginInit(); chart.Width = 300; chart.Height = 250; chart.Background = new SolidColorBrush(Color.FromArgb(192, 255, 255, 255)); var pieSeries = new PieSeries(); chart.Title = store.Name; pieSeries.IndependentValuePath = "Type"; pieSeries.DependentValuePath = "Amount"; pieSeries.ItemsSource = store.Sales; pieSeries.IsSelectionEnabled = true; chart.Series.Add(pieSeries); chart.EndInit(); // Add to map ShapeCanvas.SetLocation(chart, new Point(store.Longitude, store.Latitude)); ShapeCanvas.SetAnchor(chart, LocationAnchor.Center); ShapeCanvas.SetScale(chart, 2); ShapeCanvas.SetScaleFactor(chart, .25); // adopt the element to the scale factor layer.Shapes.Add(chart); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { // go to Karlsruhe castle var myLocation = new Point(8.4044, 49.01405); Map.SetMapLocation(myLocation, 14); // add OSM tiles Map.Layers.Add(new TiledLayer("OSM_DE") { Caption = "OpenStreetMap.DE", IsBaseMapLayer = true, TiledProvider = new RemoteTiledProvider { MinZoom = 0, MaxZoom = 18, RequestBuilderDelegate = (x, y, level) => $"https://{"abc"[(x ^ y) % 3]}.tile.openstreetmap.de/tiles/osmde/{level}/{x}/{y}.png", }, Copyright = $"Map © OpenStreetMap contributors", Icon = ResourceHelper.LoadBitmapFromResource("Ptv.XServer.Controls.Map;component/Resources/Background.png") }); // add basic xServer tiles // Map.Layers.Add(new TiledLayer("xserver") // { // Caption = "PTV xServer", // IsBaseMapLayer = true, // TiledProvider = new RemoteTiledProvider // { // MinZoom = 0, // MaxZoom = 22, // RequestBuilderDelegate = (x, y, level) => // $"https://s0{"1234"[(x ^ y) % 4]}-xserver2-test.cloud.ptvgroup.com/services/rest/XMap/tile/" + // $"{level}/{x}/{y}?storedProfile=silkysand&xtok=<your-xserver-internet-token>" // }, // Copyright = $"© PTV, HERE", // Icon = ResourceHelper.LoadBitmapFromResource("Ptv.XServer.Controls.Map;component/Resources/Background.png") // }); // add stuff var myLayer = new ShapeLayer("MyLayer") { LocalOffset = myLocation // this new property eliminates jitter at deep zoom levels }; Map.Layers.Add(myLayer); // add push-pin Control pin = new Pin { Width = 50, // regarding scale fatoring Height = 50, ToolTip = "I am a pin!", Color = Colors.Red }; ShapeCanvas.SetLocation(pin, myLocation); ShapeCanvas.SetAnchor(pin, LocationAnchor.RightBottom); ShapeCanvas.SetScaleFactor(pin, 0.1); Panel.SetZIndex(pin, 100); myLayer.Shapes.Add(pin); // add geographic circle double radius = 435; // radius in meters double cosB = Math.Cos(myLocation.Y / 360.0 * (2 * Math.PI)); // factor depends on latitude double ellipseSize = Math.Abs(1.0 / cosB * radius) * 2; // size mercator units var ellipse = new Ellipse { Width = ellipseSize, Height = ellipseSize, Fill = new SolidColorBrush(Color.FromArgb(128, 0, 0, 255)), Stroke = new SolidColorBrush(Colors.Black), StrokeThickness = radius / 20, ToolTip = "I am a circle!" }; ShapeCanvas.SetScaleFactor(ellipse, 1); // scale linear ShapeCanvas.SetLocation(ellipse, myLocation); myLayer.Shapes.Add(ellipse); }