MapEllipse center from Code Behind

1 Answer 49 Views
Map
Ohad
Top achievements
Rank 3
Bronze
Iron
Iron
Ohad asked on 25 Oct 2022, 12:21 PM | edited on 25 Oct 2022, 12:29 PM

I would like to create a MapEllipse from Code Behind using values that I have stored.

But the property Center only has a get method.

How can I determine the Center of the MapEllipse from Code Behind?

 

 

var mapEllipse = new MapEllipse();
mapEllipse.Width = mapEllipse.Height = 50;
mapEllipse.Fill = Brushes.Yellow;
mapEllipse.Opacity = 0.2;
mapEllipse.Stroke = Brushes.Red;
mapEllipse.StrokeThickness = 2;
//mapEllipse.Center = ?

 

Thanks

 

1 Answer, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 27 Oct 2022, 09:55 AM

Hello Ohad,

Thank you for the provided code snippet.

Instead of the Center property, you need to set the Location property of the MapEllipse in this case. As mentioned in the Map Shapes article, the top left corner coincides with the given location. In order to position the rectangle otherwise (centrally, for example) you might want to use the HotSpot feature.

            var mapEllipse = new MapEllipse();
            mapEllipse.Width = mapEllipse.Height = 50;
            mapEllipse.Fill = Brushes.Yellow;
            mapEllipse.Opacity = 0.2;
            mapEllipse.Stroke = Brushes.Red;
            mapEllipse.StrokeThickness = 2;
            mapEllipse.Location = new Location(42.6957539183824, 23.3327663758679);
            MapLayer.SetHotSpot(mapEllipse, new HotSpot() { X = 0.5, Y = 0.5 });

I've gone ahead and set up a small sample project to demonstrate this in action. Please have a look and let me know if the same approach works in your original application.

Regards,
Dilyan Traykov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Map
Asked by
Ohad
Top achievements
Rank 3
Bronze
Iron
Iron
Answers by
Dilyan Traykov
Telerik team
Share this question
or