1

How do I draw an Ellipse using C# in my WPF application on a Bing map? I'm really new at this so bear with me. I've managed to get my WPF window working with a bing map and I can see the location I want. Looks great so far. I've found examples for pins and some results from 2012 and 2014 but they weren't helpful and some were in XAML and I need to do this without that.

I have a map named 'geoMap' and this code to create an ellipse

Ellipse circle = new Ellipse()
{
Width = 9,
Height = 9,
Stroke = Brushes.CornflowerBlue,
StrokeThickness = 5
};

How do I connect the two?

geoMap.Children.Add(circle)  

is what I think should work, but how I do give the ellipse a LAT/LON coordinate and get it on my map? How do I tie the two together not using XAML. I want to use an ellipse and not a pin, and I need to do this via Lat/long coordinates. My guess is I'm missing a layer over the map, and the code to position the ellipse. I need to be able remove this ellipse later and redraw it at a new coordinate.

Edit for clarity: I'm using the Microsoft.Maps.MapControl.WPF if that helps

Any help would be most appreciated. I'm using c# in visual studio 2019 if that helps. Thank you.

JKos
  • 11
  • 2
  • 1
    Welcome to Stack Overflow! Which Map Control are you using? Typically you'd have to find a method in that control to add an ellipse if you want it shown at a specific geographic location on the map. – Erik H Jun 15 '20 at 06:13
  • Thank you for the reply. I'm using the Microsoft.Maps.MapControl.WPF in my xaml file. Creating a – JKos Jun 15 '20 at 06:28
  • There is an attached property [MapLayer.Position](https://learn.microsoft.com/en-us/previous-versions/bing/wpf-control/hh709476(v=msdn.10)), which you have to set on the Ellipse. Not sure if the Ellipse has to be a child of a MapLayer. – Clemens Jun 15 '20 at 07:49
  • You can template a pushpin as anything you like. That would including as an ellipse rather than rectangle as used here: https://stackoverflow.com/questions/42392015/bing-maps-in-c-sharp-change-pushpin-image – Andy Jun 15 '20 at 09:28

0 Answers0